A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/tidymodels/parsnip/issues/107 below:

predict() on a multinomial regression with glmnet double names the output with `.pred_` · Issue #107 · tidymodels/parsnip · GitHub

i.e.

library(parsnip)
data("lending_club")

multi_reg <- multinom_reg(penalty = 0.01)
multi_reg_glmnet <- multi_reg %>% set_engine("glmnet")
multi_reg_fit <- fit(multi_reg_glmnet, verification_status ~ annual_inc + sub_grade, data = lending_club)

multi_reg_fit %>%
    predict(new_data = lending_club, type = "prob")
#> # A tibble: 9,857 x 3
#>    .pred_.pred_Not_Verified .pred_.pred_Source_Verified .pred_.pred_Verifi…
#>                       <dbl>                       <dbl>               <dbl>
#>  1                    0.312                       0.389               0.298
#>  2                    0.365                       0.369               0.266
#>  3                    0.341                       0.383               0.277
#>  4                    0.297                       0.416               0.287
#>  5                    0.387                       0.377               0.236
#>  6                    0.305                       0.387               0.308
#>  7                    0.366                       0.366               0.268
#>  8                    0.409                       0.397               0.194
#>  9                    0.365                       0.380               0.255
#> 10                    0.370                       0.360               0.270
#> # … with 9,847 more rows

This is simply due to this line:

https://github.com/tidymodels/parsnip/blob/master/R/multinom_reg_data.R#L47

We don't need to add .pred_ to the names here, as it is done once in the formatting step at the end.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4