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.
results: data.frame with a metric column to create density plot for.
To only plot the baseline, set to NULL.
baseline: data.frame with the random evaluations from baseline(). Should contain a column for the metric.
To only plot the results, set to NULL.
metric: Name of the metric column in results to plot. (Character)
fill: Colors of the plotted distributions. The first color is for the baseline, the second for the results.
alpha: Transparency of the distribution (0 - 1).
theme_fn: The ggplot2 theme function to apply.
xlim: Limits for the x-axis. Can be set to NULL.
E.g. c(0, 1).
Returns
A ggplot2 object with the density of a metric, possibly split in Results and Baseline.
Examples
# Attach packageslibrary(cvms)library(dplyr)# We will use the musicians and predicted.musicians datasetsmusicians
predicted.musicians
# Set seedset.seed(42)# Create baseline for targetsbsl <- baseline_multinomial( test_data = musicians, dependent_col ="Class", n =20# Normally 100)# Evaluate predictions grouped by classifier and fold columneval <- 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 metricplot_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
See Also
Other plotting functions: font(), plot_confusion_matrix(), plot_probabilities(), plot_probabilities_ecdf(), sum_tile_settings()