## Load SCE package and the supporting packages
library(SCE)
## Load the training and testing data files
data("Streamflow_training_10var")
data("Streamflow_testing_10var")
## Define the independent (x) and dependent (y) variables
Predictors <- c("Prcp", "SRad", "Tmax", "Tmin", "VP", "smlt", "swvl1", "swvl2", "swvl3", "swvl4")
Predictants <- c("Flow")
## Build a single SCA tree
SCA_tree <- SCA(
Training_data = Streamflow_training_10var,
X = Predictors,
Y = Predictants,
Nmin = 5,
alpha = 0.05,
resolution = 1000
)
## Calculate variable importance for the single tree
Tree_importance <- SCA_importance(SCA_tree)
## Print the results
print("Single tree importance scores:")
print(Tree_importance)
## Visualize the importance scores
Importance_ranking_sorted <- Tree_importance[order(-Tree_importance$Relative_Importance), ]
barplot(
Importance_ranking_sorted$Relative_Importance,
names.arg = Importance_ranking_sorted$Predictor,
las = 2, # vertical labels
col = "skyblue",
main = "Variable Importance (SCE)",
ylab = "Importance",
xlab = "Predictor"
)
Run the code above in your browser using DataLab