reg_tune: Regression tuning (k-fold CV)

View source: R/reg_tune.R

reg_tuneR Documentation

Regression tuning (k-fold CV)

Description

Tune hyperparameters of a base regressor via k‑fold cross‑validation minimizing an error metric (MSE).

Usage

reg_tune(base_model, folds = 10, ranges = NULL)

Arguments

base_model

base model for tuning

folds

number of folds for cross-validation

ranges

a list of hyperparameter ranges to explore

Value

returns a reg_tune object.

References

Kohavi, R. (1995). A Study of Cross-Validation and Bootstrap for Accuracy Estimation and Model Selection.

Examples

# preparing dataset for random sampling
data(Boston)
sr <- sample_random()
sr <- train_test(sr, Boston)
train <- sr$train
test <- sr$test

# hyper parameter setup
tune <- reg_tune(reg_mlp("medv"), ranges = list(size=c(3), decay=c(0.1,0.5)))

# hyper parameter optimization
model <- fit(tune, train, ranges)

test_prediction <- predict(model, test)
test_predictand <- test[,"medv"]
test_eval <- evaluate(model, test_predictand, test_prediction)
test_eval$metrics

daltoolbox documentation built on Nov. 5, 2025, 7:09 p.m.