Skip to content

Fix augment bug 🐛 related to bind_cols() #510

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Jun 8, 2021
Merged

Conversation

juliasilge
Copy link
Member

Closes #506

This PR fixes the bug in augment() related to how predictions were being bound on, then fed back into predict(). Should be all working now:

library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#>   method                   from   
#>   required_pkgs.model_spec parsnip
data(two_class_dat, package = "modeldata")

two_class_df <- two_class_dat %>% mutate(id = row_number())

rec <- recipe(Class ~ ., data = two_class_df) %>%
  update_role(id, new_role = "id")

tree_spec <- boost_tree() %>%
  set_mode("classification") %>%
  set_engine("xgboost") 

tree_fit <- workflow() %>%
  add_model(tree_spec) %>%
  add_recipe(rec) %>%
  fit(data = two_class_df)
#> [10:21:15] WARNING: amalgamation/../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.

augment(tree_fit, two_class_df[22,])
#> # A tibble: 1 x 7
#>       A     B Class     id .pred_class .pred_Class1 .pred_Class2
#>   <dbl> <dbl> <fct>  <int> <fct>              <dbl>        <dbl>
#> 1  1.56  1.10 Class2    22 Class1             0.793        0.207

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

@juliasilge juliasilge requested a review from hfrick June 7, 2021 17:38
Copy link
Member

@hfrick hfrick left a comment

Choose a reason for hiding this comment

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

lgtm! should this also be mentioned in the NEWS file?

@juliasilge juliasilge merged commit 0d0dd4c into master Jun 8, 2021
@juliasilge juliasilge deleted the fix-augment-bug branch June 8, 2021 15:28
@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 Jun 23, 2021
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Augment fails in 0.1.6 with a character ID column
2 participants