nirs4all.visualization.charts.histogram module

ScoreHistogramChart - Histogram of score distributions.

class nirs4all.visualization.charts.histogram.ScoreHistogramChart(predictions, dataset_name_override: str | None = None, config=None, analyzer: PredictionAnalyzer | None = None)[source]

Bases: BaseChart

Histogram of score distributions.

Displays distribution of a metric across predictions with statistical annotations.

render(display_metric: str | None = None, display_partition: str = 'test', dataset_name: str | None = None, bins: int = 20, figsize: tuple | None = None, aggregate: bool | str | None = None, aggregate_method: str | None = None, aggregate_exclude_outliers: bool | None = None, clip_outliers: bool = True, iqr_factor: float = 1.5, layout: Literal['standard', 'stacked', 'staggered'] = 'standard', task_type: str | None = None, score_scope: str = 'refit', **filters) → Figure | list[Figure][source]

Render score distribution histogram (Optimized with Polars).

Parameters:
  • display_metric – Metric to plot (default: auto-detect from task type).

  • display_partition – Partition to display scores from (default: ‘test’).

  • bins – Number of histogram bins (default: 20).

  • figsize – Figure size tuple (default: from config).

  • aggregate – Aggregation mode for the chart.

  • aggregate_method – Aggregation method ("mean", "median", or "vote").

  • aggregate_exclude_outliers – Whether grouped aggregation excludes outliers before reducing each group.

  • clip_outliers – If True, constrain the x-axis to show the main distribution and let extreme outliers go off-frame (default: True).

  • iqr_factor – Factor to multiply IQR for determining outlier bounds. Higher values show more of the tails (default: 1.5).

  • layout – Histogram layout style: - ‘standard’: overlapping histograms (default) - ‘stacked’: bars stacked on top of each other - ‘staggered’: bars placed side by side

  • task_type – If provided, filter predictions to this task type. When None and mixed task types exist, renders separate figures per task type.

  • dataset_name – Optional dataset filter.

  • **filters – Additional filters (model_name, config_name, etc.).

Returns:

matplotlib Figure object, or a list of Figures when auto-separating by task type.

validate_inputs(display_metric: str | None, **kwargs) → None[source]

Validate histogram inputs.

Parameters:
  • display_metric – Metric name to plot.

  • **kwargs – Additional parameters (ignored).

Raises:

ValueError – If display_metric is invalid.