Skip to content

Fix error message for multi_predict() #484

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 1 commit into from
May 7, 2021
Merged

Conversation

juliasilge
Copy link
Member

Closes #482

This PR fixes the error message for multi_predict() and adds a few small tests for the error message:

library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#>   method                   from   
#>   required_pkgs.model_spec parsnip
data(attrition)

data_split <- initial_split(attrition, strata = "Attrition")
attrition_train <- training(data_split)
attrition_test  <- testing(data_split)

tree_mod <-
  boost_tree(mode = "classification", trees = 100) %>% 
  set_engine("C5.0") %>% 
  fit_xy(x = attrition_train %>% dplyr::select(-Attrition), y = attrition_train$Attrition)

multi_predict(
  tree_mod, 
  new_data = attrition_test %>% dplyr::select(-Attrition),
  trees = 80:100,
  type = "prob"
)
#> # A tibble: 367 x 1
#>    .pred            
#>    <list>           
#>  1 <tibble [21 × 3]>
#>  2 <tibble [21 × 3]>
#>  3 <tibble [21 × 3]>
#>  4 <tibble [21 × 3]>
#>  5 <tibble [21 × 3]>
#>  6 <tibble [21 × 3]>
#>  7 <tibble [21 × 3]>
#>  8 <tibble [21 × 3]>
#>  9 <tibble [21 × 3]>
#> 10 <tibble [21 × 3]>
#> # … with 357 more rows

glm_mod <-
  logistic_reg(mode = "classification") %>% 
  set_engine("glm") %>% 
  fit(Attrition ~ ., data = attrition)

multi_predict(
  glm_mod, 
  new_data = attrition_test %>% dplyr::select(-Attrition),
  type = "prob"
)
#> Error: No `multi_predict` method exists for objects with classes '_glm', 'model_fit'

Created on 2021-05-06 by the reprex package (v2.0.0)

@juliasilge juliasilge requested a review from topepo May 6, 2021 20:10
Copy link
Member

@topepo topepo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@topepo topepo merged commit 01168ca into master May 7, 2021
@github-actions
Copy link

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 May 21, 2021
@juliasilge juliasilge deleted the multi-predict-error branch June 27, 2021 16:08
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.

multi_predict error message has an error
2 participants