mars.learn.semi_supervised.LabelPropagation#
- class mars.learn.semi_supervised.LabelPropagation(kernel='rbf', gamma=20, n_neighbors=7, max_iter=1000, tol=0.001)[源代码]#
Label Propagation classifier
Read more in the User Guide.
- 参数
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
max_iter (integer) – Change maximum number of iterations allowed
tol (float) – Convergence tolerance: threshold to consider the system at steady state
- X_#
Input array.
- Type
array, shape = [n_samples, n_features]
- classes_#
The distinct labels used in classifying instances.
- Type
array, shape = [n_classes]
- label_distributions_#
Categorical distribution for each item.
- Type
array, shape = [n_samples, n_classes]
- transduction_#
Label assigned to each item via the transduction.
- Type
array, shape = [n_samples]
实际案例
>>> import numpy as np >>> from sklearn import datasets >>> from mars.learn.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) >>> labels[random_unlabeled_points] = -1 >>> label_prop_model.fit(iris.data, labels) LabelPropagation(...)
引用
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
参见
LabelSpreading
Alternate label propagation strategy more robust to noise
Methods
__init__
([kernel, gamma, n_neighbors, ...])fit
(X, y[, session, run_kwargs])Fit a semi-supervised label propagation model based
get_params
([deep])Get parameters for this estimator.
predict
(X[, session, run_kwargs])Performs inductive inference across the model.
predict_proba
(X[, session, run_kwargs])Predict probability for each possible outcome.
score
(X, y[, sample_weight, session, run_kwargs])Return the mean accuracy on the given test data and labels.
set_params
(**params)Set the parameters of this estimator.