Skip to content

Use drop = FALSE for glmnet predictions on single observation #395

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
Dec 1, 2020

Conversation

juliasilge
Copy link
Member

Closes #392

This PR adds drop = FALSE for the linear, logistic, and multinomial glmnet models.

library(parsnip)

fitted_parsnip <- linear_reg(
  penalty = 0.1 # set for simiplicity
) %>%
  set_mode('regression') %>%
  set_engine('glmnet') %>%
  fit(Sepal.Length ~ Sepal.Width + Petal.Length, iris)

predict(fitted_parsnip, head(iris))
#> # A tibble: 6 x 1
#>   .pred
#>   <dbl>
#> 1  5.05
#> 2  4.95
#> 3  4.96
#> 4  5.01
#> 5  5.07
#> 6  5.24
predict(fitted_parsnip, head(iris, 1))
#> # A tibble: 1 x 1
#>   .pred
#>   <dbl>
#> 1  5.05

Created on 2020-11-17 by the reprex package (v0.3.0.9001)

@github-actions
Copy link

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.

predict for glmnet fails with single observation
2 participants