Skip to content

Instantly share code, notes, and snippets.

@simonpcouch
Last active July 21, 2022 15:42
Show Gist options
  • Save simonpcouch/b47e618fa6ebac6ed4995765169a87bb to your computer and use it in GitHub Desktop.
Save simonpcouch/b47e618fa6ebac6ed4995765169a87bb to your computer and use it in GitHub Desktop.

auditing one-to-many join warnings

With dev dplyr, we now see:

# pak::pak("tidyverse/dplyr")
library(parsnip)

mod <- 
  linear_reg(engine = 'glmnet', penalty = tune(), mixture = 1) %>%
  fit(mpg ~ ., mtcars[1:26,])

multi_predict(mod, mtcars[27:32,], type = "numeric", penalty = seq(0, 1, .2))
#> Warning: Each row in `x` should match at most 1 row in `y`.
#> ℹ Row 1 of `x` matches multiple rows.
#> ℹ If multiple matches are expected, specify `multiple = "all"` in the join call
#>   to silence this warning.
#> # A tibble: 6 × 1
#>   .pred           
#>   <list>          
#> 1 <tibble [6 × 2]>
#> 2 <tibble [6 × 2]>
#> 3 <tibble [6 × 2]>
#> 4 <tibble [6 × 2]>
#> 5 <tibble [6 × 2]>
#> 6 <tibble [6 × 2]>

Created on 2022-07-21 by the reprex package (v2.0.1)

See tidymodels/tune#526 for initial report and tidymodels/parsnip#772 for one fix.

These warnings, at least, also appear in multi_predict._lognet in parsnip, multi_predict._fishnet in poissonreg, and multi_predict._coxnet in censored.

This warning might get us in a good few places, but the multi_predict methods seem like a good place to start looking.

library(tidymodels)
lapply(parsnip:::extensions(), library, character.only = TRUE)
#> [EDIT: output truncated]


methods(multi_predict)
  • multi_predict._C5.0
  • multi_predict._coxnet
  • multi_predict._cubist
  • multi_predict._earth
  • multi_predict._elnet
  • multi_predict._fishnet
  • multi_predict._lgb.Booster
  • multi_predict._lognet
  • multi_predict._mixo_pls
  • multi_predict._mixo_plsda
  • multi_predict._mixo_spls
  • multi_predict._mixo_splsda
  • multi_predict._multnet
  • multi_predict._torch_mlp
  • multi_predict._train.kknn
  • multi_predict._xgb.Booster
  • multi_predict._xrf
  • multi_predict.default

Created on 2022-07-21 by the reprex package (v2.0.1)

@simonpcouch
Copy link
Author

PRs have been made where needed.🐙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment