Clustering, density estimation, and anomaly detection · Anomaly detection · UCL054 · Algorithm
Cluster-Based Local Outlier Factor (CBLOF)
Score cases using cluster size and distance to large, presumed normal clusters. It offers a scalable way to detect small remote groups and points far from their own substantial cluster.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page.
- Cluster-based local outlier factor (CBLOF) 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.cblof. 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
Score cases using cluster size and distance to large, presumed normal clusters. It offers a scalable way to detect small remote groups and points far from their own substantial cluster.
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
An initial clusterer, large/small cluster categorization, and center-distance scoring.
Assumptions
The method assumes small or remote clusters deserve scrutiny, which can wrongly flag legitimate minorities. A poor initial partition propagates directly into anomaly scores.
Formula / computational definition
In a common unweighted form, a point in a large cluster receives distance to its own center; a point in a small cluster receives minimum distance to a large-cluster center. The original family may multiply distances by cluster size. The weighting convention materially changes rankings.
Parameters and notation
Learned or fitted quantities: Cluster model, size categories, and alert threshold. User-set hyperparameters/design choices: Specify the clustering estimator, cluster count, rules separating large and small clusters, distance, and optional size weighting. 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
Audit both cluster-level and point-level anomalies, compare weighted and unweighted definitions, and inspect rare legitimate populations. Report the initial clusterer's stability alongside detector performance.
Example application
Screen small remote activity clusters for investigation. 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 CBLOF and documents its weighting options. R can implement scoring after a native clusterer or bridge to Python. The component demo uses explicitly designated large centers and demonstrates the small-cluster branch only.
Component: Unweighted CBLOF small-cluster scoring branch. 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 — Unweighted CBLOF small-cluster scoring branch. · needs numpy
import numpy as np
small_points=np.array([[3.,0.],[5.,1.]]); large_centers=np.array([[0.,0.],[8.,0.]])
result=np.sqrt(((small_points[:,None]-large_centers)**2).sum(2)).min(1)
print(result)
Component demo, not a trained model — Unweighted CBLOF small-cluster scoring branch.
small_points=rbind(c(3,0),c(5,1)); large_centers=rbind(c(0,0),c(8,0))
D=sapply(1:2,function(k) sqrt(rowSums(sweep(small_points,2,large_centers[k,])^2)))
result=apply(D,1,min)
print(result)
Sources
- Source 1pyod.readthedocs.io
From the CodeSplash reference, entry UCL054.