JuliaAI / MLJBase.jl

Core functionality for the MLJ machine learning framework
MIT License
160 stars 45 forks source link

Add `TestOnly` resampling strategy? #976

Open ablaom opened 5 months ago

ablaom commented 5 months ago

Sometimes you have trained a supervised machine on some data and you want to evaluate on some holdout set without retraining. Using evaluate!(..., resamping=Holdout()) doesn't allow this, so you would need to manually predict, and apply each metric to the prediction and test target, which is inconvenient, especially if you are tracking multiple metrics.

The idea of a TestOnly reampling strategy is that evaluate!(mach, resampling=TestOnly(), rows=test, measures=...) automates this: we assume mach is already trained (or throw an exception) and just evaluate the specified measures on predictions on the test rows.

Implementation looks pretty simple: train_test_pairs(::TestOnly, rows) = [(Int[], rows),] (i.e. empty train) and in evaluate! an empty train set will suppress training.

(It would be very convenient and natural that specifying no resampling strategy would fall back to TestOnly(), as in:

fit!(mach, rows=train)
evaluate!(mach, rows=test, measure=l2)

but that would be technically breaking - the current fallback is CV(). )