DummyRegressor is a regressor that makes predictions using simple rules.
This regressor is useful as a simple baseline to compare with other (real) regressors. Do not use it for real problems.
Read more in the :ref:`User Guide <dummy_estimators>`.
.. versionadded:: 0.13
Parameters ---------- strategy : str Strategy to use to generate predictions.
* "mean": always predicts the mean of the training set * "median": always predicts the median of the training set * "quantile": always predicts a specified quantile of the training set, provided with the quantile parameter. * "constant": always predicts a constant value that is provided by the user.
constant : int or float or array-like of shape (n_outputs,) The explicit constant as predicted by the "constant" strategy. This parameter is useful only for the "constant" strategy.
quantile : float in 0.0, 1.0
The quantile to predict using the "quantile" strategy. A quantile of 0.5 corresponds to the median, while 0.0 to the minimum and 1.0 to the maximum.
Attributes ---------- constant_ : array, shape (1, n_outputs) Mean or median or quantile of the training targets or constant value given by the user.
n_outputs_ : int, Number of outputs.
Examples -------- >>> import numpy as np >>> from sklearn.dummy import DummyRegressor >>> X = np.array(1.0, 2.0, 3.0, 4.0
) >>> y = np.array(2.0, 3.0, 5.0, 10.0
) >>> dummy_regr = DummyRegressor(strategy="mean") >>> dummy_regr.fit(X, y) DummyRegressor() >>> dummy_regr.predict(X) array(5., 5., 5., 5.
) >>> dummy_regr.score(X, y) 0.0