@@ -167,7 +167,7 @@ def _build_graph(self):
167
167
)
168
168
169
169
def predict (self , X ):
170
- """Performs inductive inference across the model.
170
+ """Perform inductive inference across the model.
171
171
172
172
Parameters
173
173
----------
@@ -223,24 +223,28 @@ class labels.
223
223
return probabilities
224
224
225
225
def fit (self , X , y ):
226
- """Fit a semi-supervised label propagation model based
226
+ """Fit a semi-supervised label propagation model to X.
227
227
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.
231
232
232
233
Parameters
233
234
----------
234
235
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.
236
238
237
239
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.
240
243
241
244
Returns
242
245
-------
243
246
self : object
247
+ Returns the instance itself.
244
248
"""
245
249
X , y = self ._validate_data (X , y )
246
250
self .X_ = X
@@ -326,7 +330,7 @@ def fit(self, X, y):
326
330
327
331
328
332
class LabelPropagation (BaseLabelPropagation ):
329
- """Label Propagation classifier
333
+ """Label Propagation classifier.
330
334
331
335
Read more in the :ref:`User Guide <label_propagation>`.
332
336
@@ -385,6 +389,17 @@ class LabelPropagation(BaseLabelPropagation):
385
389
n_iter_ : int
386
390
Number of iterations run.
387
391
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
+
388
403
Examples
389
404
--------
390
405
>>> import numpy as np
@@ -398,16 +413,6 @@ class LabelPropagation(BaseLabelPropagation):
398
413
>>> labels[random_unlabeled_points] = -1
399
414
>>> label_prop_model.fit(iris.data, labels)
400
415
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.
411
416
"""
412
417
413
418
_variant = "propagation"
@@ -449,6 +454,24 @@ class distributions will exceed 1 (normalization may be desired).
449
454
return affinity_matrix
450
455
451
456
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
+ """
452
475
return super ().fit (X , y )
453
476
454
477
0 commit comments