COPOD is a parameter-free, distribution-free outlier detector that models feature marginals with empirical cumulative distribution functions, combines them into an empirical copula, and scores records by tail probability. It avoids distance calculations, scales to many features, adjusts probabilities for dimensionality and skew, and provides record-level explanations. section 6.4
COPOD follows three main steps:
- Computes an empirical cumulative distribution function for each feature. section 6.4
- Builds an empirical copula that represents the training data's joint distribution while retaining marginal distributions. section 6.4
- Estimates how likely each record is to contain an unusually extreme combination of low or high values, then uses tail probability as the outlier signal. section 6.4
Synthetic two-feature example
Fit COPOD to 1,000 normally distributed observations in two columns after setting the final row's first feature to 15. Calling explain_outlier(999) identifies the extreme first feature while distinguishing the ordinary second feature. section 6.4
Listing 6.8 Example of COPOD with synthetic data
import pandas as pd
import numpy as np
from pyod.models.copod import COPOD
np.random.seed(42)
a_data = np.random.normal(loc=10, scale=1.0, size=1000)
b_data = np.random.normal(loc=10, scale=1.0, size=1000)
df = pd.DataFrame({“A”: a_data, “B”: b_data})
df.loc[999, 'A'] = 15
clf = COPOD()
clf.fit(df)
clf.explain_outlier(999)
Use the compact PyOD listing to inspect fitting and record-level explanation on synthetic data. section 6.4
