LPA¶
-
class
s3l.classification.LPA.
LPA
(kernel='rbf', gamma=20, n_neighbors=7, max_iter=30, tol=0.001, n_jobs=None)[source]¶ Bases:
s3l.base.TransductiveEstimatorwithGraph
Class for label propagation module.
Parameters: - kernel ({'knn', 'rbf', 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 (integer > 0 (default=7)) – Parameter for knn kernel
- max_iter (integer (default=30)) – Change maximum number of iterations allowed
- tol (float (default=1e-3)) – 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 ajoblib.parallel_backend`context. `
-1`` means using all processors. See Glossary for more details.
-
fit
(X, y, labeled_idx, W)[source]¶ Fit a label propagation model
All the input data is provided matrix X (labeled and unlabeled) and corresponding label matrix y with a dedicated marker value for unlabeled samples. Optional matrix W is a graph provided for label propagation.
Parameters: - X (array-like, shape = [n_samples, n_features]) – A {n_samples by n_samples} size matrix will be created from this
- y (array_like, shape = [n_samples]) – n_labeled_samples (unlabeled points are marked as 0)
- labeled_idx (array_like, shape = [n_samples]) – index of n_labeled_samples in X.
- W (array_like, shape = [n_samples, n_samples]) – graph of instances
Returns: self
Return type: returns an instance of self.
-
predict
(index)[source]¶ Performs transductive inference across the model.
Parameters: index (array-like) – a row vector with length l, where l is the number of unlabeled instance. Each element is an index of a unlabeled instance. Returns: y – Predictions for input data Return type: array_like, shape = [n_samples]