概述
不调整最终测试数据有助于防止获得乐观的结果。正确的划分还考虑时间、共享人员或设备、类平衡以及实际部署人群。
深入探讨
A training set is used to fit model parameters from examples. A validation set informs choices made during development, such as feature selection, hyperparameters, architecture or a decision threshold. A test set is reserved to estimate performance after those choices have been made. Test results should not become a repeated tuning signal: after many adjustments made in response to the test score, that set is no longer untouched. There is no universally correct 80/10/10 or 60/20/20 ratio. The amount of data, rarity of outcomes, expected deployment shift and evaluation precision all matter. State the partition method and counts. For a rare classification target, stratification can keep class proportions reasonably represented across splits, but it does not by itself stop the same person's records from appearing in training and test. Group-aware splitting keeps related observations, such as visits from one patient or images from one device, together. For forecasting and other time-dependent tasks, randomly mixing future observations into training can make evaluation unrealistically easy. Use earlier data to predict later periods and consider a gap if labels or features overlap across the boundary. A split should also resemble the intended deployment setting: a model trained on one city and tested on the same city's nearby dates may not tell us how it will perform in a different region. Split before fitting preprocessing. Scalers, imputers, feature selectors and encoders must learn from training data in each development fold, then transform held-out data using those fitted settings. Scikit-learn's common-pitfalls guide calls out the error of computing a mean or selecting features on the full dataset before splitting. Pipelines can help keep these operations inside the correct fold. Preserve the random seed or time cutoff and document any exclusions. Report test uncertainty and subgroup results where important, and obtain a fresh independent evaluation set if the final test has already guided repeated revisions.
现实世界的实施
分类器安装在训练行上,其阈值根据验证行进行选择,最终分数在未触及的测试行上报告一次。
医院将一名患者的所有就诊都保存在同一分区中,因此重复就诊不会泄露与身份相关的信号。
需求预测员在前几个月进行训练,在后几个月进行测试,而不是重新安排所有日期。
团队对稀有标签样本进行分层,同时单独检查客户和时间段是否不交叉分区。
训练、验证和测试拆分的未来
随着数据集的联系越来越紧密,分割设计将变得比熟悉的百分比规则更加重要。评估越来越需要将家庭、患者、产品或地理集群放在一起并测试稍后的时间窗口。自动化管道可以强制执行边界,但团队仍必须决定哪些关系和部署转变很重要。未来的基准测试应该发布分区定义和泄漏检查以及分数。彻底的拆分并不能保证在人口或政策发生重大变化后的表现;它只会使所述测试更加可信。当模型被重新训练或改变用途时,持续的监控和新的抵制仍然是必要的。
付诸实践
为什么这很重要
- 更清晰的判决. 它可以帮助您将清晰的技术声明与营销语言分开。
- 成本与预算. 在花费金钱或时间之前,您可以提出更好的实施问题。
- 团队与工作流程. 具有共同理解的团队可以做出更好的产品、政策和学习决策。
留意
- 不同的团队可能会以不同的方式使用同一术语,因此请尽早定义范围。
- 基准测试可能看起来很强大,但实际性能却参差不齐。
- 忽视数据质量和评估计划通常会产生脆弱的结果。
后续步骤
- 从您需要的结果的简单语言定义开始。
- 在测试之前选择一种成功指标和一种失败条件。
- 使用代表性数据运行小型试点,而不是完善的演示集。
- 记录训练、验证和测试拆分在哪些方面有帮助以及在哪些方面更简单的方法更好。
不断探索
常见问题
什么是训练、验证和测试拆分?
训练、验证和测试分区在模型开发中发挥不同的作用:拟合参数、选择设计以及在选择后评估性能。不调整最终测试数据有助于防止获得乐观的结果。正确的划分还考虑时间、共享人员或设备、类平衡以及实际部署人群。
哪个分区通常应该提供用于拟合模型学习参数的示例?
训练数据用于拟合参数;验证和测试数据具有单独的选择和评估作用。
团队比较两种架构并选择概率阈值。哪个分区可以指导这些开发选择?
验证结果可以指导架构、超参数和阈值选择,同时保留最终测试以供以后估计。
为什么在模型选择确定后应谨慎使用最终测试集?
看到最终分数后的重复调整损害了该集合仍然独立于模型选择的主张。
数据集包含每个患者的多次就诊。哪种分割规则可以防止训练和测试之间的患者重叠?
分组感知拆分将相关观察结果保留在一起,因此一个患者的信息不会同时出现在两侧。
类别分层在分类分裂期间有助于保留什么?
分层的目的是保持阶级混合的代表性;它不会取代组或时间感知的分裂。