Stacking

To ensure code in this tutorial runs as shown, download the tutorial project folder and follow these instructions.

If you have questions or suggestions about this tutorial, please open an issue here.

An advanced illustration of learning networks.

In stacking one blends the predictions of different regressors or classifiers to gain, in some cases, better performance than naive averaging or majority vote. The gains may small, their statistical significance in doubt, and the approach is computationally intensive. Nevertheless, stacking has been used successfully by teams in data science science competitions.

For routine stacking tasks the MLJ user should use the Stack model documented here. Internally, Stack is implemented using MLJ's learning networks feature, and the purpose of this tutorial give an advanced illustration of MLJ learning networks by presenting a simplified version of this implementation. Familiarity with model stacking is not essential, but we assume the reader is already familiar with learning network basics, as illustrated in the Learning networks section of the MLJ manual. The "Ensembles (learning networks)" tutorial also gives a simple illustration.

Specifically, we build a two-model stack, first as an MLJ learning network, and then as an "exported" stand-alone composite model type MyTwoStack.

As we shall see, as a new stand-alone model type, we can apply the usual meta-algorithms, such as performance evaluation and tuning, to MyTwoStack.