skmultiflow.meta.
RegressorChain
Regressor Chains for multi-output learning.
Each member of the ensemble is an instance of the base estimator.
None to use default order, ‘random’ for random order.
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.
Notes
Regressor Chains are a modification of Classifier Chains [1] for regression.
References
Read, Jesse, Bernhard Pfahringer, Geoff Holmes, and Eibe Frank. “Classifier chains for multi-label classification.” In Joint European Conference on Machine Learning and Knowledge Discovery in Databases, pp. 254-269. Springer, Berlin, Heidelberg, 2009.
Examples
>>> from sklearn.linear_model import SGDRegressor >>> from skmultiflow.meta import RegressorChain >>> from skmultiflow.data import make_logical >>> >>> X, Y = make_logical(random_state=1) >>> >>> print("TRUE: ") >>> print(Y) >>> print("vs") >>> >>> print("RC") >>> rc = RegressorChain(SGDRegressor(loss='squared_loss', random_state=1)) >>> rc.fit(X, Y) >>> print(rc.predict(X)) >>> >>> print("RRC") >>> rc = RegressorChain(SGDRegressor(loss='squared_loss', random_state=1), >>> order='random', random_state=1) >>> rc.fit(X, Y) >>> print(rc.predict(X))
Methods
fit(self, X, y[, 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[, sample_weight])
partial_fit
Partially (incrementally) fit the model.
predict(self, X)
predict
Predict target values for the passed data.
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 coefficient of determination R^2 of the prediction.
set_params(self, **params)
set_params
Set the parameters of this estimator.
The features to train the model.
An array-like with the target values of all samples in X.
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.
The set of data samples to predict the target values for.
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.
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.
True values for X.
Sample weights.
R^2 of self.predict(X) wrt. y.
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').
multioutput='uniform_average'
'r2'
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>