physioex.train.metrics#
Functions
|
Compute accuracy score. |
|
|
|
|
|
Compute F1 score. |
Cohen's kappa of a confusion matrix; NaN when it is undefined. |
|
|
Mean absolute error for regression tasks. |
|
Median of the per-recording kappas, ignoring undefined (NaN) ones. |
|
Mean squared error for regression tasks. |
|
One kappa per recording (NaN where kappa is undefined). |
|
Kappa of the confusion matrix summed over all recordings (kappa_T). |
|
Compute precision score. |
|
Coefficient of determination (R^2) for regression tasks. |
|
Compute recall score. |
|
Confusion matrix (rows = true, columns = predicted) of one recording. |
|
- physioex.train.metrics.accuracy_score(outputs, targets, ignore_index=-1, average='micro')[source]#
Compute accuracy score.
- Parameters:
outputs (Tensor) – Model outputs (logits), shape (…, n_classes).
targets (Tensor) – Ground-truth labels.
ignore_index (int) – Label value to ignore (default -1).
average (str) – Averaging method.
"micro"computes global accuracy (correct / total)."weighted"is equivalent to"micro"for accuracy and is accepted for API consistency with the other metric functions.
- Returns:
Accuracy as a float in [0, 1].
- Return type:
- physioex.train.metrics.f1_score(outputs, targets, ignore_index=-1, average='macro')[source]#
Compute F1 score.
- Parameters:
outputs (Tensor) – Model outputs (logits), shape (…, n_classes).
targets (Tensor) – Ground-truth labels.
ignore_index (int) – Label value to ignore (default -1).
average (str) –
"macro"returns unweighted mean of per-class F1 across classes with non-zero support."weighted"weights each class F1 by its support (number of true instances).
- Returns:
F1 score as a float in [0, 1].
- Return type:
- physioex.train.metrics.kappa_from_confusion(cm)[source]#
Cohen’s kappa of a confusion matrix; NaN when it is undefined.
Undefined cases: an empty matrix, or chance agreement equal to 1 (one class only in both rater marginals).
- Return type:
- physioex.train.metrics.mae_score(outputs, targets, ignore_index=-1)[source]#
Mean absolute error for regression tasks.
- physioex.train.metrics.median_record_kappa(y_true_records, y_pred_records, n_classes, ignore_index=-1)[source]#
Median of the per-recording kappas, ignoring undefined (NaN) ones.
- physioex.train.metrics.mse_score(outputs, targets, ignore_index=-1)[source]#
Mean squared error for regression tasks.
- physioex.train.metrics.per_record_kappa(y_true_records, y_pred_records, n_classes, ignore_index=-1)[source]#
One kappa per recording (NaN where kappa is undefined).
- physioex.train.metrics.pooled_kappa(y_true_records, y_pred_records, n_classes, ignore_index=-1)[source]#
Kappa of the confusion matrix summed over all recordings (kappa_T).
- physioex.train.metrics.precision_score(outputs, targets, ignore_index=-1, average='macro')[source]#
Compute precision score.
- Parameters:
outputs (Tensor) – Model outputs (logits), shape (…, n_classes).
targets (Tensor) – Ground-truth labels.
ignore_index (int) – Label value to ignore (default -1).
average (str) –
"macro"returns unweighted mean of per-class precision across classes with non-zero support."weighted"weights each class precision by its support.
- Returns:
Precision as a float in [0, 1].
- Return type:
- physioex.train.metrics.r2_score(outputs, targets, ignore_index=-1)[source]#
Coefficient of determination (R^2) for regression tasks.
- physioex.train.metrics.recall_score(outputs, targets, ignore_index=-1, average='macro')[source]#
Compute recall score.
- Parameters:
outputs (Tensor) – Model outputs (logits), shape (…, n_classes).
targets (Tensor) – Ground-truth labels.
ignore_index (int) – Label value to ignore (default -1).
average (str) –
"macro"returns unweighted mean of per-class recall across classes with non-zero support."weighted"weights each class recall by its support.
- Returns:
Recall as a float in [0, 1].
- Return type:
- physioex.train.metrics.record_confusion_matrix(y_true, y_pred, n_classes, ignore_index=-1)[source]#
Confusion matrix (rows = true, columns = predicted) of one recording.
y_trueandy_predare class indices of equal length (numpy arrays, lists or tensors). Epochs whose true label equalsignore_index(unscored or padding) are dropped.