Skip to content

Clustering, density estimation, and anomaly detection · Anomaly detection · UCL060 · Algorithm

Empirical Cumulative Distribution Outlier Detection (ECOD)

Obtain fast anomaly scores from nonparametric univariate empirical tails, emphasizing extreme values and feature-level explanations without fitting a joint parametric density.

Runs in CodeSplash Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method runs this entry in Python and R. Set it up from the method's page.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Runs in CodeSplash
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through discover.ecod. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Obtain fast anomaly scores from nonparametric univariate empirical tails, emphasizing extreme values and feature-level explanations without fitting a joint parametric density.

Question / hypotheses

Which observations deviate from the chosen reference notion of normality, and at what operational alert rate? This entry defines an estimation or optimization objective, not an intrinsic null/alternative hypothesis test.

Architecture / computational structure

Left/right marginal empirical distributions plus skewness-guided surprise aggregation.

Assumptions

Marginal extremeness cannot reliably identify every unusual dependency pattern. Correlated features can duplicate evidence, and empirical tail resolution is limited by sample size.

Formula / computational definition

Form empirical left/right tail surprisals Lj=−log⁡F^j(xj)L_j=-\log\hat F_j(x_j) and Rj=−log⁡Fˉ^j(xj)R_j=-\log\hat{\bar F}_j(x_j). ECOD uses a skewness-guided combination and an extremeness selection before summing feature contributions. The precise maximum and skewness rules are part of the algorithm; a generic sum of two-sided tails is only an illustrative component.

Parameters and notation

Learned or fitted quantities: Empirical distributions, skewness statistics, and threshold. User-set hyperparameters/design choices: There are few core tuning parameters, but ties, constant features, missingness, training reference, and alert threshold need explicit policies. Tune these against the stated objective and stability/validation criteria; do not select settings on the final evaluation set.

Fitting, fine-tuning, and adaptation

Neural fine-tuning is not applicable to this classical detector. Refit the reference model when its population changes, then recalibrate an alert threshold on a separate normal holdout. Tune sensitivity without using final-test anomaly labels repeatedly.

How to use and calibrate

Inspect feature contributions and subgroup alert rates, compare with dependence-aware baselines, and test score stability under reference resampling. Treat its fast default as a baseline to validate, not a universal optimum.

Example application

Create a fast feature-explainable empirical-tail baseline. Define the reference population, measurement units, and success criterion before fitting; investigate whether discovered groups or alerts reflect the intended phenomenon.

Interpretation / pitfalls

Watch out

The reported result is conditional on the representation and objective. An alert is a screening result, not a diagnosis or a calibrated posterior probability. Evaluate both ranking and the decision threshold.

Python and R code examples

PyOD provides ECOD. R can bridge to the documented implementation or port its ECDF/skewness operations. The paired code demonstrates two-sided empirical surprise and explicitly omits the full skewness adjustment.

Component: ECOD two-sided ECDF surprise component without skewness adjustment. Python: executed successfully; R: not executed (Rscript unavailable). These small fixtures establish the arithmetic operation, not full-method accuracy or reproduction of paper results.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — ECOD two-sided ECDF surprise component without skewness adjustment. · needs numpy, scipy

import numpy as np
from scipy.stats import rankdata
X=np.array([[1.,4.],[2.,2.],[5.,1.],[3.,3.]])
L=np.column_stack([rankdata(X[:,j],method='max')/len(X) for j in range(2)])
R=np.column_stack([rankdata(-X[:,j],method='max')/len(X) for j in range(2)])
result=np.maximum(-np.log(L),-np.log(R)).sum(1)
print(result)
R

Component demo, not a trained model — ECOD two-sided ECDF surprise component without skewness adjustment.

X=rbind(c(1,4),c(2,2),c(5,1),c(3,3))
L=apply(X,2,function(x) rank(x,ties.method='max')/length(x))
R=apply(X,2,function(x) rank(-x,ties.method='max')/length(x))
result=rowSums(pmax(-log(L),-log(R)))
print(result)

Sources

From the CodeSplash reference, entry UCL060.