cross_val_predict¶
yohou.model_selection.cross_val_predict(forecaster, y, X_actual=None, forecasting_horizon=1, *, X_future=None, X_forecast=None, cv=5, predict_forecasting_horizon=None, predict_stride=None, coverage_rates=None, n_jobs=None, verbose=0, pre_dispatch='2*n_jobs', method='predict')
¶
Generate cross-validated predictions for each fold.
For each CV fold, the forecaster is fitted on the training data
and predictions are produced on the test data. Predictions from
all folds are concatenated into a single DataFrame with a
"split" column identifying the originating fold.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
forecaster
|
BaseForecaster
|
The forecaster to evaluate. |
required |
y
|
DataFrame
|
Target time series with a |
required |
X_actual
|
DataFrame or None
|
Actual feature observations with a |
None
|
forecasting_horizon
|
int
|
Number of time steps to forecast. |
1
|
X_future
|
DataFrame or None
|
Known future features with a |
None
|
X_forecast
|
DataFrame or None
|
External forecasts with |
None
|
cv
|
int, BaseSplitter, or None
|
Cross-validation splitting strategy. |
5
|
predict_forecasting_horizon
|
int or None
|
Override forecasting horizon for |
None
|
predict_stride
|
int or None
|
Override stride for |
None
|
coverage_rates
|
list of float or None
|
Coverage rates injected into |
None
|
n_jobs
|
int or None
|
Number of parallel jobs. |
None
|
verbose
|
int
|
Verbosity level. |
0
|
pre_dispatch
|
str or int
|
Controls pre-dispatched jobs for parallel execution. |
"2*n_jobs"
|
method
|
str
|
Prediction method: |
"predict"
|
Returns ¶
| Type | Description |
|---|---|
DataFrame
|
Concatenated predictions from all folds with an integer
|
Notes ¶
Unlike cross_validate and cross_val_score, there is no
error_score parameter: fitting and prediction errors always
raise rather than being replaced by a fallback value.
Source Code ¶
Source code in src/yohou/model_selection/validation.py
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 404 405 406 407 408 409 410 411 | |
Tutorials¶
The following example notebooks use this component:
-
Cross-Validation for Time Series
Evaluate forecasters with cross_val_score, cross_validate, and cross_val_predict using temporal splitters.