在我们之前的两篇博文中,Jeremy Ash ( @杰里米阿什JMP )我展示了联合管理计划通过分析 Martens 等人的流行光谱数据集来进行光谱分析和可视化功能。 1我们展示了可视化光谱数据的不同方法和一些预处理步骤这使我们能够显着提高数据的信噪比,以便进一步分析和建模。
在博客系列的第三部分中,我们演示了在 JMP 中对光谱数据进行建模的几种方法。偏最小二乘 (PLS) 是分析光谱数据最常用的工具,PLS 可以使用 JMP 和JMP专业版。 JMP Pro 还提供弹性网络惩罚回归、神经网络建模和高级决策树方法(如 Bootstrap Forest)。
Bootstrap Forest 和弹性网络技术可以快速轻松地找到单个化合物的最重要波长以及定义混合物中成分的波长。 这些建模技术可以与原始数据或处理后的数据一起使用。 在这篇文章中,杰里米和我展示了原始数据建模与预处理数据建模之间的差异,以显示预处理后预测能力的整体改进。 为了清楚地说明方法的整体比较,使用相同的两级验证列和 20% 的数据作为所有分析的验证集。
建模方法
偏最小二乘法
偏最小二乘法是分析光谱的标准方法。 PLS 可处理宽数据和高数据,尤其擅长处理高度相关的因素。 这种能力对光谱来说是个好兆头,因为光谱数据通常具有高度相关的吸光度,这导致每个连续的波长都依赖于紧邻其之前的一个波长。 由于这种依赖性,PLS 通常用于分析原始光谱数据,并取得非常好的结果。 如上所述,预处理足以改进生成的预测模型,足以保证投入时间和精力来预处理数据。 请记住,样本数据是一组麸质和淀粉的混合物,就 PLS 而言,它在开发模型方面做得非常好,该模型可以很好地预测任何未来样本的麸质和淀粉比率。
由于之前的主成分分析使用两个主成分,因此 PLS 模型是用两个潜在因素构建的。 另外,问2除了两个因素之外,效果并没有多大改善,并且添加更多因素会使模型解释更加困难。
Figure 1. Partial Least Squares model set up and output.Figure 1. Partial Least Squares model set up and output.Figure 1. Partial Least Squares model set up and output.Figure 1. Partial Least Squares model set up and output.Figure 1. Partial Least Squares model set up and output.图1。 偏最小二乘模型建立和输出。
Figure 1. Partial Least Squares model set up and output.Figure 1. Partial Least Squares model set up and output.Figure 1. Partial Least Squares model set up and output.Figure 1. Partial Least Squares model set up and output.Figure 1. Partial Least Squares model set up and output.图1。 偏最小二乘模型建立和输出。
Figure 2. Partial Least Squares model with Raw data.Figure 2. Partial Least Squares model with Raw data.Figure 2. Partial Least Squares model with Raw data.Figure 2. Partial Least Squares model with Raw data.Figure 2. Partial Least Squares model with Raw data.图 2. 使用原始数据的偏最小二乘模型。
Figure 3. Partial Least Squares model with Pre-Processed data.Figure 3. Partial Least Squares model with Pre-Processed data.Figure 3. Partial Least Squares model with Pre-Processed data.Figure 3. Partial Least Squares model with Pre-Processed data.Figure 3. Partial Least Squares model with Pre-Processed data.图 3. 具有预处理数据的偏最小二乘模型。
下面是两个 PLS 模型的实际与预测图的比较。 左边的是原始数据,右边的是使用预处理后的数据。 正如您所看到的,使用预处理数据的模型有了显着的改进。
Figure 4. Partial Least Squares model comparison with Raw and Pre-Processed data.Figure 4. Partial Least Squares model comparison with Raw and Pre-Processed data.Figure 4. Partial Least Squares model comparison with Raw and Pre-Processed data.Figure 4. Partial Least Squares model comparison with Raw and Pre-Processed data.Figure 4. Partial Least Squares model comparison with Raw and Pre-Processed data.图 4. 偏最小二乘模型与原始数据和预处理数据的比较。
广义回归(Gen Reg)
广义回归技术见于JMP专业版。 Gen Reg 至少为您提供了普通最小二乘法无法提供的两个功能。 一是使用 Gen Reg,您的数据不必呈正态分布。 您可以选择许多不同类型的发行版。 另一个区别是 Gen Reg 包含惩罚回归技术,并且它可以很好地处理高度相关的数据。 Gen Reg 提供 Ridge、Lasso 和 Elastic Net。 Elastic Net 是对光谱数据建模的一个很好的折衷方案,因为您可以调整 Elastic Net Alpha (ENA) 惩罚,通过拒绝许多对模型重要的高度相关因素来防止模型拟合不足。 使用默认值 0.99 ENA 来构建初始模型。 该模型似乎相当稀疏并且可能欠拟合。 Gen Reg 中的高级选项用于扫描 alpha 值的范围,以查看是否有更好的模型。 该扫描使用 0.55 的 ENA 值提供了更好的拟合。 您可以在下面的解决方案路径中看到两个 ENA 值的拟合差异。

