hoops_ai.storage.metric_storage
Classes
|
Abstract class defining the interface for storing machine learning metrics based on their type of data and visualization. |
- class hoops_ai.storage.metric_storage.MetricStorage(store)
Bases:
objectAbstract class defining the interface for storing machine learning metrics based on their type of data and visualization.
- Parameters:
store (DataStorage)
- get_storage()
Returns the storage handler for this metric storage.
- Returns:
The storage handler instance.
- list_data_ids(name)
Returns all data_ids pushed under ‘name’ by examining the Zarr store keys.
- pull_category_metric(name, epoch)
Pulls category-based metric data for a specific epoch from storage.
- Parameters:
- Returns:
A tuple containing a list of categories and the corresponding metric values.
- Raises:
ValueError – If the specified epoch is not found.
- Return type:
- pull_data(name, data_id)
Loads prediction data from storage.
- Parameters:
- Returns:
A NumPy array containing the prediction results.
- Return type:
- pull_matrix_metric(name, epoch)
Pulls a matrix-based metric for a specific epoch from storage.
- Parameters:
- Returns:
A 2D NumPy array representing the matrix metric.
- Raises:
ValueError – If the specified epoch is not found.
- Return type:
- pull_trend_metric(name)
Pulls trend metric data from storage.
- push_category_metric(name, epoch, categories, values)
Pushes category-based metrics incrementally in memory before writing them to storage.
Reason: Compares performance across different categories (e.g., classes, features) for each epoch.
Metrics Included: - Per-Class Accuracy (one bar per class) - Per-Class IoU (one bar per class) - Feature Importance (e.g., in random forests, SHAP values)
- push_matrix_metric(name, epoch, matrix)
Pushes matrix-based metrics incrementally in memory before writing them to storage.
Reason: Stores structured relationships between multiple variables in matrix form, per epoch.
Metrics Included: - Confusion Matrix (classification tasks) - Correlation Matrix (e.g., feature correlations)
- Parameters:
name (str) – The metric name (e.g., “confusion_matrix”, “feature_correlation”).
epoch (int) – The current epoch index.
matrix (numpy.ndarray) – A 2D NumPy array representing the metric (e.g., confusion matrix).
- push_predictions(name, data_id, result)
Saves prediction data to storage.
- Parameters:
name (str) – The name of the prediction metric.
data_id (int) – The identifier for the data.
result (numpy.ndarray) – A NumPy array containing the prediction results.
- push_trend_metric(name, epoch, value)
Pushes trend metrics incrementally in memory before writing to a file.
Reason: Tracks values over time (epochs) to analyze learning progress.
Metrics Included: - Loss (training, validation, test) - Accuracy over epochs - Precision/Recall over epochs - F1-score over epochs - IoU (mean IoU, per-class IoU over time) - RMSE/MSE/MAE for regression tasks over epochs - Learning Rate schedules