sadaco.utils package
Submodules
sadaco.utils.config_parser module
-
sadaco.utils.config_parser.parse_config_dict(yml_path: str = None, arg_type: str = 'data') → Dict[source] Take a yaml file and return the corresponding arguments.
- Parameters
arg_type (str) – The type of arguments to return. One of “data”, “frontend”, “model”, “train”. (default: “data”)
- Returns
Dict – The corresponding arguments in dictionary form.
sadaco.utils.misc module
sadaco.utils.stats module
-
class
sadaco.utils.stats.ICBHI_Metrics(num_classes: int = 4, normal_class_label: int = None, mixup: bool = False, mini_batch: bool = False, multi_label: bool = False)[source] Bases:
object-
__init__(num_classes: int = 4, normal_class_label: int = None, mixup: bool = False, mini_batch: bool = False, multi_label: bool = False) → None[source] Evaluation metrics for ICBHI challenge.
- Definitions:
Sensitivity: The ability of the classifier to identify audio with the disease correctly. Specificity: The ability of the classifier to identify audio without the disease correctly. ICBHI Score: The average of sensitivity and specificity.
- Confusion Matrix:
Task 1: Anomaly Cycle Classification
(True) C, W, B, N C Cc, Wc, Bc, Nc W Cw, Ww, Bw, Nw (y_pred) B Cb, Wb, Bb, Nb N Cn, Wn, Bn, Nn (Total-True) Ct, Wt, Bt, Nt
Task 2: Respiratory Disease Detection
(True) C, NC, H (y_pred) C Cc, NCc, Hc NC Cnc, NCnc, Hnc H Ch, NCh, Hh (Total-True) Ct, NCt, Ht
- Label:
TASK1_1 = {“Normal”: 0, “Wheezes”: 1, “Crackles”: 2, “Both”: 3} TASK1_2 = {“Normal”: 0, “Abnormal”: 1} TASK2_1 = {“Healthy”: 0, “Chronic”: 1, “NonChronic”: 2} TASK2_2 = {“Healthy”: 0, “Unhealthy”: 1}
- Equations:
Sensitivity Task1-1: (Cc + Ww + Bb) / (Ct + Wt + Bt) Sensitivity Task1-2: (Ccwb + Wcwb + Bcwb) / (Ct + Wt + Bt) Specificity Task1: Nn / Nt
Sensitivity Task2-1: (Cc + NCnc) / (Ct + NCt) Sensitivity Task2-2: (Ccnc + NCcnc) / (Ct + NCt) Specificity Task2: Hh / Ht
Score: (Sensitivity + Specificity) / 2 Accuracy: (TP + TN) / (TP + TN + FP + FN)
- Parameters
num_classes (int, optional) – Number of classes to evaluate, defaults to 4
normal_class_label (int, optional) – class label that will be considered ‘Normal’, defaults to None
mixup (bool, optional) – Indicate whether the mixup operation is applied, defaults to False
mini_batch (bool, optional) – batch to be evaluated, defaults to False
-
update_lists(logits: torch.Tensor = None, y_true: torch.Tensor = None, y_pred: torch.Tensor = None) → None[source]
-
get_stats() → Tuple[float, float, float, float][source] Compute the sensitivity, specificity, score and balanced accuracy based on ICBHI challenge definition through confusion matrix.
- Returns
acc – The accuracy. se: The sensitivity. sp: The specificity. sc: The score.
-
get_precision_recall_fbeta(average: str = 'macro', fbeta: float = 1.0) → Tuple[Union[float, numpy.array], Union[float, numpy.array], Union[float, numpy.array], numpy.array][source] Compute the precision, recall and fbeta score.
- Returns
shape = (num_classes,) precision: The precision score. recall: The recall score. f-beta: The f-beta score. support: The number of samples in each class.
-