Skip to contents

Draw stored fold scores using BoxplotConfig, with every available observation overlaid. Fold scores carry equal weight; this is a distribution of recorded scores, not a metric recomputed from pooled predictions or a confidence interval. Negative and unbounded metrics such as R-squared are not clipped to the unit interval.

Usage

draw_metric(
  data,
  metric = NULL,
  boxpoints = "all",
  horizontal = FALSE,
  xlab = if (horizontal) labelify(metric) else NULL,
  ylab = if (!horizontal) labelify(metric) else NULL,
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL,
  filename = NULL,
  ...,
  legend_position = "top",
  legend_placement = "outside"
)

Arguments

data

Data frame: Long records with character fold, split, and metric identities, and numeric value scores (finite or NA).

metric

Optional Character: Metric to select. May be omitted when the table contains one metric.

boxpoints

Character {"none", "all", "outliers"}: Values to overlay.

horizontal

Logical: Draw horizontal distributions.

xlab, ylab

Optional Character: Axis labels. The value axis derives its label from the selected metric when omitted; explicit NULL omits it.

theme

Optional Theme: Theme override. The palette inside the theme can be overridden per-chart with the color argument.

width

Optional Character or Numeric: Widget width.

height

Optional Character or Numeric: Widget height.

element_id

Optional Character: Explicit DOM element ID for the widget container. NULL lets htmlwidgets generate one.

filename

Optional Character: If provided, save the widget to this file via save_drawing().

...

Additional arguments to setup_BoxplotConfig(), such as quartiles, whisker, point_spread, palette, and title.

legend_position

Character {"top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"}: Legend anchor. Top/bottom anchors use horizontal rows; left/right anchors use a vertical column. Corner anchors align within the top or bottom row.

legend_placement

Character {"outside", "inside"}: Relation to the plotting area. Outside placement reserves space for the complete legend; inside placement overlays the data. Neither setting adds a missing legend.

Value

htmlwidget: Metric distributions with optional point overlays.

Details

Select one metric per chart. Sample and fold order follow first appearance. Absent sample/fold pairs and explicit NA scores remain missing; available values alone define each box. Entirely unavailable samples retain an empty category, and missing values are reported in the console. Entirely unavailable input is an error. See draw_boxplot() for exact quartile, whisker, and point-placement semantics.

The portable result uses one numeric column per split and one observation identifier column, bound through setup_BoxplotConfig(). No fitted object, R callback, or attribute is needed to render it in another interface.

Examples

scores <- data.frame(fold = rep(c("Fold1", "Fold2", "Fold3"), 2),
  split = rep(c("Training", "Test"), each = 3), metric = "rsq",
  value = c(.9, .85, .8, .7, .65, .6))
draw_metric(scores)