View source: R/pretty_roc_curve.R
pretty_roc_curve | R Documentation |
This function plots a pretty ROC (receiver-operator curve) using the values from the ['tibble::tibble()] that can be generated with the package function [get_threshold_data()]. G-mean as the unbiased evaluation metric for imbalanced classification is calculated from [sqrt(Recall*Specificity)]. This function colors the curve according to the value of the threshold.
pretty_roc_curve(
df,
plot_title = "Receiver-operator curve",
x_col = "fpr",
y_col = "tpr",
col_col = "threshold",
auc_col = "roc_auc_tr",
colors = c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#FF7F00",
"red", "#7F0000"),
annotate = NULL
)
df |
- The tibble that can be generated with the package function [get_threshold_data()] |
plot_title |
- A title for your plot |
x_col |
- The column name of the values 2B plotted on the x-axis. Default = "fpr". |
y_col |
- The column name of the values 2B plotted on the x-axis. Default = "tpr". |
col_col |
- The column name of the values for coloring the points. Default = "threshold". |
auc_col |
- The column name of the values that contain the AUC. Default = "roc-auc". Set to 'NA' if you do not want to show the AUC line |
colors |
- A vector of colors from which a gradient will be generated. An empty list will produce a single black line instead of a colored one. Default: c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000") |
annotate |
A threshold between 0 and 1 (digits = 2) that should be annotated at the curve. You may select one of the thresholds that you can get using the package function [select_threshold]. |
The plot as ggplot2.
y_true <- sample(c(0,1), replace = TRUE, size = 1000)
y_predicted <- runif(1000)
data <- get_threshold_data(truth = y_true, prediction = y_predicted)
roc <- pretty_roc_curve(df = data,
plot_title = "ROC curve")
show(roc$plot)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.