MeanSeasonalNaive¶
yohou.point.MeanSeasonalNaive
¶
Bases: BasePointForecaster
Seasonal naive forecaster that averages values across past seasons.
Instead of repeating only the last seasonal cycle (as SeasonalNaive
does), this forecaster averages the same position across n_seasons
past cycles. For example, with seasonality=7 and n_seasons=3,
the forecast for Monday is the mean of the last three observed Mondays.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
seasonality
|
int
|
The seasonal period length. For example, 7 for weekly seasonality in daily data, or 12 for monthly seasonality in monthly data. |
1
|
n_seasons
|
int
|
Number of past seasonal cycles to average over. When set to 1, the
behaviour is identical to |
1
|
panel_strategy
|
('global', multivariate)
|
How to handle panel data. See |
"global"
|
Attributes ¶
| Name | Type | Description |
|---|---|---|
interval_ |
str
|
Detected time interval of the training data. |
Examples ¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.point import MeanSeasonalNaive
>>>
>>> df = pl.DataFrame({
... "time": pl.datetime_range(
... start=datetime(2021, 1, 1),
... end=datetime(2021, 1, 12),
... interval="1d",
... eager=True,
... ),
... "value": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0],
... })
>>> forecaster = MeanSeasonalNaive(seasonality=3, n_seasons=2)
>>> _ = forecaster.fit(y=df, forecasting_horizon=3)
>>> y_pred = forecaster.predict(forecasting_horizon=3)
>>> len(y_pred)
3
Notes ¶
The forecaster stores the last seasonality * n_seasons observations.
These are reshaped into n_seasons groups of seasonality values
and the arithmetic mean is computed per position. The resulting pattern
is repeated cyclically to fill the forecasting horizon.
When n_seasons=1 the output is identical to SeasonalNaive and
the original column dtype is preserved. When n_seasons > 1 the
averaging produces Float64 columns.
See Also ¶
SeasonalNaive: Repeats the last seasonal cycle without averaging.PointReductionForecaster: ML-based point forecaster.
Source Code ¶
Source code in src/yohou/point/naive.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
Methods ¶
__sklearn_tags__()
¶
Get estimator tags.
Returns ¶
| Type | Description |
|---|---|
Tags
|
Estimator tags with yohou-specific attributes. |
Source Code ¶
Source code in src/yohou/point/naive.py
Tutorials¶
The following example notebooks use this component:
-
Naive Forecasters
Baseline forecasting (the first portion of the First Forecast tutorial) with SeasonalNaive using different seasonality periods, the observe/predict streaming workflow, and rolling evaluation patterns.