Skip to content

multi_predict column names #210

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

Merged
merged 3 commits into from
Sep 3, 2019
Merged

multi_predict column names #210

merged 3 commits into from
Sep 3, 2019

Conversation

topepo
Copy link
Member

@topepo topepo commented Sep 3, 2019

For some some models, the wrong column name was generated for type = "class":

library(tidymodels)
#> ── Attaching packages ───────────────────────────────────────────────────────────────────────────── tidymodels 0.0.2 ──
#> ✔ broom     0.5.2          ✔ purrr     0.3.2     
#> ✔ dials     0.0.2.9001     ✔ recipes   0.1.6.9000
#> ✔ dplyr     0.8.3          ✔ rsample   0.0.5     
#> ✔ ggplot2   3.2.1          ✔ tibble    2.1.3     
#> ✔ infer     0.4.0.1        ✔ yardstick 0.0.3.9000
#> ✔ parsnip   0.0.3.1
#> ── Conflicts ──────────────────────────────────────────────────────────────────────────────── tidymodels_conflicts() ──
#> ✖ purrr::discard()  masks scales::discard()
#> ✖ dplyr::filter()   masks stats::filter()
#> ✖ dplyr::lag()      masks stats::lag()
#> ✖ ggplot2::margin() masks dials::margin()
#> ✖ dials::offset()   masks stats::offset()
#> ✖ recipes::step()   masks stats::step()

lr_mod <- 
  logistic_reg() %>% 
  set_engine("glmnet") %>% 
  fit(Class ~ ., data = two_class_dat)

test_class <- 
  multi_predict(lr_mod, new_data = two_class_dat[, -3], penalty = 0:3)
test_class$.pred[[1]]
#> # A tibble: 4 x 2
#>   penalty .pred 
#>     <int> <fct> 
#> 1       0 Class1
#> 2       1 Class1
#> 3       2 Class1
#> 4       3 Class1

Created on 2019-09-02 by the reprex package (v0.2.1)

The new results are:

library(tidymodels)
#> ── Attaching packages ────────────────────────────────────────────────────────────────────────────── tidymodels 0.0.2 ──
#> ✔ broom     0.5.2          ✔ purrr     0.3.2     
#> ✔ dials     0.0.2.9001     ✔ recipes   0.1.6.9000
#> ✔ dplyr     0.8.3          ✔ rsample   0.0.5     
#> ✔ ggplot2   3.2.1          ✔ tibble    2.1.3     
#> ✔ infer     0.4.0.1        ✔ yardstick 0.0.3.9000
#> ✔ parsnip   0.0.3.9000
#> ── Conflicts ───────────────────────────────────────────────────────────────────────────────── tidymodels_conflicts() ──
#> ✖ purrr::discard()  masks scales::discard()
#> ✖ dplyr::filter()   masks stats::filter()
#> ✖ dplyr::lag()      masks stats::lag()
#> ✖ ggplot2::margin() masks dials::margin()
#> ✖ dials::offset()   masks stats::offset()
#> ✖ recipes::step()   masks stats::step()

lr_mod <- 
  logistic_reg() %>% 
  set_engine("glmnet") %>% 
  fit(Class ~ ., data = two_class_dat)

test_class <- 
  multi_predict(lr_mod, new_data = two_class_dat[, -3], penalty = 0:3)
test_class$.pred[[1]]
#> # A tibble: 4 x 2
#>   penalty .pred_class
#>     <int> <fct>      
#> 1       0 Class1     
#> 2       1 Class1     
#> 3       2 Class1     
#> 4       3 Class1

Created on 2019-09-02 by the reprex package (v0.2.1)

@topepo topepo merged commit ae42617 into master Sep 3, 2019
@github-actions
Copy link

github-actions bot commented Mar 8, 2021

This pull request 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 8, 2021
@hfrick hfrick deleted the multi-predict-column-names branch September 17, 2021 14:27
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 this pull request may close these issues.

1 participant