cross_val_score¶
yohou.model_selection.cross_val_score(forecaster, y, X_actual=None, forecasting_horizon=1, *, X_future=None, X_forecast=None, scoring, cv=5, predict_forecasting_horizon=None, predict_stride=None, n_jobs=None, verbose=0, pre_dispatch='2*n_jobs', error_score=np.nan)
¶
Evaluate a forecaster by cross-validation and return test scores.
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
|
scoring
|
BaseScorer
|
Single scorer used to evaluate predictions. Dicts of scorers
are rejected; use |
required |
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
|
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"
|
error_score
|
float or 'raise'
|
Value to assign if an error occurs during fitting or scoring.
If |
np.nan
|
Returns ¶
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns Scores from lower-is-better scorers (e.g. MAE, RMSE) are negated so that higher values always indicate better performance, following the sklearn sign convention. |
Source Code ¶
Source code in src/yohou/model_selection/validation.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 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 | |
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.