8000 DOC Ensures that LabelPropagation passes numpydoc validation (#20991) · scikit-learn/scikit-learn@31ba67a · GitHub
[go: up one dir, main page]

Skip to content

Commit 31ba67a

Browse files
genvalenglemaitre
andauthored
DOC Ensures that LabelPropagation passes numpydoc val 8000 idation (#20991)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent c3f41ae commit 31ba67a

File tree

2 files changed

+42
-20
lines changed

2 files changed

+42
-20
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# List of modules ignored when checking for numpydoc validation.
1515
DOCSTRING_IGNORE_LIST = [
1616
"KNNImputer",
17-
"LabelPropagation",
1817
"LabelSpreading",
1918
"LocallyLinearEmbedding",
2019
"MultiTaskElasticNetCV",

sklearn/semi_supervised/_label_propagation.py

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def _build_graph(self):
167167
)
168168

169169
def predict(self, X):
170-
"""Performs inductive inference across the model.
170+
"""Perform inductive inference across the model.
171171
172172
Parameters
173173
----------
@@ -223,24 +223,28 @@ class labels.
223223
return probabilities
224224

225225
def fit(self, X, y):
226-
"""Fit a semi-supervised label propagation model based
226+
"""Fit a semi-supervised label propagation model to X.
227227
228-
All the input data is provided matrix X (labeled and unlabeled)
229-
and corresponding label matrix y with a dedicated marker value for
230-
unlabeled samples.
228+
The input samples (labeled and unlabeled) are provided by matrix X,
229+
and target labels are provided by matrix y. We conventionally apply the
230+
label -1 to unlabeled samples in matrix y in a semi-supervised
231+
classification.
231232
232233
Parameters
233234
----------
234235
X : array-like of shape (n_samples, n_features)
235-
A matrix of shape (n_samples, n_samples) will be created from this.
236+
Training data, where `n_samples` is the number of samples
237+
and `n_features` is the number of features.
236238
237239
y : array-like of shape (n_samples,)
238-
`n_labeled_samples` (unlabeled points are marked as -1)
239-
All unlabeled samples will be transductively assigned labels.
240+
Target class values with unlabeled points marked as -1.
241+
All unlabeled samples will be transductively assigned labels
242+
internally.
240243
241244
Returns
242245
-------
243246
self : object
247+
Returns the instance itself.
244248
"""
245249
X, y = self._validate_data(X, y)
246250
self.X_ = X
@@ -326,7 +330,7 @@ def fit(self, X, y):
326330

327331

328332
class LabelPropagation(BaseLabelPropagation):
329-
"""Label Propagation classifier
333+
"""Label Propagation classifier.
330334
331335
Read more in the :ref:`User Guide <label_propagation>`.
332336
@@ -385,6 +389,17 @@ class LabelPropagation(BaseLabelPropagation):
385389
n_iter_ : int
386390
Number of iterations run.
387391
392+
See Also
393+
--------
394+
BaseLabelPropagation : Base class for label propagation module.
395+
LabelSpreading : Alternate label propagation strategy more robust to noise.
396+
397+
References
398+
----------
399+
Xiaojin Zhu and Zoubin Ghahramani. Learning from labeled and unlabeled data
400+
with label propagation. Technical Report CMU-CALD-02-107, Carnegie Mellon
401+
University, 2002 http://pages.cs.wisc.edu/~jerryzhu/pub/CMU-CALD-02-107.pdf
402+
388403
Examples
389404
--------
390405
>>> import numpy as np
@@ -398,16 +413,6 @@ class LabelPropagation(BaseLabelPropagation):
398413
>>> labels[random_unlabeled_points] = -1
399414
>>> label_prop_model.fit(iris.data, labels)
400415
LabelPropagation(...)
401-
402-
References
403-
----------
404-
Xiaojin Zhu and Zoubin Ghahramani. Learning from labeled and unlabeled data
405-
with label propagation. Technical Report CMU-CALD-02-107, Carnegie Mellon
406-
University, 2002 http://pages.cs.wisc.edu/~jerryzhu/pub/CMU-CALD-02-107.pdf
407-
408-
See Also
409-
--------
410-
LabelSpreading : Alternate label propagation strategy more robust to noise.
411416
"""
412417

413418
_variant = "propagation"
@@ -449,6 +454,24 @@ class distributions will exceed 1 (normalization may be desired).
449454
return affinity_matrix
450455

451456
def fit(self, X, y):
457+
"""Fit a semi-supervised label propagation model to X.
458+
459+
Parameters
460+
----------
461+
X : array-like of shape (n_samples, n_features)
462+
Training data, where `n_samples` is the number of samples
463+
and `n_features` is the number of features.
464+
465+
y : array-like of shape (n_samples,)
466+
Target class values with unlabeled points marked as -1.
467+
All unlabeled samples will be transductively assigned labels
468+
internally.
469+
470+
Returns
471+
-------
472+
self : object
473+
Returns the instance itself.
474+
"""
452475
return super().fit(X, y)
453476

454477

0 commit comments

Comments
 (0)
0