Define the Python Learner
set_py_engine.Rd
Augment the model spec object generated by {parsnip}
with information
needed to run sklearn
models. See available models with rpwf_avail_models()
.
Importantly, also passes sklearn
base learner specific arguments through
the ...
parameter.
Arguments
- obj
a model spec object generated by
parsnip::set_engine()
andparsnip::set_mode()
.- py_module
a character value that select the python module that the base learner comes from (i.e.,
xgboost
,sklearn.ensemble
, etc.).- py_base_learner
a character value that select the python base learner, (i.e., XGBClassifier, DecisionTreeClassifier, etc.).
- rpwf_model_tag
a string to name this model. Useful in keeping track of different combinations of models.
- ...
arguments passed to the python base learner via named list. Boolean must be in R format, i.e.,
TRUE
,FALSE
.
Value
a model spec object with additional attributes self$rpwf_model_tag
,
self$py_base_learner
and self$py_base_learner_args
.
Examples
m <- parsnip::boost_tree() |>
parsnip::set_engine("xgboost") |>
parsnip::set_mode("classification") |>
set_py_engine(
"xgboost",
"XGBClassifier",
"my_xgboost_model",
eval_metric = "logloss",
use_label_encoder = FALSE,
verbosity = 0,
silent = TRUE,
n_estimators = 100 # Fix the `n_estimators` at 100
)