# Two class
data("two_class_example")
ppv(two_class_example, truth, predicted)
# Multiclass
library(dplyr)
data(hpc_cv)
hpc_cv %>%
filter(Resample == "Fold01") %>%
ppv(obs, pred)
# Groups are respected
hpc_cv %>%
group_by(Resample) %>%
ppv(obs, pred)
# Weighted macro averaging
hpc_cv %>%
group_by(Resample) %>%
ppv(obs, pred, estimator = "macro_weighted")
# Vector version
ppv_vec(
two_class_example$truth,
two_class_example$predicted
)
# Making Class2 the "relevant" level
ppv_vec(
two_class_example$truth,
two_class_example$predicted,
event_level = "second"
)
# But what if we think that Class 1 only occurs 40% of the time?
ppv(two_class_example, truth, predicted, prevalence = 0.40)
Run the code above in your browser using DataLab