Label Propagation classifier
Read more in the :ref:`User Guide <label_propagation>`.
Parameters ---------- kernel : 'knn', 'rbf'
or callable, default='rbf' 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, default=20 Parameter for rbf kernel.
n_neighbors : int, default=7 Parameter for knn kernel which need to be strictly positive.
max_iter : int, default=1000 Change maximum number of iterations allowed.
tol : float, 1e-3 Convergence tolerance: threshold to consider the system at steady state.
n_jobs : int, 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_ : ndarray of shape (n_samples, n_features) Input array.
classes_ : ndarray of shape (n_classes,) The distinct labels used in classifying instances.
label_distributions_ : ndarray of shape (n_samples, n_classes) Categorical distribution for each item.
transduction_ : ndarray of 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 LabelPropagation >>> label_prop_model = LabelPropagation() >>> 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) LabelPropagation(...)
References ---------- Xiaojin Zhu and Zoubin Ghahramani. Learning from labeled and unlabeled data with label propagation. Technical Report CMU-CALD-02-107, Carnegie Mellon University, 2002 http://pages.cs.wisc.edu/~jerryzhu/pub/CMU-CALD-02-107.pdf
See Also -------- LabelSpreading : Alternate label propagation strategy more robust to noise