skmultiflow.prototype.
RobustSoftLearningVectorQuantization
Robust Soft Learning Vector Quantization for Streaming and Non-Streaming Data.
By choosing another gradient descent method the Robust Soft Learning Vector Quantization (RSLVQ) method can be used as an adaptive version.
Number of prototypes per class. Use list to specify different numbers per class, not implemented yet.
Prototypes to start with. If not given initialization near the class means. Class label must be placed as last entry of each prototype.
Variance of the distribution.
If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.
Decay rate used for momentum-based algorithm
To use momentum-based gradient descent, choose ‘adadelta’ instead of ‘vanilla’
Notes
The RSLVQ [2] can be used with vanilla SGD as gradient descent method or with a momentum-based gradient descent technique called Adadelta as proposed in [1].
References
Heusinger, M., Raab, C., Schleif, F.M.: Passive concept drift handling via momentum based robust soft learning vector quantization. In: Vellido, A., Gibert, K., Angulo, C., Martı́n Guerrero, J.D. (eds.) Advances in Self-Organizing Maps, Learning Vector Quantization, Clustering and Data Visualization. pp. 200–209. Springer International Publishing, Cham (2020)
Sambu Seo and Klaus Obermayer. 2003. Soft learning vector quantization. Neural Comput. 15, 7 (July 2003), 1589-1604
Examples
>>> # Imports >>> from skmultiflow.data import SEAGenerator >>> from skmultiflow.prototype import RobustSoftLearningVectorQuantization >>> >>> # Setup a data stream >>> stream = SEAGenerator(random_state=1) >>> >>> # Pre-train the estimator with 200 samples >>> X, y = stream.next_sample(200) >>> rslvq = RobustSoftLearningVectorQuantization() >>> rslvq.partial_fit(X, y) >>> >>> # Preparing the processing of 5000 samples and correct prediction count >>> n_samples = 0 >>> correct_cnt = 0 >>> while n_samples < 5000 and stream.has_more_samples(): >>> X, y = stream.next_sample() >>> y_pred = rslvq.predict(X) >>> if y[0] == y_pred[0]: >>> correct_cnt += 1 >>> rslvq.partial_fit(X, y) >>> n_samples += 1 >>> >>> # Display results >>> print('Robust Soft Learning Vector Quantization usage example') >>> print('{} samples analyzed.'.format(n_samples)) >>> print('Performance: {}'.format(correct_cnt / n_samples))
prototypes
The prototypes
prototypes_classes
The prototypes classes
class_labels
The class labels
Methods
fit(self, X, y[, classes, sample_weight])
fit
Fit the model.
get_info(self)
get_info
Collects and returns the information about the configuration of the estimator
get_params(self[, deep])
get_params
Get parameters for this estimator.
partial_fit(self, X, y[, classes, sample_weight])
partial_fit
Fit the LVQ model to the given training data and parameters using gradient ascent.
predict(self, X)
predict
Predict class membership index for each input sample.
predict_proba(self, X)
predict_proba
Not implemented for this method.
reset(self)
reset
Resets the estimator to its initial state.
score(self, X, y[, sample_weight])
score
Returns the mean accuracy on the given test data and labels.
set_params(self, **params)
set_params
Set the parameters of this estimator.
Attributes
The features to train the model.
An array-like with the class labels of all samples in X.
Contains all possible/known class labels. Usage varies depending on the learning method.
Samples weight. If not provided, uniform weights are assumed. Usage varies depending on the learning method.
Configuration of the estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Training vector, where n_samples in the number of samples and n_features is the number of features.
An array-like with the class labels of all samples in X
This function does classification on an array of test vectors X.
Returns predicted values.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Test samples.
True labels for X.
Sample weights.
Mean accuracy of self.predict(X) wrt. y.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
<component>__<parameter>