LabelSpreading model for semi-supervised learning
This model is similar to the basic Label Propagation algorithm, but uses affinity matrix based on the normalized graph Laplacian and soft clamping across the labels.
Read more in the :ref:`User Guide <label_propagation>`.
Parameters ---------- kernel : 'knn', 'rbf', callable
String identifier for kernel function to use or the kernel function itself. Only 'rbf' and 'knn' strings are valid inputs. The function passed should take two inputs, each of shape n_samples, n_features
, and return a n_samples, n_samples
shaped weight matrix
gamma : float parameter for rbf kernel
n_neighbors : integer > 0 parameter for knn kernel
alpha : float Clamping factor. A value in (0, 1) that specifies the relative amount that an instance should adopt the information from its neighbors as opposed to its initial label. alpha=0 means keeping the initial label information; alpha=1 means replacing all initial information.
max_iter : integer maximum number of iterations allowed
tol : float Convergence tolerance: threshold to consider the system at steady state
n_jobs : int or None, optional (default=None) The number of parallel jobs to run. ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context. ``-1`` means using all processors. See :term:`Glossary <n_jobs>` for more details.
Attributes ---------- X_ : array, shape = n_samples, n_features
Input array.
classes_ : array, shape = n_classes
The distinct labels used in classifying instances.
label_distributions_ : array, shape = n_samples, n_classes
Categorical distribution for each item.
transduction_ : array, shape = n_samples
Label assigned to each item via the transduction.
n_iter_ : int Number of iterations run.
Examples -------- >>> import numpy as np >>> from sklearn import datasets >>> from sklearn.semi_supervised import LabelSpreading >>> label_prop_model = LabelSpreading() >>> iris = datasets.load_iris() >>> rng = np.random.RandomState(42) >>> random_unlabeled_points = rng.rand(len(iris.target)) < 0.3 >>> labels = np.copy(iris.target) >>> labelsrandom_unlabeled_points
= -1 >>> label_prop_model.fit(iris.data, labels) LabelSpreading(...)
References ---------- Dengyong Zhou, Olivier Bousquet, Thomas Navin Lal, Jason Weston, Bernhard Schoelkopf. Learning with local and global consistency (2004) http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.115.3219
See Also -------- LabelPropagation : Unregularized graph based semi-supervised learning