sadaco.utils package

Submodules

sadaco.utils.config_parser module

sadaco.utils.config_parser.join(loader, node)[source]
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.config_parser.parse_config_obj(yml_path: str = None)[source]
class sadaco.utils.config_parser.ArgsParser(argv=None)[source]

Bases: object

add_argument(*opts, **kwopts)[source]
get_args()[source]

sadaco.utils.misc module

sadaco.utils.misc.seed_everything(seed: int) → None[source]

Seed everything for reproducibility.

`os`
`random`
`numpy`
`torch`
sadaco.utils.misc.min_max_scale(samples, min, max)[source]

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

binary2int(tensor)[source]
int2onehot(tensor)[source]
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_mixup_stats() → float[source]
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.

reset_metrics() → None[source]
sadaco.utils.stats.print_stats(stats: Union[Tuple, DefaultDict], names: Tuple = None)[source]

sadaco.utils.web_utils module

sadaco.utils.web_utils.get_configs()[source]
sadaco.utils.web_utils.load_config(name)[source]

Module contents