Skip to content
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

convert expressions for levels #156

Merged
merged 4 commits into from
Sep 20, 2024
Merged

convert expressions for levels #156

merged 4 commits into from
Sep 20, 2024

Conversation

topepo
Copy link
Member

@topepo topepo commented Sep 20, 2024

Related to #145

The calibration objects store factor levels as expressions and we are seeing errors when subsetting columns or setting class levels in new factors:

library(probably)
#> 
#> Attaching package: 'probably'
#> The following objects are masked from 'package:base':
#> 
#>     as.factor, as.ordered
data(two_class_example, package = "modeldata")
w_calibration <- cal_estimate_logistic(two_class_example,
                                       truth = truth,
                                       estimate = c(Class1, Class2))

cal_apply(two_class_example, w_calibration, pred_class = Class)
#> Error in `purrr::map()`:
#> ℹ In index: 1.
#> Caused by error in `[<-.data.frame`:
#> ! anyNA() applied to non-(list or vector) of type 'symbol'

Created on 2024-09-20 with reprex v2.1.0

Copy link
Contributor

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome—this does the trick for tidymodels/tailor@probabilities-46. I'll move forward with enabling tests and sending that PR in once this is merged!

R/cal-apply-binary.R Outdated Show resolved Hide resolved
R/cal-apply-multi.R Outdated Show resolved Hide resolved
R/cal-utils.R Outdated Show resolved Hide resolved
@topepo topepo marked this pull request as ready for review September 20, 2024 17:45
@topepo topepo merged commit ab2239d into main Sep 20, 2024
10 checks passed
@topepo topepo deleted the reformat-levels branch September 20, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants