{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\nChaining Operations\n===================\n\nOften, a data processing pipeline looks like the following:\n\n#. Apply a blocked mean or median to the data\n#. Remove a trend from the blocked data\n#. Fit a spline to the residual of the trend\n#. Grid using the spline and restore the trend\n\nThe :class:`verde.Chain` class allows us to created gridders that perform multiple\noperations on data. Each step in the chain filters the input and passes the result along\nto the next step. For gridders and trend estimators, filtering means fitting the model\nand passing along the residuals (input data minus predicted data). When predicting data,\nthe predictions of each step are added together.\n\nOther operations, like :class:`verde.BlockReduce` and :class:`verde.BlockMean` change\nthe input data values and the coordinates but don't impact the predictions because they\ndon't implement the :meth:`~verde.base.BaseGridder.predict` method.\n\n
The :class:`~verde.Chain` class was inspired by the\n :class:`sklearn.pipeline.Pipeline` class, which doesn't serve our purposes because\n it only affects the feature matrix, not what we would call *data* (the target\n vector).