1515# ===============================================================================
1616
1717import warnings
18+ from functools import wraps
1819
1920import numpy as np
2021from sklearn .neighbors import LocalOutlierFactor as _sklearn_LocalOutlierFactor
@@ -142,28 +143,9 @@ def _predict(self, X=None):
142143 # This would cause issues in fit_predict. Also, available_if
143144 # is hard to unwrap, and this is the most straighforward way.
144145 @available_if (_sklearn_LocalOutlierFactor ._check_novelty_fit_predict )
146+ @wraps (_sklearn_LocalOutlierFactor .fit_predict , assigned = ["__doc__" ])
145147 @wrap_output_data
146148 def fit_predict (self , X , y = None ):
147- """Fit the model to the training set X and return the labels.
148-
149- **Not available for novelty detection (when novelty is set to True).**
150- Label is 1 for an inlier and -1 for an outlier according to the LOF
151- score and the contamination parameter.
152-
153- Parameters
154- ----------
155- X : {array-like, sparse matrix} of shape (n_samples, n_features), default=None
156- The query sample or samples to compute the Local Outlier Factor
157- w.r.t. the training samples.
158-
159- y : Ignored
160- Not used, present for API consistency by convention.
161-
162- Returns
163- -------
164- is_inlier : ndarray of shape (n_samples,)
165- Returns -1 for anomalies/outliers and 1 for inliers.
166- """
167149 return self .fit (X )._predict ()
168150
169151 def _kneighbors (self , X = None , n_neighbors = None , return_distance = True ):
@@ -185,34 +167,9 @@ def _kneighbors(self, X=None, n_neighbors=None, return_distance=True):
185167 kneighbors = wrap_output_data (_kneighbors )
186168
187169 @available_if (_sklearn_LocalOutlierFactor ._check_novelty_score_samples )
170+ @wraps (_sklearn_LocalOutlierFactor .score_samples , assigned = ["__doc__" ])
188171 @wrap_output_data
189172 def score_samples (self , X ):
190- """Opposite of the Local Outlier Factor of X.
191-
192- It is the opposite as bigger is better, i.e. large values correspond
193- to inliers.
194-
195- **Only available for novelty detection (when novelty is set to True).**
196- The argument X is supposed to contain *new data*: if X contains a
197- point from training, it considers the later in its own neighborhood.
198- Also, the samples in X are not considered in the neighborhood of any
199- point. Because of this, the scores obtained via ``score_samples`` may
200- differ from the standard LOF scores.
201- The standard LOF scores for the training data is available via the
202- ``negative_outlier_factor_`` attribute.
203-
204- Parameters
205- ----------
206- X : {array-like, sparse matrix} of shape (n_samples, n_features)
207- The query sample or samples to compute the Local Outlier Factor
208- w.r.t. the training samples.
209-
210- Returns
211- -------
212- opposite_lof_scores : ndarray of shape (n_samples,)
213- The opposite of the Local Outlier Factor of each input samples.
214- The lower, the more abnormal.
215- """
216173 check_is_fitted (self )
217174
218175 distances_X , neighbors_indices_X = self ._kneighbors (
0 commit comments