milia.anomaly.models.ecod#
ECOD: empirical-CDF tail probabilities, summed over dimensions.
Functions
|
Left and right empirical tail probabilities of new rows under the training columns. |
Classes
|
Parameter-free detector from per-dimension empirical CDFs (Li et al., 2023, IEEE TKDE). |
|
Validated hyperparameters of the ECOD detector. |
- milia.anomaly.models.ecod.tails(train, X)#
Left and right empirical tail probabilities of new rows under the training columns.
- Parameters:
- Return type:
- Returns:
(left, right)arrays of the shape ofX, clipped below at1 / (n + 1)so an extreme point never takeslog(0).
Examples
>>> left, right = tails(np.array([[1.0], [2.0], [3.0], [4.0]]), np.array([[2.0]])) >>> float(left[0, 0]), float(right[0, 0]) (0.5, 0.5)
- class milia.anomaly.models.ecod.ECOD(contamination=0.1)#
Bases:
BaseDetectorParameter-free detector from per-dimension empirical CDFs (Li et al., 2023, IEEE TKDE).
Per dimension, the smaller of the left and right tail probabilities is kept, and its negative logarithm is summed across dimensions. Implemented from the paper rather than through pyod.
- Parameters:
contamination (
float) – Expected share of outliers, used for the default threshold.
Examples
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> train, cal = rng.normal(size=(200, 2)), rng.normal(size=(100, 2)) >>> model = ECOD().fit(train).calibrate(cal, alpha=0.1) >>> model.flag(np.array([[0.0, 0.0], [8.0, 8.0]])).tolist() [False, True]
- class milia.anomaly.models.ecod.ECODConfig(*, name='ecod', kind='detector', space=None, contamination=0.1)#
Bases:
BaseModelConfigValidated hyperparameters of the ECOD detector.
Fields mirror
ECOD’s constructor;spaceis the default Optuna search space. Build the detector withmake("detector", "ecod", ...)orECOD(**config.params()).Examples
>>> ECODConfig().name 'ecod'