Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

predict() on a multinomial regression with glmnet double names the output with .pred_ #107

Closed
Tracked by #8
DavisVaughan opened this issue Nov 18, 2018 · 1 comment · Fixed by #113
Closed
Tracked by #8

Comments

@DavisVaughan
Copy link
Member

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.

@github-actions
Copy link

github-actions bot commented Mar 9, 2021

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant