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: bool | str | None = None, aggregate_method: str | None = None, aggregate_exclude_outliers: bool | None = None, score_scope: str = 'cv', task_type: str | None = None, **filters) Figure | list[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’).
score_scope – Defaults to
"cv"for fold ranking. Explicit"refit"uses the artifact’s saved selection metric.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 – 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.
task_type – If provided, filter predictions to this task type. When None and mixed task types exist, renders separate figures per task type.
**filters – Additional filters.
- Returns:
matplotlib Figure object, or a list of Figures when auto-separating by task type.