Classification Neural Network Learner
Source:R/learner_fastai_classif_fastai.R
mlr_learners_classif.fastai.Rd
Simple and fast neural nets for tabular data classification.
Calls fastai::tabular_learner()
from package fastai.
Installation
The Python dependencies are automatically installed via reticulate::py_require()
.
See Installing Python Dependencies for more details.
You can manually specify a virtual environment by calling reticulate::use_virtualenv()
prior to calling the $train()
function.
In this virtual environment, the fastai
package and its dependencies must be installed.
Saving a Learner
In order to save a lrn("classif.fastai")
for later usage, it is necessary to call the $marshal()
method on the Learner
before writing it to disk,
as the object will otherwise not be saved correctly.
After loading a marshaled lrn("classif.fastai")
into R again, you then need to call $unmarshal()
to transform it into a useable state.
Initial parameter values
n_epoch
: Needs to be set forfastai::fit()
to work. If no value is given, it is set to 5.eval_metric
: Needs to be set forfastai::predict()
to work. If no value is given, it is set tofastai::accuracy()
.
Meta Information
Task type: “classif”
Predict Types: “response”, “prob”
Feature Types: “logical”, “integer”, “numeric”, “factor”, “ordered”
Required Packages: mlr3, mlr3extralearners, fastai, reticulate
Parameters
Id | Type | Default | Levels | Range |
act_cls | untyped | - | - | |
bn_cont | logical | TRUE | TRUE, FALSE | - |
bn_final | logical | FALSE | TRUE, FALSE | - |
drop_last | logical | FALSE | TRUE, FALSE | - |
embed_p | numeric | 0 | \([0, 1]\) | |
emb_szs | untyped | NULL | - | |
n_epoch | integer | - | \([1, \infty)\) | |
eval_metric | untyped | - | - | |
layers | untyped | - | - | |
loss_func | untyped | - | - | |
lr | numeric | 0.001 | \([0, \infty)\) | |
metrics | untyped | - | - | |
n_out | integer | - | \((-\infty, \infty)\) | |
num_workers | integer | 0 | \((-\infty, \infty)\) | |
opt_func | untyped | - | - | |
patience | integer | 1 | \([1, \infty)\) | |
pin_memory | logical | TRUE | TRUE, FALSE | - |
procs | untyped | NULL | - | |
ps | untyped | NULL | - | |
shuffle | logical | FALSE | TRUE, FALSE | - |
train_bn | logical | TRUE | TRUE, FALSE | - |
wd | integer | - | \([0, \infty)\) | |
wd_bn_bias | logical | FALSE | TRUE, FALSE | - |
use_bn | logical | TRUE | TRUE, FALSE | - |
y_range | untyped | NULL | - | |
bs | integer | 50 | \((-\infty, \infty)\) |
References
Howard, Jeremy, Gugger, Sylvain (2020). “Fastai: A Layered API for Deep Learning.” Information, 11(2), 108. ISSN 2078-2489, doi:10.3390/info11020108 .
See also
as.data.table(mlr_learners)
for a table of available Learners in the running session (depending on the loaded packages).Chapter in the mlr3book: https://mlr3book.mlr-org.com/basics.html#learners
mlr3learners for a selection of recommended learners.
mlr3cluster for unsupervised clustering learners.
mlr3pipelines to combine learners with pre- and postprocessing steps.
mlr3tuning for tuning of hyperparameters, mlr3tuningspaces for established default tuning spaces.
Super classes
mlr3::Learner
-> mlr3::LearnerClassif
-> LearnerClassifFastai
Active bindings
internal_valid_scores
(named
list()
orNULL
) The validation scores extracted fromeval_protocol
which itself is set by fitting thefastai::tab_learner
. If early stopping is activated, this contains the validation scores of the model for the optimaln_epoch
, otherwise then_epoch
for the final model.internal_tuned_values
(named
list()
orNULL
) If early stopping is activated, this returns a list withn_epoch
, which is the last epoch that yielded improvement w.r.t. thepatience
, extracted bymax(eval_protocol$epoch)+1
validate
(
numeric(1)
orcharacter(1)
orNULL
) How to construct the internal validation data. This parameter can be eitherNULL
, a ratio,"test"
, or"predefined"
.marshaled
(
logical(1)
) Whether the learner has been marshaled.
Methods
Inherited methods
mlr3::Learner$base_learner()
mlr3::Learner$configure()
mlr3::Learner$encapsulate()
mlr3::Learner$format()
mlr3::Learner$help()
mlr3::Learner$predict()
mlr3::Learner$predict_newdata()
mlr3::Learner$print()
mlr3::Learner$reset()
mlr3::Learner$selected_features()
mlr3::Learner$train()
mlr3::LearnerClassif$predict_newdata_fast()
Method marshal()
Marshal the learner's model.
Arguments
...
(any)
Additional arguments passed tomlr3::marshal_model()
.
Method unmarshal()
Unmarshal the learner's model.
Arguments
...
(any)
Additional arguments passed tomlr3::marshal_model()
.