Skip to content

Conversation

@rorynolan
Copy link
Contributor

When converting a nameless matrix to tibble with as_tibble(), you need to specify .name_repair to 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 the as_tibble call.

When converting a nameless matrix to tibble with `as_tibble()`, you need to specify `.name_repair` to avoid a warning.
@juliasilge
Copy link
Member

Can you share a reprex where you produce a warning? We don't currently see warnings in our tests.

@rorynolan
Copy link
Contributor Author

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 rows

Created on 2020-07-21 by the reprex package (v0.3.0)

@topepo
Copy link
Member

topepo commented Jul 21, 2020

Can you show the output of library(tidymodels) or sessionifo::session_info()?

@DavisVaughan
Copy link
Member

I get the warning using the above reprex with CRAN tibble 3.0.3, so I think this is a reasonable change.

@rorynolan
Copy link
Contributor Author

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 rows

Created on 2020-07-21 by the reprex package (v0.3.0)

@topepo topepo merged commit f333aba into tidymodels:master Jul 29, 2020
@topepo
Copy link
Member

topepo commented Jul 29, 2020

Thanks

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 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 6, 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 this pull request may close these issues.

4 participants