A wrapper for ranger::ranger() with probability = TRUE for
use in nadir::super_learner() with multiclass outcomes. This adds a
flexible, nonparametric tree-ensemble counterpart to the parametric
multinomial learners lnr_multinomial_vglm and
lnr_multinomial_nnet.
Arguments
- data
A dataframe to train a learner / learners on.
- formula
A regression formula to use inside this learner.
- weights
Observation weights; see
?lm- ...
Any extra arguments that should be passed to the internal model for model fitting purposes.
Value
A prediction function that accepts newdata,
which returns predictions (a numeric vector of density prediction values at the
outcome value observed in the newdata conditioning on the predictor
variables in newdata).
Examples
df <- mtcars
df$cyl <- as.factor(df$cyl)
lnr_multinomial_ranger(df, cyl ~ hp + mpg)(df)
#> [1] 0.8621619 0.8621619 0.9811921 0.6089825 0.7163079 0.7471913 0.9977333
#> [8] 0.9927921 0.9811921 0.8509325 0.8223730 0.9954476 0.9217960 0.9954476
#> [15] 0.9977333 0.9977333 0.9977333 0.9927921 0.9927921 0.9927921 0.9001603
#> [22] 0.9330063 0.9330063 0.9977333 0.6758690 0.9927921 0.9927921 0.6647873
#> [29] 0.9977333 0.5125032 0.9977333 0.5330492
lnr_multinomial_ranger(iris, Species ~ .)(iris)
#> [1] 1.0000000 0.9996000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [8] 1.0000000 0.9996000 1.0000000 1.0000000 1.0000000 0.9996000 0.9996000
#> [15] 0.9920000 0.9960000 1.0000000 1.0000000 0.9920000 1.0000000 1.0000000
#> [22] 1.0000000 1.0000000 1.0000000 1.0000000 0.9996000 1.0000000 1.0000000
#> [29] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [36] 1.0000000 0.9820000 1.0000000 0.9996000 1.0000000 1.0000000 0.9791579
#> [43] 1.0000000 1.0000000 1.0000000 0.9996000 1.0000000 1.0000000 1.0000000
#> [50] 1.0000000 0.9858690 0.9945698 0.7957889 0.9928016 0.9855667 0.9987111
#> [57] 0.9595556 0.8739365 0.9981111 0.9764849 0.9461698 0.9947421 0.9658325
#> [64] 0.9907524 0.9980000 0.9972754 0.9912032 1.0000000 0.9255722 0.9986349
#> [71] 0.3611897 0.9942159 0.7288389 0.9905937 0.9973111 0.9972754 0.8741921
#> [78] 0.5104841 0.9903421 1.0000000 0.9976349 0.9976349 1.0000000 0.4185183
#> [85] 0.9705143 0.9707603 0.9955698 0.9745024 0.9980000 0.9976349 0.9990000
#> [92] 0.9934667 0.9980000 0.9617698 0.9980000 1.0000000 1.0000000 0.9915889
#> [99] 0.9757698 1.0000000 0.9966278 0.9606595 1.0000000 0.9966341 1.0000000
#> [106] 1.0000000 0.4509333 0.9967056 0.9792897 0.9982778 0.9804944 0.9942381
#> [113] 0.9994286 0.9345921 0.9642310 0.9976278 0.9981341 0.9982778 0.9922381
#> [120] 0.5532556 0.9973063 0.9048786 0.9991111 0.8913294 0.9953500 0.9868833
#> [127] 0.7573349 0.9088143 0.9991111 0.7862405 0.9991111 0.9976111 0.9991111
#> [134] 0.6305302 0.7019325 1.0000000 0.9966278 0.9965341 0.7299984 0.9994286
#> [141] 0.9977222 0.9692476 0.9606595 0.9970563 0.9953500 0.9977222 0.9384325
#> [148] 1.0000000 0.9821175 0.9447540
