-
Notifications
You must be signed in to change notification settings - Fork 106
Avoid tibble warning. #347
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
Conversation
When converting a nameless matrix to tibble with `as_tibble()`, you need to specify `.name_repair` to avoid a warning.
|
Can you share a reprex where you produce a warning? We don't currently see warnings in our tests. |
|
Sure thing sorry should've done that from the start. suppressMessages(library(tidymodels))
iris_data <- janitor::clean_names(datasets::iris)
iris_data_split <- initial_split(iris_data)
gbm_spec <- boost_tree(trees = 10, tree_depth = 2, learn_rate = 0.1) %>%
set_engine("xgboost") %>%
set_mode("classification")
fitted_gbm <- fit(gbm_spec, species ~ ., training(iris_data_split))
predict(fitted_gbm, new_data = testing(iris_data_split), type = "prob")
#> Warning: The `x` argument of `as_tibble.matrix()` must have unique column names if `.name_repair` is omitted as of tibble 2.0.0.
#> Using compatibility `.name_repair`.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> # A tibble: 37 x 3
#> .pred_setosa .pred_versicolor .pred_virginica
#> <dbl> <dbl> <dbl>
#> 1 0.708 0.147 0.145
#> 2 0.708 0.147 0.145
#> 3 0.708 0.147 0.145
#> 4 0.708 0.147 0.145
#> 5 0.708 0.147 0.145
#> 6 0.708 0.147 0.145
#> 7 0.708 0.147 0.145
#> 8 0.708 0.147 0.145
#> 9 0.708 0.147 0.145
#> 10 0.708 0.147 0.145
#> # … with 27 more rowsCreated on 2020-07-21 by the reprex package (v0.3.0) |
|
Can you show the output of |
|
I get the warning using the above reprex with CRAN tibble 3.0.3, so I think this is a reasonable change. |
library(tidymodels)
#> ── Attaching packages ──────────────────────────────────────────────────────── tidymodels 0.1.1 ──
#> ✓ broom 0.7.0 ✓ recipes 0.1.13
#> ✓ dials 0.0.8 ✓ rsample 0.0.7
#> ✓ dplyr 1.0.0 ✓ tibble 3.0.3
#> ✓ ggplot2 3.3.2.9000 ✓ tidyr 1.1.0
#> ✓ infer 0.5.3 ✓ tune 0.1.1
#> ✓ modeldata 0.0.2 ✓ workflows 0.1.2
#> ✓ parsnip 0.1.2 ✓ yardstick 0.0.7
#> ✓ purrr 0.3.4
#> ── Conflicts ─────────────────────────────────────────────────────────── tidymodels_conflicts() ──
#> x purrr::discard() masks scales::discard()
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag() masks stats::lag()
#> x recipes::step() masks stats::step()
iris_data <- janitor::clean_names(datasets::iris)
iris_data_split <- initial_split(iris_data)
gbm_spec <- boost_tree(trees = 10, tree_depth = 2, learn_rate = 0.1) %>%
set_engine("xgboost") %>%
set_mode("classification")
fitted_gbm <- fit(gbm_spec, species ~ ., training(iris_data_split))
predict(fitted_gbm, new_data = testing(iris_data_split), type = "prob")
#> Warning: The `x` argument of `as_tibble.matrix()` must have unique column names if `.name_repair` is omitted as of tibble 2.0.0.
#> Using compatibility `.name_repair`.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> # A tibble: 37 x 3
#> .pred_setosa .pred_versicolor .pred_virginica
#> <dbl> <dbl> <dbl>
#> 1 0.707 0.148 0.145
#> 2 0.707 0.148 0.145
#> 3 0.707 0.148 0.145
#> 4 0.707 0.148 0.145
#> 5 0.707 0.148 0.145
#> 6 0.707 0.148 0.145
#> 7 0.707 0.148 0.145
#> 8 0.707 0.148 0.145
#> 9 0.707 0.148 0.145
#> 10 0.707 0.148 0.145
#> # … with 27 more rowsCreated on 2020-07-21 by the reprex package (v0.3.0) |
|
Thanks |
|
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. |
When converting a nameless matrix to tibble with
as_tibble(), you need to specify.name_repairto avoid a warning. In this case, the colnames are set on the following line, so it makes sense to do the minimum with colnames inside theas_tibblecall.