# \donttest{
## Load required packages
library(SCE)
library(parallel)
## Load example datasets
data("Streamflow_training_10var")
data("Streamflow_testing_10var")
## Define predictors and predictants
Predictors <- c("Prcp","SRad","Tmax","Tmin","VP","smlt","swvl1","swvl2","swvl3","swvl4")
Predictants <- c("Flow")
## Build the SCE model
Model <- SCE(
Training_data = Streamflow_training_10var,
X = Predictors,
Y = Predictants,
mfeature = round(0.5 * length(Predictors)),
Nmin = 5,
Ntree = 48,
alpha = 0.05,
resolution = 1000,
parallel = FALSE
)
## Generate predictions for test data
predictions <- SCE_Prediction(
X_sample = Streamflow_testing_10var,
model = Model
)
## Conduct comprehensive model evaluation
Results <- Model_simulation(
Testing_data = Streamflow_testing_10var,
model = Model
)
## Access different prediction components
training_predictions <- Results$Training
validation_predictions <- Results$Validation
testing_predictions <- Results$Testing
## Calculate variable importance with OOB weighting (default)
Importance_weighted <- Wilks_importance(Model)
## Calculate variable importance without OOB weighting
Importance_unweighted <- Wilks_importance(Model, OOB_weight = FALSE)
## Visualize the importance scores
Importance_ranking_sorted <- Importance_weighted[
order(-Importance_weighted$Relative_Importance),
]
barplot(
Importance_ranking_sorted$Relative_Importance,
names.arg = Importance_ranking_sorted$Predictor,
las = 2,
col = "skyblue",
main = "Variable Importance (SCE)",
ylab = "Importance",
xlab = "Predictor"
)
# }
Run the code above in your browser using DataLab