Skip to content

Conversation

juliasilge
Copy link
Member

Closes #480

This PR adds a new little helper function check_spec_pred_type() to create a consistent error when a user uses an unavailable type at prediction time.

library(parsnip)
data(two_class_dat, package = "modeldata")

svm_fit <- svm_linear() %>%
  set_mode("classification") %>%
  set_engine("LiblineaR") %>%
  fit(Class ~ ., data = two_class_dat)

glm_fit <- logistic_reg() %>%
  set_engine("glm") %>%
  fit(Class ~ ., data = two_class_dat)

predict(svm_fit, two_class_dat, type = "prob")
#> Error: No prob prediction method available for this model.
#> * Value for `type` should be one of: 'class', 'raw'
predict(glm_fit, two_class_dat, type = "quantile")
#> Error: No quantile prediction method available for this model.
#> * Value for `type` should be one of: 'class', 'prob', 'raw', 'conf_int'

Created on 2021-05-12 by the reprex package (v2.0.0)

This PR also removes the unneeded class probability prediction module for the LiblineaR svm_linear() which only was there to error.

@topepo topepo merged commit f364b81 into master May 13, 2021
@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 May 28, 2021
@juliasilge juliasilge deleted the pred-type-error branch June 27, 2021 16:08
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.

Uninformative error for predict() when default type isn't available
2 participants