欢迎回到充满信心的分析。在本系列中,我正在探索现代数据分析成功的关键:验证。在第一篇和第二篇文章中,我们讨论了泛化性,并了解了如何构建不可泛化的有问题的模型。在这篇文章中,我们继续对反应配方进行案例研究,并介绍抑制验证作为构建您可以信任的模型的简单工具。
请记住,在本案例研究中,我们正在研究制造高价值化学产品的配方 [1]。成分选择有 4,608 种可能的变化(4 种亲电子试剂 x 3 种亲核试剂 x 12 种配体 x 8 种碱基 x 4 种溶剂)。我们希望使用仅 150 种可能的食谱中的数据来构建模型来预测任何食谱的产量并找到成分的最佳组合。
我们上次构建的分区模型乍一看看起来很棒,R 方为 0.985,实际与预测图显示与数据非常吻合。但随后我们研究了模型预测与训练数据中未包含的所有 4,458 种食谱的实际产量的比较情况。该模型预测几种食谱的产量接近 100%,而实际上产量接近 0!
Actual versus Predicted plots for the data that was used to train the model (left) and the data for all the other recipes that were not used to train the model (right). This is an example of an "overfit" model that does not generalize.Actual versus Predicted plots for the data that was used to train the model (left) and the data for all the other recipes that were not used to train the model (right). This is an example of an "overfit" model that does not generalize.Actual versus Predicted plots for the data that was used to train the model (left) and the data for all the other recipes that were not used to train the model (right). This is an example of an "overfit" model that does not generalize.用于训练模型的数据(左)和未用于训练模型的所有其他配方的数据(右)的实际与预测图。这是一个无法概括的“过度拟合”模型的示例。
我们如何避免构建在训练数据上看起来不错的模型,却发现在对未见过的数据进行测试时它们不能泛化?我们如何确保我们的模型不会不必要地复杂?
您可能想到的一个想法是在构建过程的每个步骤中根据看不见的数据验证模型。我们本可以在决策树中的每次分割后停下来检查未用于训练模型的 4,458 个配方的实际与预测(以及 R 方)。我们可以选择最佳模型作为最适合未见过的数据的模型。我们也会知道我们可以期望它的表现如何。
当然,这是在人为的情况下。如果我们拥有所有可能食谱的数据,我们就不会保留大部分数据来验证模型。我们可以使用相同的想法,但仅利用 150 个食谱的数据吗?
介绍...制作验证列
是的,有一个工具可以做到这一点。 JMP Pro 中的“创建验证列”将标记数据表中要保留的部分行,并在模型构建过程的每个步骤中用作验证。我们将在后面的文章中探讨各种有用的选项,但对于这个示例,我们将保持简单并坚持默认值。
The Make Validation Column tool in JMP Pro (Analyze > Predictive Modeling). In this example, we stick with the defaults to make a Random Validation Column and click OK.The Make Validation Column tool in JMP Pro (Analyze > Predictive Modeling). In this example, we stick with the defaults to make a Random Validation Column and click OK.The Make Validation Column tool in JMP Pro (Analyze > Predictive Modeling). In this example, we stick with the defaults to make a Random Validation Column and click OK.JMP Pro 中的“创建验证列”工具(分析 > 预测建模)。在此示例中,我们坚持使用默认值来创建随机验证列,然后单击“确定”。
我们将采用建议的 0.75/0.25训练/验证分开,这意味着 150 行数据中的 37 行将被保留进行验证。
The default 0.75/0.25 training/validation split in Make Validation Column. Enter “1234” as the Random Seed if you want to follow along in JMP Pro and get the same results.The default 0.75/0.25 training/validation split in Make Validation Column. Enter “1234” as the Random Seed if you want to follow along in JMP Pro and get the same results.The default 0.75/0.25 training/validation split in Make Validation Column. Enter “1234” as the Random Seed if you want to follow along in JMP Pro and get the same results.Make Validation Column 中默认的训练/验证分割为 0.75/0.25。如果您想在 JMP Pro 中进行操作并获得相同的结果,请输入“1234”作为随机种子。
现在,我们的数据表中有一个验证列,它标记了 37 行用于验证,其他行用于训练:
Validation column in our data table that marks 37 of the rows for validation and the others for trainingValidation column in our data table that marks 37 of the rows for validation and the others for trainingValidation column in our data table that marks 37 of the rows for validation and the others for training数据表中的验证列标记了 37 行用于验证,其他行用于训练
现在,让我们重复我们在第 2 篇文章中创建的分区模型,但进行了验证。这里的关键步骤是在启动分区时在验证角色中添加验证列。
Partition model with validationPartition model with validationPartition model with validation带验证的分区模型
第一次分割与我们未经验证的模型相同。但现在我们可以看到训练数据和验证数据的 R 方。验证数据的拟合度不如训练数据的拟合度好(R 方 = 0.133 与 0.224)。

我们可以点击 Go,算法将探索多个分割,然后修剪回具有最大验证 R 方的树,即最能预测我们保留的数据的模型。在这种情况下,验证 R 方(红色)在五次分割时达到峰值。除此之外,模型变得更加复杂,并且更好地拟合训练数据,但它过度拟合噪声,而不是找到泛化到未见数据的模式。我们甚至可以修剪回四个分割,因为验证 R 方是相同的并且模型更简单。

其他型号呢?
我们可以使用多种其他统计和机器学习模型类型。抑制验证的另一个优点是,它使我们能够快速构建和比较经过验证的模型,并找出性能最好的模型。 JMP Pro 中的模型筛选平台使这一切变得非常简单。在这种情况下,我们发现提升树模型具有最高的验证 R 方:
Model Screening report showing the Boosted Tree has a slightly better Validation RSquare than the Decision Tree and the other statistical and machine learning methods.Model Screening report showing the Boosted Tree has a slightly better Validation RSquare than the Decision Tree and the other statistical and machine learning methods.Model Screening report showing the Boosted Tree has a slightly better Validation RSquare than the Decision Tree and the other statistical and machine learning methods.模型筛选报告显示,提升树的验证 R 方比决策树和其他统计和机器学习方法稍好。
现在,当我们查看此 Booted Tree 模型的表现时,我们发现未用于训练或验证模型的 4,458 个配方的预测与实际产量之间有更好的一致性:

了解更多:
[1] 数据来自Perera D、Tucker JW、Brahmbhatt S、Helal CJ、Chong A、Farrell W、Richardson P、Sach NW。用于自动化纳摩尔级反应筛选和微摩尔级流动合成的平台。科学。 2018 年 1 月 26 日;359(6374):429-434。 doi:10.1126/science.aap9112。 PMID:29371464。采样数据集和完整数据集作为 JMP 数据表附加。
很好的解释菲尔! 我刚刚作为 Arla Foods 的第一人获得从 8 月份开始访问 PRO 版本的权限:D
真的很期待开始验证我构建的模型。
我有两个与您的帖子相关的后续问题:假设我已经使用应用程序创建了自定义 DoE 设计。 20-30 次运行。
模型的训练、验证和测试是否仍然有效,或者您是否需要运行 100 多次才能真正从中得到任何结果?
如果您随后开始在新的水平上增强相同的设计(测试相同的因素)? JMP 是否会再次将这些运行分配为训练和验证?
谢谢。
此致
克里斯蒂安·贝特尔森
嗨, @Steffen_Bugge 。
最初的计划是写更多帖子来探讨模型验证的其他主题。但是,我认为我现在没有时间研究这个问题。也许将来其他人可以接手。