kdpsingh / runway

Visualizing Prediction Model Performance
Other
73 stars 11 forks source link

cal_plot error #31

Open jennjh opened 10 months ago

jennjh commented 10 months ago

Hi,

I am having trouble with cal_plot function after a recent R update.

When I use the below code, I get an error, which I didn't before the R update

cal_plot(fit_preddf,
         outcome = 'fit_obs',
         prediction = 'fit_pred',
         n_bins = 5,show_loess = TRUE)
#> Error in cal_plot(fit_preddf, outcome = "fit_obs", : You must either set n_bins > 0 and show_loess to FALSE or set n_bins to 0 and show_loess to TRUE. Both cannot be displayed."

However, when I change it this, I still get an error.

cal_plot(fit_preddf,
         outcome = 'fit_obs',
         prediction = 'fit_pred',
         n_bins = 5,show_loess = FALSE)
#> Error in cal_plot(fit_preddf, outcome = "fit_obs", : argument "positive" is missing, with no default"

Created on 2023-11-08 with reprex v2.0.2

Any idea why this is happening or have any tips to generating the cal_plot? I am running R 4.3.2.

Thanks!

timdisher commented 8 months ago

I think this may just be that the documentation hasn't been updated to reflect the new "positive" argument so when you try ?cal_plot you wouldn't know it exists. You can see it's been updated on the actual code side (https://github.com/ML4LHS/runway/blob/master/R/cal_plots.R) including documentation and a new example but the actual help documentation just wasn't updated (https://github.com/ML4LHS/runway/blob/master/man/cal_plot.Rd). I ran into the same issue yesterday @kdpsingh if I'm right I think you just need to run devtools::document() on the stable version and merge back to main.

Using the example in the rendered documentation

library(runway)
data(single_model_dataset)

roc_plot(single_model_dataset, outcome = 'outcomes', prediction = 'predictions', ci = TRUE)
#> Error in roc_plot(single_model_dataset, outcome = "outcomes", prediction = "predictions", : argument "positive" is missing, with no default

Adding the positive argument which just indicates which value indicates the positive class. This is just copying the example from the latest function file.

library(runway)
data(single_model_dataset)

cal_plot(single_model_dataset, outcome = 'outcomes', positive = '1', prediction = 'predictions', n_bins = 5)
#> Warning in ggplot2::geom_point(ggplot2::aes(x = bin_pred, y = bin_prob, :
#> Ignoring unknown aesthetics: ymin and ymax
#> Warning: Removed 2 rows containing missing values (`geom_bar()`).

image