Prediction voting regressor for unfitted estimators.
.. versionadded:: 0.21
A voting regressor is an ensemble meta-estimator that fits several base regressors, each on the whole dataset. Then it averages the individual predictions to form a final prediction.
Read more in the :ref:`User Guide <voting_regressor>`.
Parameters ---------- estimators : list of (str, estimator) tuples Invoking the ``fit`` method on the ``VotingRegressor`` will fit clones of those original estimators that will be stored in the class attribute ``self.estimators_``. An estimator can be set to ``'drop'`` using ``set_params``.
.. versionchanged:: 0.21 ``'drop'`` is accepted.
.. deprecated:: 0.22 Using ``None`` to drop an estimator is deprecated in 0.22 and support will be dropped in 0.24. Use the string ``'drop'`` instead.
weights : array-like of shape (n_regressors,), default=None Sequence of weights (`float` or `int`) to weight the occurrences of predicted values before averaging. Uses uniform weights if `None`.
n_jobs : int, default=None The number of jobs to run in parallel for ``fit``. ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context. ``-1`` means using all processors. See :term:`Glossary <n_jobs>` for more details.
verbose : bool, default=False If True, the time elapsed while fitting will be printed as it is completed.
Attributes ---------- estimators_ : list of regressors The collection of fitted sub-estimators as defined in ``estimators`` that are not 'drop'.
named_estimators_ : Bunch Attribute to access any fitted sub-estimators by name.
.. versionadded:: 0.20
See Also -------- VotingClassifier: Soft Voting/Majority Rule classifier.
Examples -------- >>> import numpy as np >>> from sklearn.linear_model import LinearRegression >>> from sklearn.ensemble import RandomForestRegressor >>> from sklearn.ensemble import VotingRegressor >>> r1 = LinearRegression() >>> r2 = RandomForestRegressor(n_estimators=10, random_state=1) >>> X = np.array([1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36]
) >>> y = np.array(2, 6, 12, 20, 30, 42
) >>> er = VotingRegressor(('lr', r1), ('rf', r2)
) >>> print(er.fit(X, y).predict(X)) 3.3 5.7 11.8 19.7 28. 40.3