S4VM¶
S4VM implements the S4VM algorithm in [1].¶
S4VM employs the Python version of libsvm [2] (available at https://www.csie.ntu.edu.tw/~cjlin/libsvm/).
References
[1] | Yu-Feng Li and Zhi-Hua Zhou. Towards Making Unlabeled Data Never Hurt. In: Proceedings of the 28th International Conference on Machine Learning (ICML‘11), Bellevue, Washington, 2011. |
[2] | R.-E. Fan, P.-H. Chen, and C.-J. Lin. Working set selection using second order information for training SVM. Journal of Machine Learning Research 6, 1889-1918, 2005. |
-
class
s3l.model_uncertainty.S4VM.
S4VM
(kernel='RBF', C1=100, C2=0.1, sample_time=100, gamma=0, n_clusters=10)[source]¶ Bases:
s3l.base.InductiveEstimatorWOGraph
Base class for S4VM module.
Parameters: - kernel ('RBF' or 'Linear' (default='RBF')) – String identifier for kernel function to use or the kernel function itself. Only ‘RBF’ and ‘Linear’ strings are valid inputs.
- gamma (float) – Parameter gamma is the width of RBF kernel. Default value is average distance between instances.
- C1 (double (default=100)) – Weight for the hinge loss of labeled instance.
- C2 (double (default=0.1)) – Weight for the hinge loss of unlabeled instance. If C2 is set as 0, our S4VM will degenerate to standard SVM.
- sampleTime (integer (default=100)) – The sampling times for each sampleTime.
- n_clusters (integer (default=10)) – The number of clusters to form as well as the number of centroids to generate for K-means.
-
fit
(X, y, labeled_idx)[source]¶ Fit the model according to the given training data.
Parameters: - X ({array-like, sparse matrix}, shape = [n_samples, n_features]) – Training vector containing labeled and unlabeled instances, where n_samples in the number of samples and n_features is the number of features. All unlabeled samples will be transductively assigned labels.
- y (array-like, shape = [n_labeled_samples]) – Target vector relative to labeled instances in X.
- labeled_idx (array-like, shape = [n_labeled_samples]) – Index of labeled instances in X.
Returns: self
Return type:
-
predict
(u_ind)[source]¶ Predict method replace the unsafe prediction with the baseline_pred to improve the safeness.
Parameters: u_ind (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: pred – the label of the instance, including labeled and unlabeled instances, even though for labeled instances the prediction is consistent with the true label. Return type: a column vector with length n. Each element is a prediction for