cla_tune: Classification Tune

View source: R/cla_tune.R

cla_tuneR Documentation

Classification Tune

Description

This function performs a grid search or random search over specified hyperparameter values to optimize a base classification model

Usage

cla_tune(base_model, folds = 10, metric = "accuracy")

Arguments

base_model

base model for tuning

folds

number of folds for cross-validation

metric

metric used to optimize

Value

returns a cla_tune object

Examples

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

# hyper parameter setup
tune <- cla_tune(cla_mlp("Species", levels(iris$Species)))
ranges <- list(size=c(3:5), decay=c(0.1))

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

# testing optimization
test_prediction <- predict(model, test)
test_predictand <- adjust_class_label(test[,"Species"])
test_eval <- evaluate(model, test_predictand, test_prediction)
test_eval$metrics

daltoolbox documentation built on Nov. 3, 2024, 9:06 a.m.