Skip to contents

nnet::multinom Multinomial Learner

Usage

lnr_multinomial_nnet(data, formula, weights = NULL, ...)

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_nnet(df, cyl ~ hp + mpg)(df)
#>  [1] 1.0000000 1.0000000 1.0000000 0.9996982 1.0000000 1.0000000 1.0000000
#>  [8] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [15] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [22] 1.0000000 1.0000000 1.0000000 0.9998992 1.0000000 1.0000000 1.0000000
#> [29] 1.0000000 0.9999127 1.0000000 0.9997039
lnr_multinomial_nnet(iris, Species ~ .)(iris)
#>   [1] 1.0000000 0.9999996 1.0000000 0.9999968 1.0000000 1.0000000 1.0000000
#>   [8] 1.0000000 0.9999871 0.9999992 1.0000000 0.9999997 0.9999992 0.9999998
#>  [15] 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 0.9999999
#>  [22] 1.0000000 1.0000000 0.9999998 0.9999768 0.9999965 0.9999999 1.0000000
#>  [29] 1.0000000 0.9999968 0.9999956 1.0000000 1.0000000 1.0000000 0.9999994
#>  [36] 1.0000000 1.0000000 1.0000000 0.9999987 1.0000000 1.0000000 0.9997542
#>  [43] 0.9999998 1.0000000 0.9999999 0.9999996 1.0000000 0.9999997 1.0000000
#>  [50] 1.0000000 0.9999877 0.9999501 0.9987828 0.9999567 0.9985711 0.9998954
#>  [57] 0.9986727 0.9999997 0.9999850 0.9999848 1.0000000 0.9999615 0.9999999
#>  [64] 0.9991850 0.9999600 0.9999957 0.9986481 1.0000000 0.9401019 0.9999999
#>  [71] 0.5945365 0.9999988 0.7743208 0.9999586 0.9999984 0.9999924 0.9992755
#>  [78] 0.7236305 0.9990177 0.9999917 0.9999999 1.0000000 0.9999997 0.1323524
#>  [85] 0.9977885 0.9997823 0.9996965 0.9997399 0.9999991 0.9999886 0.9999591
#>  [92] 0.9998366 0.9999995 0.9999998 0.9999845 0.9999997 0.9999968 0.9999976
#>  [99] 0.9997776 0.9999976 1.0000000 0.9996078 0.9999990 0.9997148 0.9999999
#> [106] 1.0000000 0.8908074 0.9999954 0.9999919 1.0000000 0.9901387 0.9997381
#> [113] 0.9999794 0.9999665 0.9999999 0.9999950 0.9976741 0.9999999 1.0000000
#> [120] 0.9203566 0.9999996 0.9995049 1.0000000 0.9480610 0.9999819 0.9995521
#> [127] 0.8239052 0.8019269 0.9999992 0.9710712 0.9999968 0.9999172 0.9999999
#> [134] 0.2060534 0.9664645 1.0000000 0.9999999 0.9964650 0.6689415 0.9998686
#> [141] 0.9999999 0.9999423 0.9996078 1.0000000 1.0000000 0.9999929 0.9990906
#> [148] 0.9989764 0.9999955 0.9775646