Skip to content

Xenia101/Local-Outlier-Factor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

Local-Outlier-Factor (LOF)

Deriving the Local Outlier Factor Scores

LOF 란?

In anomaly detection, the local outlier factor (LOF) is an algorithm proposed by Markus M. Breunig, Hans-Peter Kriegel, Raymond T. Ng and Jörg Sander in 2000 for finding anomalous data points by measuring the local deviation of a given data point with respect to its neighbours. WIKIPEDIA

Example

from sklearn.neighbors import LocalOutlierFactor
import numpy as np

clf = LocalOutlierFactor(n_neighbors=3, contamination=0.1)
clf.fit_predict(load_data())
X_scores = clf.negative_outlier_factor_

X_scores  # X_scores is a negative number
-X_scores # print a positive number

Execution / Test Environment

  • Windows 10 or Ubuntu Linux
  • Python 3.6

Usage

  • Input : example_of_input.csv

    python3 LocalOutlierFactor.py

  • Output : example_of_output.csv with LOF scores