skmultiflow.core.RegressorMixin

class skmultiflow.core.RegressorMixin[source]

Mixin class for all regression estimators in scikit-multiflow.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Methods

fit(X, y[, sample_weight])

Fit the model.

partial_fit(X, y[, sample_weight])

Partially (incrementally) fit the model.

predict(X)

Predict target values for the passed data.

predict_proba(X)

Estimates the probability for probabilistic/bayesian regressors

score(X, y[, sample_weight])

Returns the coefficient of determination R^2 of the prediction.

fit(X, y, sample_weight=None)[source]

Fit the model.

Parameters
  • X (numpy.ndarray of shape (n_samples, n_features)) – The features to train the model.

  • y (numpy.ndarray of shape (n_samples, n_targets)) – An array-like with the target values of all samples in X.

  • sample_weight (numpy.ndarray, optional (default=None)) – Samples weight. If not provided, uniform weights are assumed. Usage varies depending on the learning method.

Returns

Return type

self

partial_fit(X, y, sample_weight=None)[source]

Partially (incrementally) fit the model.

Parameters
  • X (numpy.ndarray of shape (n_samples, n_features)) – The features to train the model.

  • y (numpy.ndarray of shape (n_samples)) – An array-like with the target values of all samples in X.

  • sample_weight (numpy.ndarray of shape (n_samples), optional (default=None)) – Samples weight. If not provided, uniform weights are assumed. Usage varies depending on the learning method.

Returns

Return type

self

predict(X)[source]

Predict target values for the passed data.

Parameters

X (numpy.ndarray of shape (n_samples, n_features)) – The set of data samples to predict the target values for.

Returns

Return type

A numpy.ndarray with all the predictions for the samples in X.

predict_proba(X)[source]

Estimates the probability for probabilistic/bayesian regressors

Parameters

X (numpy.ndarray of shape (n_samples, n_features)) – The matrix of samples one wants to predict the probabilities for.

Returns

Return type

numpy.ndarray

score(X, y, sample_weight=None)[source]

Returns the coefficient of determination R^2 of the prediction.

The coefficient R^2 is defined as (1 - u/v), where u is the residual sum of squares ((y_true - y_pred) ** 2).sum() and v is the total sum of squares ((y_true - y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R^2 score of 0.0.

Parameters
  • X (array-like, shape = (n_samples, n_features)) – Test samples. For some estimators this may be a precomputed kernel matrix instead, shape = (n_samples, n_samples_fitted], where n_samples_fitted is the number of samples used in the fitting for the estimator.

  • y (array-like, shape = (n_samples) or (n_samples, n_outputs)) – True values for X.

  • sample_weight (array-like, shape = [n_samples], optional) – Sample weights.

Returns

score – R^2 of self.predict(X) wrt. y.

Return type

float

Notes

The R2 score used when calling score on a regressor will use multioutput='uniform_average' from version 0.23 to keep consistent with metrics.r2_score. This will influence the score method of all the multioutput regressors (except for multioutput.MultiOutputRegressor). To specify the default value manually and avoid the warning, please either call metrics.r2_score directly or make a custom scorer with metrics.make_scorer (the built-in scorer 'r2' uses multioutput='uniform_average').