MultiLabelClassificationOutput¶
- class torch_ecg.components.MultiLabelClassificationOutput(*args: Any, **kwargs: Any)[source]¶
Bases:
BaseOutput
Class that maintains the output of a multi-label classification task.
- Parameters:
classes (Sequence[str]) – class names
thr (float) – threshold for making binary predictions
prob (numpy.ndarray) – Probabilities of each class, of shape
(batch_size, num_classes)
pred (numpy.ndarray) – Binary predictions, of shape
(batch_size, num_classes)
.
Note
Known issues:
fields of type dict are not well supported due to the limitations of the base class CFG, for example
>>> output = MultiLabelClassificationOutput(classes=["AF", "N", "SPB"], thr=0.5, pred=np.ones((1,3)), prob=np.ones((1,3)), d={"d":1}) >>> output {'classes': ['AF', 'N', 'SPB'], 'prob': array([[1., 1., 1.]]), 'pred': array([[1., 1., 1.]]), 'thr': 0.5, 'd': {'d': 1}} >>> output.d # has to access via `output["d"]` AttributeError: 'MultiLabelClassificationOutput' object has no attribute 'd'
- compute_metrics(macro: bool = True) ClassificationMetrics [source]¶
Compute metrics from the output.
- Parameters:
macro (bool) – Whether to use macro-averaged metrics or not.
- Returns:
metrics – Metrics computed from the output.
- Return type: