Using DummyRegressor as a Baseline to Interpret Regression Metrics
A regression metric like MAE=5 is meaningless without knowing what a constant predictor achieves on the same data. DummyRegressor provides that reference point, letting you judge whether your model captures real signal or merely reproduces central tendency.
On this page
The short answer
DummyRegressor fits a single scalar (mean, median, quantile, or user-supplied constant) to training targets and returns that value for every prediction regardless of input features. By computing the same metric on dummy predictions and model predictions over held-out data, you obtain a ratio that normalizes performance across datasets. A ratio near 1.0 means the model learned nothing beyond the unconditional center; a ratio well below 1.0 confirms genuine predictive gain. The strategy must match the metric: median for MAE, mean for MSE or RMSE, quantile for pinball loss. Mismatched pairings inflate the baseline and create a false impression of model superiority.
Why an absolute metric value carries no information about forecast quality
A number such as MAE equals 5 tells you nothing about whether your model is good, mediocre, or useless. The target variable might have a standard deviation of 0.1, making 5 catastrophic, or a standard deviation of 100, making 5 excellent. Metrics measure distance to truth, not distance to a trivial solution. The scikit-learn model evaluation guide states that Dummy estimators are useful to get a baseline value of those metrics for random predictions, precisely because without that anchor the raw number is uninterpretable. The scale and variance of the target determine what counts as good, and only a constant-predictor comparison reveals that scale.
Practical tip
Always report the baseline-to-model ratio alongside the raw metric in any experiment write-up. If you cannot beat the median predictor on validation data, ship the constant: it is faster, simpler, and equally accurate. For time-series problems, replace the global median with a per-season or per-group median to avoid crediting a model for exploiting trend that any lagged naive forecast would capture.
How DummyRegressor mechanically produces a constant prediction
Internally, fit stores a single scalar derived from the training targets. The predict method completely ignores the input data X and returns that scalar repeated n_times. The scikit-learn documentation lists four strategies: mean predicts the training mean, median predicts the training median, quantile predicts a user-specified quantile, and constant predicts a user-supplied value. Because predict discards X entirely, the dummy serves as a pure reference point against which any feature-dependent model can be compared.
Matching the dummy strategy to your evaluation metric
The alignment principle follows from statistical decision theory. Under MAE the optimal constant predictor is the median; under MSE or RMSE it is the mean; under pinball loss at alpha it is the corresponding quantile. The model evaluation guide frames this through strictly consistent scoring functions that act as truth serum, guaranteeing that reporting the true functional is an optimal strategy in expectation. If you evaluate with MAE but compare against a mean-based dummy, the baseline is inflated and your model appears better than it truly is. Always pair the metric with its matching dummy strategy.
Computing the baseline score on held-out data
The concrete workflow is straightforward: fit DummyRegressor on X_train and y_train only, call predict on X_test, then pass those predictions to the same metric function used for your real model. Fitting on training data alone prevents leakage. The test-set baseline is the honest reference for generalization. Below is a complete example using synthetic data where X carries no signal about y, so a properly regularized model should produce a ratio near 1.0. A ratio above 1.0 on held-out data indicates the model performs worse than the constant baseline, which may result from overfitting, misspecification, or inadequate regularization; distinguishing among these causes requires comparing training and test metrics.
Requires scikit-learn 0.18 or later and NumPy 1.17 or later (for default_rng). The example uses default_rng from NumPy for reproducibility.
from sklearn.dummy import DummyRegressor
from sklearn.linear_model import Ridge
from sklearn.metrics import mean_absolute_error
from sklearn.model_selection import train_test_split
import numpy as np
rng = np.random.default_rng(42)
X = rng.normal(size=(200, 5))
y = np.median(rng.normal(size=200)) + rng.laplace(scale=3.0, size=200)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
dummy = DummyRegressor(strategy="median").fit(X_train, y_train)
baseline_pred = dummy.predict(X_test)
baseline_mae = mean_absolute_error(y_test, baseline_pred)
ridge = Ridge(alpha=1.0).fit(X_train, y_train)
model_pred = ridge.predict(X_test)
model_mae = mean_absolute_error(y_test, model_pred)
print(f"Baseline MAE (median): {baseline_mae:.3f}")
print(f"Model MAE (Ridge): {model_mae:.3f}")
print(f"Ratio model/baseline: {model_mae / baseline_mae:.3f}")Interpreting the gap between model score and baseline score
The ratio model_error divided by baseline_error is a normalized measure comparable across datasets. A ratio near 1.0 means the model is equivalent to predicting a constant and the features carry little signal beyond central tendency. A ratio of 0.7 means the model reduces error by thirty percent relative to the trivial predictor. In the example above, because X was generated independently of y, Ridge should produce a ratio close to 1.0, confirming it learned nothing useful. If you observe a ratio well below 1.0 on real data, the model captures genuine structure.
Using DummyRegressor inside cross-validation for robust comparison
A single train-test split can produce a noisy baseline. Integrating DummyRegressor into cross_val_score ensures every fold gets its own dummy fit, mirroring how the real model is evaluated and making fold-level comparisons fair. The code below demonstrates this pattern with five folds and the negated MAE scorer convention used by scikit-learn cross-validation utilities.
Requires scikit-learn 0.18 or later and NumPy 1.17 or later (for default_rng).
from sklearn.dummy import DummyRegressor
from sklearn.linear_model import Ridge
from sklearn.model_selection import cross_val_score
import numpy as np
rng = np.random.default_rng(42)
X = rng.normal(size=(200, 5))
y = np.median(rng.normal(size=200)) + rng.laplace(scale=3.0, size=200)
dummy_scores = cross_val_score(
DummyRegressor(strategy="median"), X, y,
cv=5, scoring="neg_mean_absolute_error"
)
ridge_scores = cross_val_score(
Ridge(alpha=1.0), X, y,
cv=5, scoring="neg_mean_absolute_error"
)
print(f"Dummy MAE per fold: {-dummy_scores}")
print(f"Ridge MAE per fold: {-ridge_scores}")
print(f"Mean ratio: {(-ridge_scores.mean()) / (-dummy_scores.mean()):.3f}")When the baseline itself is informative as a production fallback
A well-chosen dummy is not merely a diagnostic tool but a deployable model. If no trained model beats the median predictor on validation data, shipping the constant is the rational choice because it is simpler, faster, and equally accurate. The decision-theoretic framing from the model evaluation guide supports this: a strictly consistent scoring function guarantees that truth-telling is optimal in expectation, so if your model cannot beat the truth-telling constant, it adds no value and introduces unnecessary complexity and maintenance burden.
Limits of the constant baseline and when you need a richer reference
DummyRegressor captures only unconditional central tendency. It cannot represent conditional patterns, seasonality, or group-level shifts. For time series a seasonal naive forecast or per-group median is a more appropriate floor. The constant baseline sets a minimum bar that any model must clear but does not define the ceiling of achievable performance. Regarding sample_weight support, consult the DummyRegressor API reference for your installed scikit-learn version to confirm whether weighted fitting is available; if not, weighted baselines must be computed manually. Multioutput regression requires per-column baselines not addressed by the default single-target behavior.
Things to check
- The baseline MAE printed by the first code block should be approximately equal to the mean absolute deviation of y_test from its median, confirming the dummy returns a constant.
- The ratio model/baseline in the first example should be close to 1.0 because X carries no signal about y by construction.
- The cross-validation example uses neg_mean_absolute_error scoring, so higher (less negative) scores indicate better performance; the printed MAE values are obtained by negating the scores.
- Verify that DummyRegressor(strategy='median').predict(X_test) returns an array where every element is identical, confirming the constant-prediction behavior.
- The mean_absolute_error function returns a non-negative float; if you see a negative value, predictions and targets are swapped in the call.
Where this applies
This article covers single-target regression with unconditional constant baselines. It does not address multioutput DummyRegressor behavior, weighted baselines, or richer references such as seasonal naive forecasts for time series. The synthetic example demonstrates the mechanics but cannot validate real-world signal detection; on actual data a ratio below 1.0 confirms usefulness while a ratio above 1.0 indicates the model performs worse than a constant on held-out data, though the underlying cause (overfitting, misspecification, or poor tuning) requires further diagnosis. The examples use np.random.default_rng, which requires NumPy 1.17 or later. DummyRegressor with strategy=median and the neg_mean_absolute_error scorer are available since scikit-learn 0.18.