nirs4all.visualization.charts.top_k_comparison module
TopKComparisonChart - Scatter plots comparing predicted vs observed values for top K models.
- class nirs4all.visualization.charts.top_k_comparison.TopKComparisonChart(predictions, dataset_name_override: str | None = None, config=None, analyzer: PredictionAnalyzer | None = None)[source]
Bases:
BaseChartScatter plots comparing predicted vs observed values for top K models.
Displays predicted vs true scatter plots alongside residual plots for the best performing models according to a ranking metric.
- render(k: int = 5, rank_metric: str | None = None, rank_partition: str = 'val', display_metric: str = '', display_partition: str = 'all', show_scores: bool = True, dataset_name: str | None = None, figsize: tuple | None = None, aggregate: str | None = None, **filters) Figure[source]
Plot top K models with predicted vs true and residuals.
Uses the top() method to rank models by a metric on rank_partition, then displays predictions from display_partition(s).
- Parameters:
k – Number of top models to show (default: 5).
rank_metric – Metric for ranking models (default: auto-detect from task type).
rank_partition – Partition used for ranking (default: ‘val’).
display_metric – Metric to display in titles (default: same as rank_metric).
display_partition – Partition(s) to display (‘all’ for train/val/test, or ‘test’, ‘val’, ‘train’).
show_scores – If True, show scores in chart titles (default: True).
dataset_name – Optional dataset filter.
figsize – Figure size tuple (default: from config).
aggregate – If provided, aggregate predictions by this metadata column or ‘y’.
**filters – Additional filters.
- Returns:
matplotlib Figure object.