← Back to Classic ML Mind Map
📊 Classic MLID: timeseries-cv

Time-Series Cross-Validation

时序交叉验证
🎯Core Definition
Time-series data cannot use random K-Fold; walk-forward (rolling-window) validation must be used instead: the training set contains only past time steps and the validation set is the immediately following future window — step 1 trains on [0,t][0, t] and validates on [t,t+h][t, t+h], step 2 rolls to train on [0,t+s][0, t+s] and validate on [t+s,t+s+h][t+s, t+s+h], and so on until the data is covered. The iron rule is no future information: any preprocessing computed with future statistics (means, targets, global normalization parameters) causes temporal leakage and inflates validation scores. For hyperparameter tuning, nested CV is used: an outer rolling loop for model evaluation and an inner loop for hyperparameter search, avoiding selection bias.
💡Use Cases
forecasting stocks/sales/traffic, risk control and recommendation — anything with timestamps; interviews ask “how to CV time series”, “why random K-Fold overestimates”, and “which future information must be blocked”.
⚡Key Problems Solved
random K-Fold mixes future samples into training so the model “peeks” into the future, inflating CV scores that collapse in production; walk-forward mimics the real online setting (every step predicts using only history) and gives an honest generalization estimate — it sacrifices some training data (early windows are small) in exchange for temporal integrity that matches deployment.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Time-Series Cross-Validation.
Use Cases
In production engineering, what are the primary use cases for Time-Series Cross-Validation and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Why does random K-Fold fail on time series? Trace the concrete leakage path (e.g. predicting t+1 with samples from t+1 onward)?
2
Describe the walk-forward rolling-window procedure: training span, validation span and step size for step k?
3
How to normalize, impute and target-encode in time-series modeling without leakage (history-only statistics)?
4
What is nested CV? What does each loop do, and which bias does it fix?
5
How does walk-forward differ from plain K-Fold in bias-variance and cost? When is the data loss acceptable?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "Time-Series Cross-Validation"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardK-Fold Cross-ValidationNext Card →Class Imbalance

🔗 More Classic ML Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/ML/card/timeseries-cv
中文速览与面试要点

时序交叉验证 (Time-Series Cross-Validation)

定义: 时序数据不能随机 K-Fold,必须用 walk-forward(前向验证 / 滚动窗口): 训练集只包含过去时刻,验证集是紧随其后的未来窗口——第 1 步用 [0, t] 训练、[t, t+h] 验证,第 2 步滚动到 [0, t+s] 训练、[t+s, t+s+h] 验证,如此滚动直到覆盖全部数据。核心铁律是禁止未来信息: 任何用未来时刻统计量(均值、目标值、全局归一化参数)计算的预处理都会造成时序泄漏,使验证分数虚高。若要调参还可用嵌套 CV(nested CV): 外层滚动窗口做模型评估、内层窗口做超参数搜索,避免选择偏差。 使用场景: 股票/销量/流量预测、风控与推荐等一切带时间戳的建模; 面试常问“时序数据怎么做交叉验证”“为什么随机 K-Fold 会高估性能”“预测时有哪些未来信息要防”。 解决的问题: 随机 K-Fold 切分会把未来样本混进训练集,模型“偷看”未来后 CV 分数虚高,上线时性能断崖式下降; walk-forward 精确模拟真实在线环境(每一步只依据历史做出预测),给出诚实的泛化估计——它牺牲了部分训练数据量(早期窗口数据少),换取与线上一致的时间顺序完整性。

核心要点

  • 为什么随机 K-Fold 在时序数据上失效? 具体泄漏路径是什么(举例: 预测 t+1 用了 t+1 及之后的样本)?
  • 画/描述 walk-forward 滚动窗口流程: 第 k 步训练区间、验证区间、滚动步长如何选择?
  • 归一化、缺失值填充、目标编码在时序建模中怎么处理才不泄漏(必须只用历史窗口统计)?
  • 嵌套 CV(nested CV)是什么? 外层内层各做什么, 解决什么偏差?
  • walk-forward 与常规 K-Fold 在偏差-方差与计算成本上的差异? 什么情况下损失可接受?