Random optimization of hyperparameters
random_search(train_data, y, models = NULL, engine, type, max_evals = 10)
A training data for models created by `prepare_data()` function.
A string that indicates a target column name.
A list of models trained by `train_models()` function. They will be compered with models trained with different hyperparameters
A vector of tree-based models that shall be created. Possible values are: `ranger`, `xgboost`, `desicion tree`, `lightgbm`, `catboost`.
A string that determines if Machine Learning task is the `binary_clf` or `regression` task.
The number of trained models for each model type in `engine`.
A list consisting of models created via random search and ranked list of models scores.
data(iris)
iris_bin <- iris[1:100, ]
type <- guess_type(iris_bin, 'Species')
preprocessed_data <- preprocessing(iris_bin, 'Species', type)
#> Error in if (advanced) { del_cor <- delete_correlated_values(pre_data, y, verbose = verbose) pre_data <- del_cor$data pre_data <- delete_id_columns(pre_data) pre_data <- boruta_selection(pre_data, y)}: argument is not interpretable as logical
preprocessed_data <- preprocessed_data$data
#> Error in eval(expr, envir, enclos): object 'preprocessed_data' not found
split_data <-
train_test_balance(preprocessed_data,
'Species',
balance = FALSE)
#> Error in train_test_balance(preprocessed_data, "Species", balance = FALSE): object 'preprocessed_data' not found
train_data <-
prepare_data(split_data$train,
'Species',
engine = c('ranger', 'xgboost', 'decision_tree', 'lightgbm', 'catboost'))
#> Error in as.data.frame(unclass(data), stringsAsFactors = TRUE): object 'split_data' not found
test_data <-
prepare_data(split_data$test,
'Species',
engine = c('ranger', 'xgboost', 'decision_tree', 'lightgbm', 'catboost'),
predict = TRUE,
train = split_data$train)
#> Error in as.data.frame(unclass(data), stringsAsFactors = TRUE): object 'split_data' not found
model <-
train_models(train_data,
'Species',
engine = c('ranger', 'xgboost', 'decision_tree', 'lightgbm', 'catboost'),
type = type)
#> Error in ranger::ranger(dependent.variable.name = y, data = data$ranger_data, classification = TRUE, probability = TRUE): object 'train_data' not found
predictions <-
predict_models(model,
test_data,
'Species',
engine = c('ranger', 'xgboost', 'decision_tree', 'lightgbm', 'catboost'),
type = type)
#> Error in predict(models[[i]], data$ranger_data): object 'model' not found
score <- score_models(model, predictions, test_data$ranger_data$Species, type)
#> Error in matrix(nrow = length(models), ncol = length(metrics_binary_clf) + nr_add_col): object 'model' not found
random_best <- random_search(train_data,
test_data,
y = 'Species',
engine = c('ranger', 'xgboost', 'decision_tree',
'lightgbm', 'catboost'),
type = type,
max_evals = 4)
#> Error in ranger::ranger(data = train_data$ranger_data, dependent.variable.name = y, num.trees = unlist(sample_ranger_grid[i, "num.trees"]), mtry = unlist(sample_ranger_grid[i, "try"]), min.node.size = unlist(sample_ranger_grid[i, "min.node.size"]), max.depth = unlist(sample_ranger_grid[i, "max.depth"]), classification = classification, probability = probability): object 'train_data' not found