Skip to content

Conversation

@ablaom
Copy link
Member

@ablaom ablaom commented Nov 11, 2025

After this PR, one can use DeterministicConstantRegressor with multitargets:

julia> using MLJBase, MLJModels

julia> X, y = make_regression(10, 2; n_targets=3); # synthetic data: two tables

julia> regressor = DeterministicConstantRegressor();

julia> mach = machine(regressor, X, y) |> fit!;
[ Info: Training machine(DeterministicConstantRegressor(), ).

julia> 

julia> fitted_params(mach)
(mean = [-0.08104117873774516 1.5935905587979058 1.0865047090815172],)

julia> 

julia> Xnew, _ = make_regression(3, 2)
(Tables.MatrixTable{Matrix{Float64}} with 3 rows, 2 columns, and schema:
 :x1  Float64
 :x2  Float64, [0.36837556494255974, 0.45959051755066704, 0.23793608647119824])

julia> predict(mach, Xnew)
(Column1 = [-0.08104117873774516, -0.08104117873774516, -0.08104117873774516], Column2 = [1.5935905587979058, 1.5935905587979058, 1.5935905587979058], Column3 = [1.0865047090815172, 1.0865047090815172, 1.0865047090815172])

It also adds tests and a docstring, which this model never had.

@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.77%. Comparing base (7384cde) to head (89aa6cb).
⚠️ Report is 7 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #602      +/-   ##
==========================================
+ Coverage   76.93%   78.77%   +1.83%     
==========================================
  Files           8        8              
  Lines         477      490      +13     
==========================================
+ Hits          367      386      +19     
+ Misses        110      104       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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 (observations the rows).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems likes there is a typo here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, where?

Copy link
Member

@OkonSamuel OkonSamuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!! I just made a couple of minor suggestions.

@ablaom
Copy link
Member Author

ablaom commented Nov 19, 2025

I realize I also need to:

  • make sure the column names of multitargets get passed to predict to prevent arbitrary names being generated.

@ablaom ablaom merged commit 2172e81 into dev Nov 23, 2025
4 checks passed
@ablaom ablaom mentioned this pull request Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants