8000 DOC Ensures that LocalOutlierFactor passes numpydoc validation (#21180) · scikit-learn/scikit-learn@e7fb5b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit e7fb5b8

Browse files
DOC Ensures that LocalOutlierFactor passes numpydoc validation (#21180)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent cbe4151 commit e7fb5b8

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"KNNImputer",
1313
"LabelPropagation",
1414
"LabelSpreading",
15-
"LocalOutlierFactor",
1615
"LocallyLinearEmbedding",
1716
"MultiLabelBinarizer",
1817
"MultiTaskElasticNet",

sklearn/neighbors/_lof.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717

1818

1919
class LocalOutlierFactor(KNeighborsMixin, OutlierMixin, NeighborsBase):
20-
"""Unsupervised Outlier Detection using Local Outlier Factor (LOF)
20+
"""Unsupervised Outlier Detection using the Local Outlier Factor (LOF).
2121
22-
The anomaly score of each sample is called Local Outlier Factor.
23-
It measures the local deviation of density of a given sample with
24-
respect to its neighbors.
22+
The anomaly score of each sample is called the Local Outlier Factor.
23+
It measures the local deviation of the density of a given sample with respect
24+
to its neighbors.
2525
It is local in that the anomaly score depends on how isolated the object
2626
is with respect to the surrounding neighborhood.
2727
More precisely, locality is given by k-nearest neighbors, whose distance
2828
is used to estimate the local density.
29-
By comparing the local density of a sample to the local densities of
30-
its neighbors, one can identify samples that have a substantially lower
31-
density than their neighbors. These are considered outliers.
29+
By comparing the local density of a sample to the local densities of its
30+
neighbors, one can identify samples that have a substantially lower density
31+
than their neighbors. These are considered outliers.
3232
3333
.. versionadded:: 0.19
3434
@@ -52,13 +52,13 @@ class LocalOutlierFactor(KNeighborsMixin, OutlierMixin, NeighborsBase):
5252
this parameter, using brute force.
5353
5454
leaf_size : int, default=30
55-
Leaf size passed to :class:`BallTree` or :class:`KDTree`. This can
55+
Leaf is size passed to :class:`BallTree` or :class:`KDTree`. This can
5656
affect the speed of the construction and query, as well as the memory
5757
required to store the tree. The optimal value depends on the
5858
nature of the problem.
5959
6060
metric : str or callable, default='minkowski'
61-
metric used for the distance computation. Any metric from scikit-learn
61+
The metric is used for distance computation. Any metric from scikit-learn
6262
or scipy.spatial.distance can be used.
6363
6464
If metric is "precomputed", X is assumed to be a distance matrix and
@@ -84,7 +84,7 @@ class LocalOutlierFactor(KNeighborsMixin, OutlierMixin, NeighborsBase):
8484
8585
See the documentation for scipy.spatial.distance for details on these
8686
metrics:
87-
https://docs.scipy.org/doc/scipy/reference/spatial.distance.html
87+
https://docs.scipy.org/doc/scipy/reference/spatial.distance.html.
8888
8989
p : int, default=2
9090
Parameter for the Minkowski metric from
@@ -170,6 +170,16 @@ class LocalOutlierFactor(KNeighborsMixin, OutlierMixin, NeighborsBase):
170170
n_samples_fit_ : int
171171
It is the number of samples in the fitted data.
172172
173+
See also
174+
----------
175+
sklearn.svm.OneClassSVM: Unsupervised Outlier Detection using
176+
Support Vector Machine.
177+
178+
References
179+
----------
180+
.. [1] Breunig, M. M., Kriegel, H. P., Ng, R. T., & Sander, J. (2000, May).
181+
LOF: identifying density-based local outliers. In ACM sigmod record.
182+
173183
Examples
174184
--------
175185
>>> import numpy as np
@@ -180,11 +190,6 @@ class LocalOutlierFactor(KNeighborsMixin, OutlierMixin, NeighborsBase):
180190
array([ 1, 1, -1, 1])
181191
>>> clf.negative_outlier_factor_
182192
array([ -0.9821..., -1.0370..., -73.3697..., -0.9821...])
183-
184-
References
185-
----------
186-
.. [1] Breunig, M. M., Kriegel, H. P., Ng, R. T., & Sander, J. (2000, May).
187-
LOF: identifying density-based local outliers. In ACM sigmod record.
188193
"""
189194

190195
def __init__(
@@ -223,7 +228,7 @@ def _check_novelty_fit_predict(self):
223228

224229
@available_if(_check_novelty_fit_predict)
225230
def fit_predict(self, X, y=None):
226-
"""Fits the model to the training set X and returns the labels.
231+
"""Fit the model to the training set X and return the labels.
227232
228233
**Not available for novelty detection (when novelty is set to True).**
229234
Label is 1 for an inlier and -1 for an outlier according to the LOF

0 commit comments

Comments
 (0)
0