Skip to content

nexuml_library.evaluation.anomalous_sound_detection.decision

nexuml_library.evaluation.anomalous_sound_detection.decision

Decision rules: fit thresholds from train scores, emit binary decisions.

DecisionRule

Bases: Module

Abstract decision rule.

Lifecycle
  1. fit(train_scores) — fit threshold from normal train scores
  2. forward(scores) -> decisions — apply threshold to produce binary decisions

fit

fit(train_scores: Tensor) -> None

Fit the decision threshold from train-only scores.

forward

forward(scores: Tensor) -> torch.Tensor

Return 1 (anomalous) / 0 (normal) binary decisions.

DecisionRuleSpec

Bases: FactorySpec

Portable constructor configuration for a decision rule.

QuantileThresholdRule

Bases: DecisionRule

Threshold at a given quantile of the train score distribution.

quantile in [0, 1]; e.g. 0.95 means the top-5% of train scores.

PercentileThresholdRule

Bases: DecisionRule

Threshold at a given percentile of the train score distribution.

percentile in [0, 100]; equivalent to QuantileThresholdRule with quantile = percentile / 100.

GammaPercentileRule

Bases: DecisionRule

Gamma-fit threshold at a given percentile of train scores.

decision_rule

decision_rule(
    factory: Callable[P, DecisionRule],
    *args: args,
    **kwargs: kwargs,
) -> DecisionRuleSpec

Configure an importable decision-rule factory.

Returns:

Type Description
DecisionRuleSpec

Portable decision-rule specification.