View source: R/plot_metric_density.R
plot_metric_density | R Documentation |
Creates a ggplot2
object with a density plot
for one of the columns in the passed data.frame
(s).
Note: In its current form, it is mainly intended as a quick way to visualize the results from cross-validations and baselines (random evaluations). It may change significantly in future versions.
plot_metric_density(
results = NULL,
baseline = NULL,
metric = "",
fill = c("darkblue", "lightblue"),
alpha = 0.6,
theme_fn = ggplot2::theme_minimal,
xlim = NULL
)
results |
To only plot the baseline, set to |
baseline |
To only plot the results, set to |
metric |
Name of the metric column in |
fill |
Colors of the plotted distributions.
The first color is for the |
alpha |
Transparency of the distribution ( |
theme_fn |
The |
xlim |
Limits for the x-axis. Can be set to E.g. |
A ggplot2
object with the density of a metric, possibly split
in 'Results' and 'Baseline'.
Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk
Other plotting functions:
font()
,
plot_confusion_matrix()
,
plot_probabilities()
,
plot_probabilities_ecdf()
,
sum_tile_settings()
# Attach packages
library(cvms)
library(dplyr)
# We will use the musicians and predicted.musicians datasets
musicians
predicted.musicians
# Set seed
set.seed(42)
# Create baseline for targets
bsl <- baseline_multinomial(
test_data = musicians,
dependent_col = "Class",
n = 20 # Normally 100
)
# Evaluate predictions grouped by classifier and fold column
eval <- predicted.musicians %>%
dplyr::group_by(Classifier, `Fold Column`) %>%
evaluate(
target_col = "Target",
prediction_cols = c("A", "B", "C", "D"),
type = "multinomial"
)
# Plot density of the Overall Accuracy metric
plot_metric_density(
results = eval,
baseline = bsl$random_evaluations,
metric = "Overall Accuracy",
xlim = c(0,1)
)
# The bulk of classifier results are much better than
# the baseline results
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.