DummyRegressor#

  • Crea un estimador que pronostica con reglas simples.

  • Se usa como linea base de comparación con otros modelos.

[1]:
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 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.
    strategy="mean",
    # -------------------------------------------------------------------------
    # The explicit constant as predicted by the “constant” strategy. This
    # parameter is useful only for the “constant” strategy.
    constant=None,
    # -------------------------------------------------------------------------
    # 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.
    quantile=None,
)


dummy_regr.fit(X, y)
[1]:
DummyRegressor()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
[2]:
dummy_regr.predict(X)
[2]:
array([5., 5., 5., 5.])
[3]:
dummy_regr.score(X, y)
[3]:
0.0