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: str | None = None, clip_outliers: bool = True, iqr_factor: float = 1.5, layout: Literal['standard', 'stacked', 'staggered'] = 'standard', **filters) 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 – If provided, aggregate predictions by this metadata column or ‘y’. When ‘y’, groups by y_true values. When a column name (e.g., ‘ID’), groups by that metadata column. Aggregated predictions have recalculated metrics.

  • 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

  • dataset_name – Optional dataset filter.

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

Returns:

matplotlib Figure object.

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.