DeterministicConstantRegressor

DeterministicConstantRegressor

This "dummy" predictor always makes the same prediction, irrespective of the provided input pattern, namely the mean value of the training target values. (It's counterpart, ConstantRegressor makes probabilistic predictions.) This model handles mutlitargets, i.e, the training target can be a matrix or a table (with rows as observations).

Almost any reasonable model is expected to outperform DeterministicConstantRegressor which is used almost exclusively for testing and establishing performance baselines.

In MLJ, do model = DeterministicConstantRegressor() to construct a model instance.

Training data

In MLJ (or MLJBase) bind an instance model to data with

mach = machine(model, X, y)

Here:

  • X is any table of input features (eg, a DataFrame)
  • y is the target, which can be any AbstractVector, AbstractVector or table whose element scitype is Continuous; check the scitype scitype(y) or, for tables, with schema(y)

Train the machine using fit!(mach, rows=...).

Operations

  • predict(mach, Xnew): Return predictions of the target given features Xnew (which for this model are ignored).

Fitted parameters

The fields of fitted_params(mach) are:

  • mean: The target mean(s). Always a row vector. (i.e an AbstractMatrix object with row dim 1)

Examples

using MLJ

X, y = make_regression(10, 2; n_targets=3); ## synthetic data: two tables
regressor = DeterministicConstantRegressor();
mach = machine(regressor, X, y) |> fit!;

fitted_params(mach)

Xnew, _ = make_regression(3, 2)
predict(mach, Xnew)

See also ConstantClassifier