RandomSearchCV | R Documentation |
Hyperparameter tuning using random search scheme.
Given a set of hyper parameters, random search trainer provides a faster way of hyper parameter tuning. Here, the number of models to be trained can be defined by the user.
superml::GridSearchCV
-> RandomSearchTrainer
n_iter
number of models to be trained
new()
RandomSearchCV$new( trainer = NA, parameters = NA, n_folds = NA, scoring = NA, n_iter = NA )
trainer
superml trainer object, must be either XGBTrainer, LMTrainer, RFTrainer, NBTrainer
parameters
list, list containing parameters
n_folds
integer, number of folds to use to split the train data
scoring
character, scoring metric used to evaluate the best model, multiple values can be provided. currently supports: auc, accuracy, mse, rmse, logloss, mae, f1, precision, recall
n_iter
integer, number of models to be trained
Create a new 'RandomSearchTrainer' object.
A 'RandomSearchTrainer' object.
rf <- RFTrainer$new() rst <-RandomSearchCV$new(trainer = rf, parameters = list(n_estimators = c(100,500), max_depth = c(5,2,10,14)), n_folds = 3, scoring = c('accuracy','auc'), n_iter = 4)
fit()
RandomSearchCV$fit(X, y)
X
data.frame containing features
y
character, name of target variable
Train the model on given hyperparameters
NULL, tunes hyperparameters and stores the result in memory
rf <- RFTrainer$new() rst <-RandomSearchCV$new(trainer = rf, parameters = list(n_estimators = c(100,500), max_depth = c(5,2,10,14)), n_folds = 3, scoring = c('accuracy','auc'), n_iter = 4) data("iris") rst$fit(iris, "Species") rst$best_iteration()
clone()
The objects of this class are cloneable with this method.
RandomSearchCV$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------
## Method `RandomSearchCV$new`
## ------------------------------------------------
rf <- RFTrainer$new()
rst <-RandomSearchCV$new(trainer = rf,
parameters = list(n_estimators = c(100,500),
max_depth = c(5,2,10,14)),
n_folds = 3,
scoring = c('accuracy','auc'),
n_iter = 4)
## ------------------------------------------------
## Method `RandomSearchCV$fit`
## ------------------------------------------------
rf <- RFTrainer$new()
rst <-RandomSearchCV$new(trainer = rf,
parameters = list(n_estimators = c(100,500),
max_depth = c(5,2,10,14)),
n_folds = 3,
scoring = c('accuracy','auc'),
n_iter = 4)
data("iris")
rst$fit(iris, "Species")
rst$best_iteration()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.