# Example 1: Random Forest for regression task
library(MLwrap)
data(sim_data) # sim_data is a simulated dataset with psychological variables
wrap_object <- preprocessing(
df = sim_data,
formula = psych_well ~ depression + emot_intel + resilience + life_sat,
task = "regression"
)
wrap_object <- build_model(
analysis_object = wrap_object,
model_name = "Random Forest",
hyperparameters = list(
mtry = 3,
trees = 100
)
)
# It is safe to reuse the same object name (e.g., wrap_object, or whatever) step by step,
# as all previous results and information are retained within the updated analysis object.
# Example 2: SVM for classification task
data(sim_data) # sim_data is a simulated dataset with psychological variables
wrap_object <- preprocessing(
df = sim_data,
formula = psych_well_bin ~ depression + emot_intel + resilience + life_sat,
task = "classification"
)
wrap_object <- build_model(
analysis_object = wrap_object,
model_name = "SVM",
hyperparameters = list(
type = "rbf",
cost = 1,
margin = 0.1,
rbf_sigma = 0.05
)
)
Run the code above in your browser using DataLab