Skip to content

Instantly share code, notes, and snippets.

@evilying
Created July 7, 2018 20:06
Show Gist options
  • Save evilying/0329fb7dcdbd6b8f4699e1301b4f6bf9 to your computer and use it in GitHub Desktop.
Save evilying/0329fb7dcdbd6b8f4699e1301b4f6bf9 to your computer and use it in GitHub Desktop.

Local outlier factor

The LOF is an anomaly score that you can generate using the scikit-learn class sklearn.neighbors.LocalOutlierFactor. Similar to the aforementioned k-NN and k-means anomaly detection methods, LOF classifies anomalies using local density around a sample. The local density of a data point refers to the concentration of other points in the immediate surrounding region, where the size of this region can be defined either by a fixed distance threshold or by the closest n neighboring points. LOF measures the isolation of a single data point with respect to its closest n neighbors. Data points with a significantly lower local density than that of their closest n neighbors are considered to be anomalies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment