Home > Back-end >  Extra learners in mlr3
Extra learners in mlr3

Time:05-07

I cannot use models in mlr3 other than random forest, part, knn, svm, gbm etc. I am using mlr3extralearners package but still it seems there are a lot of models supported. How to use nnet, mlp etc in mlr3. I have a regression problem.

Second point is, is there a difference between regr.randomForest and regr.Ranger models? It seems they have the same parameters and default values. If they are same and produce the same result, then why both are used and why not just one?

Thank you

CodePudding user response:

Filter this list by class "regr" to see which learners are avaiable for a regression problem.

To initialise a learner, e.g. "regr.kknn" do

# (1) mlr3 learners 
# install.packages("mlr3learners")
library(mlr3learners) 
#> Loading required package: mlr3
#mlr_learners

# (2) extra leaners
# remotes::install_github("mlr-org/mlr3extralearners")
library(mlr3extralearners)
regr_kknn = lrn("regr.kknn")
#> Warning: Package 'kknn' required but not installed for Learner 'regr.kknn'
print(regr_kknn)
#> <LearnerRegrKKNN:regr.kknn>
#> * Model: -
#> * Parameters: k=7
#> * Packages: mlr3, mlr3learners, kknn
#> * Predict Type: response
#> * Feature types: logical, integer, numeric, factor, ordered
#> * Properties: -

Created on 2022-05-06 by the reprex package (v2.0.1)

Then set hyper parameters, train, predict, resample etc. as described in the pleasant mlr3 book.

Regarding your second question, I think {mlr3} does not implement learners on its own. Instead it relies on several libraries. Probably this is the reason why regr.randomForest and regr.Ranger are available.

  • Related