The doc at Model Stacking · MLJ shows how to stack models, but the base models are trained at the same time.
Is there a way to use already-trained models and only train the metalearner
?
The doc at Model Stacking · MLJ shows how to stack models, but the base models are trained at the same time.
Is there a way to use already-trained models and only train the metalearner
?
It doesn’t look like that’s an option, but in general you want to be very careful about that kind of thing. The metalearner should be trained on out-of-sample predictions.
What you could do is create a wrapper model type that wraps an already fitted model. The fit
method for the wrapper type would do nothing, and the predict
method would forward to the predict
method of the model that was wrapped.
I believe that if you create a transform (that only handles inference) rather than model, it should work.
If in doubt, check with @ablaom
No, there is no support for using pre-trained base models in stacking. As @CameronBieganek points out, it is not enough in a Stack to pre-train a base model on your full train set. In a stack, each base model is trained multiple times, once on each fold complement, as in cross-validation, to splice together the so-called out-of-sample prediction used to train train the metalearer - and then trained again on all the data for making inferences on new data.
Perhaps you can say a bit more about your use case. It may be you can roll your own solution using a learning network model.
my use case is precisely that I don’t have new data – I use cross-train and evaluation so that all my data are used in training but also evaluated in the end (on a model that has never seen this subset of data during training)