# Example 1: Fine tuning function applied to a regression task
library(MLwrap)
data(sim_data) # sim_data is a simulated dataset wtih 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 = 50
)
)
wrap_object <- fine_tuning(wrap_object,
tuner = "Grid Search CV",
metrics = c("rmse")
)
# Extracting Evaluation Results
table_best_hyp <- table_best_hyperparameters(wrap_object)
table_results <- table_evaluation_results(wrap_object)
# Plotting Results
wrap_object |>
plot_tuning_results() |>
plot_residuals_distribution() |>
plot_scatter_residuals()
Run the code above in your browser using DataLab