xgboost/cv-shuffled-time-series
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| XGBoost | warning | none, edit by hand | All versions |
xgboost.cv defaults to shuffle=True. On time-ordered data, random shuffling lets future observations leak into training folds (on a 200-step random walk, shuffle=True reported RMSE 0.507 against 0.623 with shuffle=False).
cv_res = xgb.cv(params, dtrain, num_boost_round=50, nfold=4)cv_res = xgb.cv(params, dtrain, num_boost_round=50, folds=list(TimeSeriesSplit(n_splits=4).split(X)))What the rule reports
Section titled “What the rule reports”Calls to xgboost.cv omitting folds= and shuffle=False in a module that imports or uses a forward time-series splitter (TimeSeriesSplit, TimeGapSplit, GroupTimeSeriesSplit, WalkForward, or CombinatorialPurgedCV).
How to fix it
Section titled “How to fix it”Pass forward folds= built from a time-series splitter, or set shuffle=False when contiguous ordered blocks are intended.
Diagnostic message
Section titled “Diagnostic message”xgboost.cv defaults to shuffle=True, mixing future rows into training folds on time-ordered data. Pass folds= from a forward time-series splitter (or shuffle=False).See all rules in the XGBoost pack.