-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import numpy as np | ||
from sklearn.neighbors import LocalOutlierFactor | ||
|
||
class LocalOutlierFactorAnomalyDetector: | ||
def __init__(self, n_neighbors=20, algorithm='auto', leaf_size=30, metric='minkowski', p=2): | ||
self.n_neighbors = n_neighbors | ||
self.algorithm = algorithm | ||
self.leaf_size = leaf_size | ||
self.metric = metric | ||
self.p = p | ||
self.lof = LocalOutlierFactor(n_neighbors=n_neighbors, algorithm=algorithm, leaf_size=leaf_size, metric=metric, p=p) | ||
|
||
def fit(self, X): | ||
self.lof.fit(X) | ||
|
||
def predict(self, X): | ||
return self.lof.predict(X) | ||
|
||
def decision_function(self, X): | ||
return self.lof.decision_function(X) | ||
|
||
def score_samples(self, X): | ||
return self.lof.score_samples(X) |