Back to models
Transformer

MiddleOutReconciler

Inverse transformUnequal length

Reconciliation using a middle-out approach.

This reconciliation strategy splits the hierarchy at a given level and applies a bottom-up strategy to the top part of the hierarchy and a topdown strategy to the bottom part of the hierarchy.

The parameter middle-level is determined by the level according to the hierarchy tree. For example, consider the following structure with four levels:

``` __total ├── B1 │ ├── C1 │ │ ├── D1 │ │ └── D2 │ └── C2 │ ├── D3 │ └── D4 └── B2

├── C3 │ ├── D5 │ └── D6

```

If middle_level is set to 0, then the hierarchy is split at the root node. If middle_level is set to 1, then the hierarchy is split at the first level below the root node, in this example, the nodes [B1, B2].

It is important to note that the height of this hierarchy tree don’t necessarily coincides with the number of levels in the pd.DataFrame index. For example, the following index has 3 levels, but the tree has 4 levels:

` __total, __total, __total B1, __total, __total B1, C1, __total ... B2, __total, __total B2, C3, __total ... `

Quickstart

python
from sktime.transformations.hierarchical.reconcile import MiddleOutReconciler

estimator = MiddleOutReconciler(middle_level: int, middle_bottom_reconciler: BaseTransformer=None)

Parameters(2)

middle_levelint
The level at which to split the hierarchy for reconciliation.
middle_bottom_reconcilerBaseTransformer
The transformer to use for each subtree below the middle-level totals.

Examples

>>> from sktime.transformations.hierarchical.reconcile import (
... MiddleOutReconciler)
>>> from sktime.utils._testing.hierarchical import _make_hierarchical
>>> from sktime.forecasting.naive import NaiveForecaster
>>> from sktime.transformations.hierarchical.aggregate import Aggregator
>>> y = _make_hierarchical (hierarchy_levels = (2, 2, 4))
>>> pipe = MiddleOutReconciler (middle_level = 1) * NaiveForecaster ()
>>> pipe = pipe. fit (y)
>>> y_pred = pipe. predict (fh = [1, 2, 3 ])