pretty_roc_curve: Plot pretty ROC curve

View source: R/pretty_roc_curve.R

pretty_roc_curveR Documentation

Plot pretty ROC curve

Description

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.

Usage

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
)

Arguments

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].

Value

The plot as ggplot2.

Examples

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)


mai00fti/prettyPROC documentation built on Aug. 16, 2024, 4:48 p.m.