Skip to content

Commit e243f32

Browse files
deeplookqinhanmin2014
authored andcommitted
EXA Add example for neighbors.LocalOutlierFactor (scikit-learn#15203)
1 parent 692c2f2 commit e243f32

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sklearn/neighbors/_lof.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ class LocalOutlierFactor(NeighborsBase, KNeighborsMixin, UnsupervisedMixin,
144144
case, the offset is defined in such a way we obtain the expected
145145
number of outliers in training.
146146
147+
Example
148+
-------
149+
>>> import numpy as np
150+
>>> from sklearn.neighbors import LocalOutlierFactor
151+
>>> X = [[-1.1], [0.2], [101.1], [0.3]]
152+
>>> clf = LocalOutlierFactor(n_neighbors=2)
153+
>>> clf.fit_predict(X)
154+
array([ 1, 1, -1, 1])
155+
>>> clf.negative_outlier_factor_
156+
array([ -0.9821..., -1.0370..., -73.3697..., -0.9821...])
157+
147158
References
148159
----------
149160
.. [1] Breunig, M. M., Kriegel, H. P., Ng, R. T., & Sander, J. (2000, May).

0 commit comments

Comments
 (0)