Clustering, density estimation, and anomaly detection · Anomaly detection · UCL059 · Algorithm
Copula-Based Outlier Detection (COPOD)
Construct an efficient tail-based anomaly ranking from empirical marginal distributions and a copula-inspired combination, avoiding expensive iterative optimization.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page.
- ECOD anomaly scores Verified in Python and R
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
Construct an efficient tail-based anomaly ranking from empirical marginal distributions and a copula-inspired combination, avoiding expensive iterative optimization.
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
Empirical marginal tails and the specified copula-inspired aggregation.
Assumptions
Empirical tails have finite resolution and depend on reference sample size. Copula-inspired scoring is not a fitted full multivariate Gaussian copula density, and the score is not an anomaly probability.
Formula / computational definition
Estimate left- and right-tail empirical probabilities for each feature. Negative log tail probabilities measure marginal surprise; the published implementation combines left, right, and skewness-guided terms to obtain a row score. A representative component is , but this alone is not the complete COPOD score.
Parameters and notation
Learned or fitted quantities: Empirical distribution reference and alert threshold. User-set hyperparameters/design choices: The core method has little model tuning, yet preprocessing, missing values, ties, and decision thresholds remain important choices. 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
Compare tail contributions, stability across reference samples, and detection of dependence-only anomalies, where marginal methods may struggle. Calibrate any binary flag on a separate operational reference set.
Example application
Rank cases using empirical tail evidence with low computational cost. 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 implements COPOD. R can bridge to it or reproduce its exact published empirical-tail combination. The paired component computes one left-tail surprise using ranked values and is labeled partial rather than silently claiming full COPOD equivalence.
Component: COPOD left-tail ECDF surprise component. 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.
Component demo, not a trained model — COPOD left-tail ECDF surprise component. · needs numpy, scipy
import numpy as np
from scipy.stats import rankdata
X=np.array([[1.,4.],[2.,2.],[5.,1.],[3.,3.]])
U=np.column_stack([rankdata(X[:,j],method='max')/len(X) for j in range(2)])
result=-np.log(U).sum(1)
print(result)
Component demo, not a trained model — COPOD left-tail ECDF surprise component.
X=rbind(c(1,4),c(2,2),c(5,1),c(3,3))
U=apply(X,2,function(x) rank(x,ties.method='max')/length(x))
result=-rowSums(log(U))
print(result)
Sources
- Source 1pyod.readthedocs.io
From the CodeSplash reference, entry UCL059.