在我們之前的兩篇部落格文章中,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