skmultiflow.neural_networks.
PerceptronMask
Mask for sklearn.linear_model.Perceptron.
scikit-multiflow requires a few interfaces, not present in scikit-learn, This mask serves as a wrapper for the Perceptron classifier.
Examples
>>> # Imports >>> from skmultiflow.neural_networks import PerceptronMask >>> from skmultiflow.data import SEAGenerator >>> >>> # Setup a data stream >>> stream = SEAGenerator(random_state=1) >>> >>> # Setup the Perceptron Mask >>> perceptron = PerceptronMask() >>> >>> n_samples = 0 >>> correct_cnt = 0 >>> while n_samples < 5000 and stream.has_more_samples(): >>> X, y = stream.next_sample() >>> my_pred = perceptron.predict(X) >>> if y[0] == my_pred[0]: >>> correct_cnt += 1 >>> perceptron.partial_fit(X, y, classes=stream.target_values) >>> n_samples += 1 >>> >>> # Display the results >>> print('Perceptron Mask usage example') >>> print('{} samples analyzed'.format(n_samples)) >>> print("Perceptron's performance: {}".format(correct_cnt / n_samples))
Methods
fit(self, X, y[, classes, sample_weight])
fit
Calls the Perceptron fit function from sklearn.
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
Calls the Perceptron partial_fit from sklearn.
predict(self, X)
predict
Uses the current model to predict samples in X.
predict_proba(self, X)
predict_proba
Predicts the probability of each sample belonging to each one of the known classes.
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.
The feature’s matrix.
The class labels for all samples in X.
Samples weight. If not provided, uniform weights are assumed.
self
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.
A numpy.ndarray containing the predicted labels for all instances in X.
A matrix of the samples we want to predict.
An array of shape (n_samples, n_features), in which each outer entry is associated with the X entry of the same index. And where the list in index [i] contains len(self.target_values) elements, each of which represents the probability that the i-th sample of X belongs to a certain label.
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>