Title: | Search Spaces for 'mlr3' |
---|---|
Description: | Collection of search spaces for hyperparameter optimization in the 'mlr3' ecosystem. It features ready-to-use search spaces for many popular machine learning algorithms. The search spaces are from scientific articles and work for a wide range of data sets. |
Authors: | Marc Becker [cre, aut]
|
Maintainer: | Marc Becker <[email protected]> |
License: | LGPL-3 |
Version: | 0.5.2 |
Built: | 2025-01-24 07:08:22 UTC |
Source: | CRAN |
Collection of search spaces for hyperparameter optimization in the 'mlr3' ecosystem. It features ready-to-use search spaces for many popular machine learning algorithms. The search spaces are from scientific articles and work for a wide range of data sets.
Maintainer: Marc Becker [email protected] (ORCID)
Other contributors:
Michel Lang [email protected] (ORCID) [contributor]
Useful links:
Report bugs at https://github.com/mlr-org/mlr3tuningspaces/issues
Function to retrieve TuningSpace objects from mlr_tuning_spaces and further, allows a mlr3::Learner to be directly configured with a search space. This function belongs to mlr3::mlr_sugar family.
lts(x, ...) ## S3 method for class 'missing' lts(x, ...) ## S3 method for class 'character' lts(x, ...) ## S3 method for class 'Learner' lts(x, ...) ltss(x)
lts(x, ...) ## S3 method for class 'missing' lts(x, ...) ## S3 method for class 'character' lts(x, ...) ## S3 method for class 'Learner' lts(x, ...) ltss(x)
x |
( |
... |
(named list of paradox::TuneToken | |
TuningSpace if x
is character()
.
mlr3::Learner if x
is mlr3::Learner.
Or a list of objects for the ltss()
function.
missing, mlr_tuning_spaces dictionary
a character
, TuningSpace
a mlr3::Learner, mlr3::Learner with paradox::TuneToken
a list()
, list of TuningSpace or mlr3::Learner
# load tuning space lts("classif.rpart.default") # load tuning space and add parameter lts("classif.rpart.default", maxdepth = to_tune(1, 15)) # load tuning space and remove parameter lts("classif.rpart.default", minsplit = NULL) # load tuning space and overwrite parameter lts("classif.rpart.default", minsplit = to_tune(32, 128)) # load learner and apply tuning space in one go lts(lrn("classif.rpart")) # load learner, overwrite parameter and apply tuning space lts(lrn("classif.rpart"), minsplit = to_tune(32, 128)) # load multiple tuning spaces ltss(c("classif.rpart.default", "classif.ranger.default"))
# load tuning space lts("classif.rpart.default") # load tuning space and add parameter lts("classif.rpart.default", maxdepth = to_tune(1, 15)) # load tuning space and remove parameter lts("classif.rpart.default", minsplit = NULL) # load tuning space and overwrite parameter lts("classif.rpart.default", minsplit = to_tune(32, 128)) # load learner and apply tuning space in one go lts(lrn("classif.rpart")) # load learner, overwrite parameter and apply tuning space lts(lrn("classif.rpart"), minsplit = to_tune(32, 128)) # load multiple tuning spaces ltss(c("classif.rpart.default", "classif.ranger.default"))
A simple mlr3misc::Dictionary storing objects of class TuningSpace.
Each tuning space has an associated help page, see mlr_tuning_spaces_[id]
.
R6::R6Class object inheriting from mlr3misc::Dictionary.
See mlr3misc::Dictionary.
as.data.table(dict, ..., objects = FALSE)
mlr3misc::Dictionary -> data.table::data.table()
Returns a data.table::data.table()
with fields "key", "label", "learner", and "n_values" as columns.
If objects
is set to TRUE
, the constructed objects are returned in the list column named object
.
as.data.table(mlr_tuning_spaces) mlr_tuning_spaces$get("classif.ranger.default") lts("classif.ranger.default")
as.data.table(mlr_tuning_spaces) mlr_tuning_spaces$get("classif.ranger.default") lts("classif.ranger.default")
Tuning spaces from the Bischl (2023) article.
s Logscale
alpha
k Logscale
distance
kernel [“rectangular”, “optimal”, “epanechnikov”, “biweight”, “triweight”, “cos”, “inv”, “gaussian”, “rank”]
mtry.ratio
replace [TRUE,FALSE]
sample.fraction
num.trees
minsplit Logscale
minbucket Logscale
cp Logscale
cost Logscale
kernel [“polynomial”, “radial”, “sigmoid”, “linear”]
degree
gamma Logscale
eta Logscale
nrounds
max_depth
colsample_bytree
colsample_bylevel
lambda Logscale
alpha Logscale
subsample
Bischl B, Binder M, Lang M, Pielok T, Richter J, Coors S, Thomas J, Ullmann T, Becker M, Boulesteix A, Deng D, Lindauer M (2023). “Hyperparameter Optimization: Foundations, Algorithms, Best Practices and Open Challenges.”
Tuning spaces from the Kuehn (2018) article.
alpha
s Logscale
k
num.trees
replace [TRUE,FALSE]
sample.fraction
mtry.ratio
respect.unordered.factors [“ignore”, “order”]
min.node.size
The tuning space of the ranger learner is slightly different from the original paper.
The hyperparameter mtry.power
is replaced by mtry.ratio
and min.node.size
is explored in a range from 1 to 100.
cp
maxdepth
minbucket
minsplit
kernel [“linear”, “polynomial”, “radial”]
cost Logscale
gamma Logscale
degree
nrounds
eta Logscale
subsample
booster [“gblinear”, “gbtree”, “dart”]
max_depth
min_child_weight Logscale
colsample_bytree
colsample_bylevel
lambda Logscale
alpha Logscale
Kuehn D, Probst P, Thomas J, Bischl B (2018). “Automatic Exploration of Machine Learning Experiments on OpenML.” 1806.10961, https://arxiv.org/abs/1806.10961.
Tuning spaces from the Binder (2020) article.
alpha
s Logscale
k
num.trees
replace [TRUE,FALSE]
sample.fraction
mtry.ratio
respect.unordered.factors [“ignore”, “order”, “partition”]
min.node.size
splitrule [“gini”, “extratrees”]
num.random.splits
mtry.power
is replaced by mtry.ratio
.
cp Logscale
maxdepth
minbucket
minsplit
kernel [“linear”, “polynomial”, “radial”]
cost Logscale
gamma Logscale
tolerance Logscale
degree
booster [“gblinear”, “gbtree”, “dart”]
nrounds Logscale
eta Logscale
gamma Logscale
lambda Logscale
alpha Logscale
subsample
max_depth
min_child_weight Logscale
colsample_bytree
colsample_bylevel
rate_drop
skip_drop
Binder M, Pfisterer F, Bischl B (2020). “Collecting Empirical Data About Hyperparameters for Data Driven AutoML.” https://www.automl.org/wp-content/uploads/2020/07/AutoML_2020_paper_63.pdf.
This class defines a tuning space for hyperparameter tuning.
For tuning, it is important to create a search space that defines the range over which hyperparameters should be tuned.
TuningSpace
object consists of search spaces from peer-reviewed articles which work well for a wide range of data sets.
The $values
field stores a list of paradox::TuneToken which define the search space.
These tokens can be assigned to the $values
slot of a learner's paradox::ParamSet.
When the learner is tuned, the tokens are used to create the search space.
as.data.table.TuningSpace(x)
Returns a tabular view of the tuning space.
TuningSpace -> data.table::data.table()
x
(TuningSpace)
id
(character(1)
)
Identifier of the object.
values
(list()
)
List of paradox::TuneToken that describe the tuning space and fixed parameter values.
tags
(character()
)
Arbitrary tags to group and filter tuning space e.g. "classification"
or "regression
".
learner
(character(1)
)
mlr3::Learner of the tuning space.
package
(character(1)
)
Packages which provide the mlr3::Learner, e.g. mlr3learners for the learner
mlr3learners::LearnerClassifRanger which interfaces the ranger package.
label
(character(1)
)
Label for this object.
Can be used in tables, plot and text output instead of the ID.
man
(character(1)
)
String in the format [pkg]::[topic]
pointing to a manual page for this object.
The referenced help package can be opened via method $help()
.
new()
Creates a new instance of this R6 class.
TuningSpace$new( id, values, tags, learner, package = character(), label = NA_character_, man = NA_character_ )
id
(character(1)
)
Identifier for the new instance.
values
(list()
)
List of paradox::TuneToken that describe the tuning space and fixed parameter values.
tags
(character()
)
Tags to group and filter tuning spaces e.g. "classification"
or "regression
".
learner
(character(1)
)
mlr3::Learner of the tuning space.
package
(character()
)
Packages which provide the mlr3::Learner, e.g. mlr3learners for the learner
mlr3learners::LearnerClassifRanger which interfaces the ranger package.
label
(character(1)
)
Label for the new instance.
Can be used in tables, plot and text output instead of the ID.
man
(character(1)
)
String in the format [pkg]::[topic]
pointing to a manual page for for the new instance.
The referenced help package can be opened via method $help()
.
get_learner()
Returns a learner with paradox::TuneToken set in parameter set.
TuningSpace$get_learner(...)
...
(named ‘list()’)
Passed to mlr3::lrn()
. Named arguments passed to the constructor, to
be set as parameters in the paradox::ParamSet, or to be set as public
field. See mlr3misc::dictionary_sugar_get()
for more details.
format()
Helper for print outputs.
TuningSpace$format(...)
...
(ignored).
help()
Opens the corresponding help page referenced by field $man
.
TuningSpace$help()
print()
Printer.
TuningSpace$print(...)
...
(ignored).
clone()
The objects of this class are cloneable with this method.
TuningSpace$clone(deep = FALSE)
deep
Whether to make a deep clone.
library(mlr3tuning) # Get default tuning space of rpart learner tuning_space = lts("classif.rpart.default") # Set tuning space learner = lrn("classif.rpart") learner$param_set$values = tuning_space$values # Tune learner instance = tune( tnr("random_search"), task = tsk("pima"), learner = learner, resampling = rsmp ("holdout"), measure = msr("classif.ce"), term_evals = 10) instance$result library(mlr3pipelines) # Set tuning space in a pipeline graph_learner = as_learner(po("subsample") %>>% lts(lrn("classif.rpart")))
library(mlr3tuning) # Get default tuning space of rpart learner tuning_space = lts("classif.rpart.default") # Set tuning space learner = lrn("classif.rpart") learner$param_set$values = tuning_space$values # Tune learner instance = tune( tnr("random_search"), task = tsk("pima"), learner = learner, resampling = rsmp ("holdout"), measure = msr("classif.ce"), term_evals = 10) instance$result library(mlr3pipelines) # Set tuning space in a pipeline graph_learner = as_learner(po("subsample") %>>% lts(lrn("classif.rpart")))