nirs4all.visualization.chart_utils.predictions_adapter module
PredictionsAdapter - Adapter for Predictions API with optimized data access.
Wraps the refactored Predictions API to provide convenient methods for charts.
- class nirs4all.visualization.chart_utils.predictions_adapter.PredictionsAdapter(predictions)[source]
Bases:
objectAdapter for Predictions API with optimized data access.
Wraps the refactored Predictions API to provide convenient methods for charts. Leverages predictions.top(), lazy loading, and structured results.
Key Optimizations: - Uses predictions.top() for efficient ranking - Supports lazy loading (load_arrays=False) for metadata-only queries - Works with PredictionResult/PredictionResultsList classes - Avoids redundant metric calculations
- predictions
Predictions object instance.
- extract_metric_values(predictions_list: PredictionResultsList, metric: str, partition: str = 'test') List[float][source]
Extract metric values from prediction results.
- Parameters:
predictions_list – List of prediction results.
metric – Metric name to extract.
partition – Partition to extract from (default: ‘test’).
- Returns:
List of metric values.
- get_all_predictions_metadata(rank_metric: str = 'rmse', rank_partition: str = 'test', **filters) PredictionResultsList[source]
Get all predictions matching filters (metadata only, fast).
- Parameters:
rank_metric – Metric for sorting (default: ‘rmse’).
rank_partition – Partition for sorting (default: ‘test’).
**filters – Filters to apply (dataset_name, model_name, etc.).
- Returns:
PredictionResultsList with all matching predictions (no arrays loaded).
- get_top_models(n: int, rank_metric: str, rank_partition: str = 'val', ascending: bool | None = None, load_arrays: bool = True, **filters) PredictionResultsList[source]
Get top N models using predictions.top() API.
- Parameters:
n – Number of top models to retrieve.
rank_metric – Metric to rank by.
rank_partition – Partition to rank on (default: ‘val’).
ascending – Sort order (None = auto-detect from metric).
load_arrays – Whether to load prediction arrays (default: True).
**filters – Additional filters (dataset_name, model_name, etc.).
- Returns:
PredictionResultsList of top N models.