healthcareai-r icon indicating copy to clipboard operation
healthcareai-r copied to clipboard

predict with newdata returns original outcomes but they may have been prepped

Open michaellevy opened this issue 6 years ago • 0 comments

It seems like leaving the outcome in its original form is the desired behavior, but if we want to do things with predicted classes (e.g. choosing thresholds) we likely want to know what the positive class is and that's currently post-prep form.

library(healthcareai)
m <- machine_learn(mtcars, outcome = am, tune = FALSE, models = "xgb")
pred <- predict(m, dplyr::sample_n(mtcars, 5), prepdata = TRUE)
# positive class is "Y" from prep_data
attr(pred, "model_info")$positive_class
#> [1] "Y"
# But original 0s and 1s come back from predict
pred$am
#> [1] 0 1 0 1 0

Created on 2018-07-18 by the reprex package (v0.2.0).

michaellevy avatar Jul 18 '18 21:07 michaellevy