Figure 5 – Elastic Net solution paths for Raw data.Figure 5 – Elastic Net solution paths for Raw data.Figure 5 – Elastic Net solution paths for Raw data.Figure 5 – Elastic Net solution paths for Raw data.Figure 5 – Elastic Net solution paths for Raw data.图 5 – 原始数据的 Elastic Net 解决方案路径。
Figure 6 - Fit Statistics for Gen Reg with Raw Data.Figure 6 - Fit Statistics for Gen Reg with Raw Data.Figure 6 - Fit Statistics for Gen Reg with Raw Data.Figure 6 - Fit Statistics for Gen Reg with Raw Data.Figure 6 - Fit Statistics for Gen Reg with Raw Data.图 6 - Gen Reg 与原始数据的拟合统计数据。

Figure 7 - Elastic Net solution paths for Pre-Processed data.Figure 7 - Elastic Net solution paths for Pre-Processed data.Figure 7 - Elastic Net solution paths for Pre-Processed data.Figure 7 - Elastic Net solution paths for Pre-Processed data.Figure 7 - Elastic Net solution paths for Pre-Processed data.图 7 - 预处理数据的 Elastic Net 解决方案路径。
Figure 8 - Fit Statistics for Gen Reg with Pre-Processed Data.Figure 8 - Fit Statistics for Gen Reg with Pre-Processed Data.Figure 8 - Fit Statistics for Gen Reg with Pre-Processed Data.Figure 8 - Fit Statistics for Gen Reg with Pre-Processed Data.Figure 8 - Fit Statistics for Gen Reg with Pre-Processed Data.图 8 - 使用预处理数据拟合 Gen Reg 的统计数据。
无需详细说明,当弹性网 Alpha (ENA) 为 0.99 时,原始数据的拟合使用 10 个波长;当 ENA 为 0.55 时,原始数据的拟合使用 37 个波长。
预处理后的数据具有显着不同的结果。 再次使用 Elastic Net,使用 0.99 的 ENA 发现了 22 个有效波长,使用 0.55 的 ENA 发现了 53 个有效波长。 虽然 ENA 为 0.55 时识别出大量(37 和 53 个)重要波长,但这两个结果都大大低于 PLS 模型。 检查两组模型的拟合统计数据表明,预处理的数据具有更好的整体预测模型。 但是,如果您仅使用原始数据,您仍然能够得出相当好的预测模型。
Figure 9 – Model comparison for Gen Reg with Raw and Pre-Processed Data.Figure 9 – Model comparison for Gen Reg with Raw and Pre-Processed Data.Figure 9 – Model comparison for Gen Reg with Raw and Pre-Processed Data.Figure 9 – Model comparison for Gen Reg with Raw and Pre-Processed Data.Figure 9 – Model comparison for Gen Reg with Raw and Pre-Processed Data.图 9 – Gen Reg 与原始数据和预处理数据的模型比较。
使用处理后的数据对 PLS 和 ELN 模型进行比较表明,基于 R 的 ELN 模型仅稍好一些2 。然而,ELN 模型更简单且更容易解释。
Figure 10 – Comparison of PLS and ELN modeling techniques for processed data.Figure 10 – Comparison of PLS and ELN modeling techniques for processed data.Figure 10 – Comparison of PLS and ELN modeling techniques for processed data.Figure 10 – Comparison of PLS and ELN modeling techniques for processed data.Figure 10 – Comparison of PLS and ELN modeling techniques for processed data.图 10 – PLS 和 ELN 建模技术处理数据的比较。
这是否意味着您应该使用 Elastic Net 模型进行所有频谱分析? 您应该将其视为可行的候选者,但这实际上取决于您拥有哪些可用的建模平台以及除了预测性能之外模型的可解释性是否是理想的。
更多建模选项
神经网络模型
出于演示目的,您还可以使用神经网络模型,在本例中,神经网络模型显示出非常好的拟合效果,但模型非常复杂。
然而,JMP 中的预测刻画器使用户能够解释最复杂的非线性模型。 当所有波长都用于预测时,Profiler 可能会让人不知所措。 为了使神经网络模型更简单,您可以在模型对话框中提供使用 Gen Reg 选择的波长。
Figure 11 – Comparison of Neural Net fits for raw and pre-processed data.Figure 11 – Comparison of Neural Net fits for raw and pre-processed data.Figure 11 – Comparison of Neural Net fits for raw and pre-processed data.Figure 11 – Comparison of Neural Net fits for raw and pre-processed data.Figure 11 – Comparison of Neural Net fits for raw and pre-processed data.图 11 – 原始数据和预处理数据的神经网络拟合比较。
在这两种情况下,数据均采用一个隐藏层和三个具有双曲正切激活函数的节点进行拟合,并使用固定的 20% 验证列进行交叉验证。
引导森林
使用 Bootstrap Forest 方法可以给出一组给定光谱的最重要的波长。 这也清楚地表明预处理可以提供更好的模型。 差异基于验证 R 2对于每个数据集。 验证R 2原始数据的验证率为 0.805,处理后的数据的验证 R 2是 0.987。 下面的模型使用固定 20% 的数据作为验证集进行拟合,以避免随机选择验证集。
Figure 12 – Comparison of Bootstrap Forest fits for Raw and Pre-Processed data.Figure 12 – Comparison of Bootstrap Forest fits for Raw and Pre-Processed data.Figure 12 – Comparison of Bootstrap Forest fits for Raw and Pre-Processed data.Figure 12 – Comparison of Bootstrap Forest fits for Raw and Pre-Processed data.Figure 12 – Comparison of Bootstrap Forest fits for Raw and Pre-Processed data.图 12 – 原始数据和预处理数据的 Bootstrap Forest 拟合比较。
支持向量回归
JMP Pro 中还提供支持向量回归 (SVR) 建模,它是分析光谱数据的另一个不错的选择。 SVR 是一种强大且灵活的基于边界的机器学习算法,用于构建连续响应的预测模型。 就我们的数据集而言,SVR 在分析处理后的数据时也显示出显着的改进。
Figure 13 - Comparison of SVR model fits for Raw and Pre-Processed data.Figure 13 - Comparison of SVR model fits for Raw and Pre-Processed data.Figure 13 - Comparison of SVR model fits for Raw and Pre-Processed data.Figure 13 - Comparison of SVR model fits for Raw and Pre-Processed data.Figure 13 - Comparison of SVR model fits for Raw and Pre-Processed data.图 13 - SVR 模型对原始数据和预处理数据的拟合比较。
JMP 和 JMP Pro 中还有更多建模技术可用于对光谱数据进行建模,因此,如果您没有看到想要使用或已经使用过的建模技术,请告知我们,我们将确保在其中介绍该技术未来的博客文章。
1)“通过扩展乘法信号校正分离光散射和光吸光度。 粉末混合物近红外透射分析的应用”分析化学2003年2月1日;75(3):394-404