if (requireNamespace('data.table', quietly = TRUE)) {
# don't multi-thread during CRAN checks
data.table::setDTthreads(1)
}
# data with two different regimes of behavior
d <- rbind(
data.frame(
x = rnorm(1000),
y = sample(c(TRUE, FALSE), prob = c(0.02, 0.98), size = 1000, replace = TRUE)),
data.frame(
x = rnorm(200) + 5,
y = sample(c(TRUE, FALSE), size = 200, replace = TRUE))
)
# Sensitivity/Specificity examples
ThresholdPlot(d, 'x', 'y',
title = 'Sensitivity/Specificity',
metrics = c('sensitivity', 'specificity'),
truth_target = TRUE)
if(FALSE) {
MetricPairPlot(d, 'x', 'y',
x_metric = 'false_positive_rate',
y_metric = 'true_positive_rate',
truth_target = TRUE,
title = 'ROC equivalent')
ROCPlot(d, 'x', 'y',
truthTarget = TRUE,
title = 'ROC example')
# Precision/Recall examples
ThresholdPlot(d, 'x', 'y',
title = 'precision/recall',
metrics = c('recall', 'precision'),
truth_target = TRUE)
MetricPairPlot(d, 'x', 'y',
x_metric = 'recall',
y_metric = 'precision',
title = 'recall/precision',
truth_target = TRUE)
PRPlot(d, 'x', 'y',
truthTarget = TRUE,
title = 'p/r plot')
}
Run the code above in your browser using DataLab