Clustering, density estimation, and anomaly detection · Anomaly detection · UCL065 · Algorithm
Local Correlation Integral (LOCI)
Detect local density deficits over multiple spatial scales, reducing dependence on one chosen neighborhood size. It can expose both isolated points and small anomalous groups relative to surrounding structure.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page.
- Nearest-neighbor outlier 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.knn_outlier. 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
Detect local density deficits over multiple spatial scales, reducing dependence on one chosen neighborhood size. It can expose both isolated points and small anomalous groups relative to surrounding structure.
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
Multi-radius neighborhood counting and standardized density-deficit comparison.
Assumptions
Multiple-scale search is computationally demanding. A fixed deviation rule is not automatically a globally controlled hypothesis test across all points and radii. Sparse data or duplicate counts can create unstable denominators.
Formula / computational definition
At radius , count neighbors inside a smaller radius around point and comparable surrounding points. The multigranularity deviation factor is , where is a neighborhood-average count. Compare it with a locally estimated standardized deviation over relevant radii.
Parameters and notation
Learned or fitted quantities: Neighborhood count profiles and scale-specific deviations. User-set hyperparameters/design choices: Choose scale fraction , deviation multiplier, metric, and candidate radii or approximation strategy. 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 which scales trigger alerts, count profiles, ranking stability, and false-alarm behavior under a suitable reference process. Explain whether a flagged case is isolated or belongs to a small sparse group.
Example application
Detect a sparse subpopulation that appears anomalous only at certain scales. 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 LOCI. R can bridge to Python or implement the full multi-radius counting algorithm. The paired component calculates MDEF from supplied counts and flags a specified standardized threshold; it does not perform the full scale search.
Component: LOCI MDEF at a supplied scale. 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 — LOCI MDEF at a supplied scale. · needs numpy
import numpy as np
local_count=np.array([2.,8.]); mean_count=np.array([10.,10.]); sd_mdef=np.array([.1,.1])
mdef=1-local_count/mean_count; result=np.c_[mdef,mdef>3*sd_mdef]
print(result)
Component demo, not a trained model — LOCI MDEF at a supplied scale.
local_count=c(2,8); mean_count=c(10,10); sd_mdef=c(.1,.1)
mdef=1-local_count/mean_count; result=cbind(mdef,flag=mdef>3*sd_mdef)
print(result)
Sources
- Source 1pyod.readthedocs.io
From the CodeSplash reference, entry UCL065.