View source: R/pretty_pr_curve.R
pretty_pr_curve | R Documentation |
This function plots a pretty PR (precision-recall curve) using the values from the [tidyverse::tibble()] that can be generated with the package function [get_threshold_data()]. It colors the curve according to the value of the threshold.
pretty_pr_curve(
df,
plot_title = "Precision-recall curve",
x_col = "Recall",
y_col = "Precision",
col_col = "threshold",
f1_col = "F1",
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 = "Recall". |
y_col |
- The column name of the values 2B plotted on the x-axis. Default = "Precision". |
col_col |
- The column name of the values for coloring the points. Default = "threshold". |
colors |
- A vector of colors from which a gradient will be generated. 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]. |
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 |
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)
pr <- pretty_pr_curve(df = data,
plot_title = "Precision-recall curve")
show(pr$plot)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.