BaseForecastTransformer¶
yohou.base.BaseForecastTransformer
¶
Bases: _BaseTransformer
Base class for "forecast"-kind transformers over X_forecast frames.
fit and transform operate on a frame carrying "vintage_time" and
"time" index columns plus one or more feature columns. transform
preserves the two index columns on output and is stateless. A frame may
contain any number of vintages, including one (serving a single fresh
vintage) or none (an empty frame).
Attributes ¶
| Name | Type | Description |
|---|---|---|
feature_names_in_ |
list[str]
|
Names of the non-index columns seen during |
n_features_in_ |
int
|
Number of non-index columns seen during |
X_schema_ |
dict[str, DataType]
|
Feature column name to dtype mapping seen during |
See Also ¶
BaseActualTransformer: Base class for single-axis transformers.PerVintageActualTransformer: Lift a stateless actual transformer onto the vintage axis.
Source Code ¶
Source code in src/yohou/base/forecast_transformer.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
Methods ¶
min_vintage_rows
property
¶
Get the smallest vintage length that yields non-empty output.
A vintage shorter than this contributes no rows to transform output.
The default is 1: a transformer imposing no per-vintage minimum emits
output for any non-empty vintage. Implementations that consume rows within
a vintage, or that need a minimum number of rows to fit on, report their
own larger value.
This is deliberately not named observation_horizon. On
BaseActualTransformer
that name means a buffer carried between calls, sized so the next
transform has enough history behind it. A forecast transformer keeps
no such buffer: each vintage is self-contained, so this quantity is a
length requirement within one vintage rather than a memory depth across
calls.
A forecaster holding this transformer in its forecast_transformer slot
asserts forecasting_horizon >= min_vintage_rows at fit, because a
served vintage spans the forecasting horizon.
Returns ¶
| Type | Description |
|---|---|
int
|
Smallest vintage length yielding non-empty output, at least |
Raises ¶
| Type | Description |
|---|---|
NotFittedError
|
If the transformer has not been fitted yet. |
fit(X, y=None, **params)
¶
Fit the transformer to an X_forecast frame.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame
|
Input |
required |
y
|
DataFrame or None
|
Ignored. Present for API compatibility. |
None
|
**params
|
dict
|
Metadata to route to nested estimators. |
{}
|
Returns ¶
| Type | Description |
|---|---|
self
|
The fitted transformer instance. |
Raises ¶
| Type | Description |
|---|---|
ValueError
|
If |
Source Code ¶
Source code in src/yohou/base/forecast_transformer.py
transform(X, **params)
¶
Transform an X_forecast frame.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame
|
Input |
required |
**params
|
dict
|
Metadata to route to nested estimators. |
{}
|
Returns ¶
| Type | Description |
|---|---|
DataFrame
|
Transformed |
Raises ¶
| Type | Description |
|---|---|
NotFittedError
|
If the transformer has not been fitted yet. |
ValueError
|
If |