正交匹配追踪算法的近红外光谱定量分析
李四海1, 刘东玲2
1.甘肃中医药大学信息工程学院, 甘肃 兰州 730000
2.甘肃中医药大学药学院, 甘肃 兰州 730000

作者简介: 李四海, 1972年生, 甘肃中医药大学信息工程学院副教授 e-mail: lshroom@163.com

摘要

压缩感知(CS)是一种新兴的信号压缩和采样技术, 正交匹配追踪(OMP)是一种贪婪追踪算法, 广泛用于压缩感知领域中的稀疏信号重构。 针对近红外光谱信号高维小样本以及信号稀疏先验的特点, 为进一步提高小样本近红外光谱变量选择的灵活性和可靠性, 基于压缩感知理论, 提出了一种新颖的光谱变量选择方法正交匹配追踪变量选择(OMPBVS)。 OMPBVS算法通过对原始光谱信号的稀疏重构, 将绝大部分变量的回归系数压缩为0, 进而间接实现光谱变量选择。 具体过程为以光谱矩阵为传感矩阵, 预测变量为观测变量, 迭代地计算残差与原子的内积, 选择内积最大的原子, 在每一步迭代过程中将信号投影到由所有已经被选择原子张成的子空间上, 然后对所有被选择原子的系数进行更新, 使得产生的残差与已被选择的所有原子都正交, 其残差计算的实质是进行Gram-Schmidt正交化, 正交投影能够在保证信号重构精度的情况下减小迭代次数。 OMPBVS具有将光谱维度降低至样本大小规模的能力, 其变量选择能力与LASSO相当, 但与LASSO相比, 由于OMPBVS损失函数的优化方法是前向选择算法, 减少了迭代次数, 并且可以精确控制选择变量的数量。 分别在beer数据集和Wheat kernels数据集上进行变量选择实验, 比较PLS, MCUVE-PLS, CARS-PLS, WMSCVS, LASSOLarsCV和OMPBVS六种变量选择方法的性能。 其中beer数据集共60个样本, 采用Kennard Stone (KS)方法划分训练集样本36个, 测试集样本24个, 预测变量为Original extract concentration。 Wheat kernels数据集共523个样本, 训练集样本415个, 测试集样本108个, 预测值为蛋白质含量。 OMPBVS方法在beer数据集上选择变量个数、 RMSEC和RMSEP分别为2, 0.205 2和0.159 8, 在Wheat kernels数据集上选择变量个数、 RMSEC和RMSEP分别为9, 0.450 2和0.412 5, 其变量选择能力和模型性能均好于其他五种方法, 这说明OMPBVS是一种有效的近红外光谱变量选择和定量分析方法。 OMPBVS变量选择方法在小样本情况下具有良好的泛化能力, 能够减少选择变量的数量, 提高变量选择的稳健性。 此外, 基于SNV和MSC等光谱预处理方法, 能够在一定程度上减少选择变量的个数, 提高模型的可解释性。

关键词: 近红外光谱; 变量选择; 压缩感知; 偏最小二乘; 正交匹配追踪
中图分类号:TP391.4 文献标志码:A
Quantitative Analysis of Near Infrared Spectroscopy Based on Orthogonal Matching Pursuit Algorithm
LI Si-hai1, LIU Dong-ling2
1. College of Information Engineering, Gansu University of Chinese Medicine, Lanzhou 730000, China
2. School of Pharmacy, Gansu University of Chinese Medicine, Lanzhou 730000, China
Abstract

Compressed sensing (CS) is a new technology of signal compression and sampling. Orthogonal Matching Pursuit (OMP), a greedy tracking algorithm, is widely used in sparse signal reconstruction in the compressed sensing field. In connection with the characteristics of high-dimensional small samples of near-infrared spectra signals and sparse prior signals, a novel near-infrared spectra variable selection method named Orthogonal Matching Pursuit Based Variable Selection (OMPBVS) is proposed, based on the compressed sensing theory, to further improve the flexibility and reliability of near-infrared spectra variable selection. By sparse reconstruction of the original spectral signal, OMPBVS can compress the regression coefficient of most variables to zero, and then indirectly realize the selection of spectral variables. In the specific process, the spectral matrix is adopted as the sensing matrix, the predictive variable as the observation variable and iteratively calculated residual and the inner product of the atom, and the inner product of the largest atom is chosen. During each iteration, the signal is projected onto the subspace spanned by all selected atoms, and then the coefficients are updated for all the selected atoms, enabling the residual error and all the selected atoms to be orthogonal. With the residual calculation to be the essence of Grammar-Schmidt Orthogonalization, the orthogonal projection can reduce the number of iterations and ensure the accuracy of signal reconstruction. OMPBVS can reduce the spectral dimension to the sample size scale, and its variable selection capability is comparable to LASSO. However, compared with LASSO, the optimization method of OMPBVS loss function is a forward selection algorithm, which reduces the number of iterations and can precisely control the number of selected variables. Variable selection experiments were performed on the beer dataset and Wheat kernels dataset to compare the performance of six variable selection methods: PLS, MCUVE, CARS, WMSCVS, LASSOLarsCV, and OMPBVS. There were 60 samples in the beer dataset, 36 samples of the training set and 24 samples of the test set were divided by Kennard Stone (KS) method, and the prediction variable was Original extract concentration. The Wheat kernels data set consisted of 523 samples, 415 training samples, and 108 test samples. The predicted value was protein content. The OMPBVS method selects the number of variables, RMSEC and RMSEP from the beer dataset as 2, 0.205 2 and 0.159 8, respectively. When on the Wheat kernels data set, the number of selected variables, RMSEC and RMSEP were 9, 0.450 2, and 0.412 5, respectively, and the variable selection ability and model performance was better than the other five methods, indicating that OMPBVS is an effective NIR spectral variable selection and quantitative analysis method. OMPBVS variable selection method has good generalization ability in the case of small samples, which can reduce the number of selected variables and improve the robustness of variable selection. Besides, spectral preprocessing methods based on SNV and MSC can reduce the number of selected variables to a certain extent and improve the interpretability of the model.

Keyword: Near infrared spectroscopy; Variable selection; Compressed sensing; Partial Least squares; Orthogonal matching pursuit
引言

近红外光谱是一种简单、 快速、 低成本和无破坏性的新型分析检测方法, 广泛用于农林业、 食品、 石油化工、 药物设计及中医药等领域。 近红外光谱是高维小样本数据并且含有噪声和干扰信号, 为提高定量分析模型的预测能力和稳健性, 目前常用的方法有三种: 正则化、 特征抽取和特征选择[1]。 正则化方法包括LASSO回归、 岭回归和弹性网等, 其基本思想是在损失函数中分别添加l1范数、 l2范数和l12范数正则项, 对解空间进行约束, 将大部分光谱变量的回归系数压缩为0或较小值, 以达到降维和提高模型泛化能力的目的。 特征抽取方法包括PCA, PCR和PLS等, 其基本思想是在建立定量分析模型前将原始高维光谱空间变换至低维变量空间, 低维空间的变量通常是高维空间光谱变量的线性组合, 其主要缺点是模型的可解释性较差。 特征选择方法包括PLS-VIP, MCUVE-PLS, CARS-PLS, GA-iPLS, WMSCVS[2]和SPEA-LASSO[3]等, 这些方法通常根据RC, VIP, SR[4]和sMC[5]等光谱变量重要性测度或统计特征量, 从高维变量空间中找到若干个重要变量或最优的变量子集, 其优点是可以提高模型的预测能力和可解释性。

压缩感知(compressed sensing, CS)[6]是一种新的信号采样理论, 突破了香农采样定理对采样频率的限制, 通过信号的稀疏先验信息, 能够以比香农采样定理更少的稀疏信号精确恢复原始信号, 并且信号的采集和压缩同时完成。 CS理论实现了信息采集和处理技术的革命性突破, 受到研究者的广泛关注, 目前已在压缩型光谱成像[7]、 阵列信号处理、 磁共振成像、 DNA微阵列传感器等领域得到很好的应用。

由于近红外光谱信号具有稀疏先验特点, 因此通过对光谱信号的压缩, 利用正交匹配追踪等稀疏信号重构算法即可精确恢复原始光谱信号, 由于恢复出的光谱信号具有稀疏性, 因此可以间接实现光谱变量特征选择的目的。

基于CS理论, 提出一种新的光谱变量选择方法: 正交匹配追踪变量选择(orthogonal matching pursuit based variable selection, OMPBVS), 分别运用PLS, MCUVE-PLS, CARS-PLS, WMSCVS, LASSOLarsCV和OMPBVS六种方法对beer数据集和Wheat kernels数据集进行变量选择, 并对beer中的OEC和Wheat kernels中的蛋白质含量进行预测, 比较了不同变量选择方法的性能。

1 OMPBVS变量选择方法
1.1 压缩感知理论

对于N维的光谱信号xRN, 假设信号在N× N的变换基Ψ 下的稀疏度为S, 变换系数为θ , 则信号x可表示为[8, 9]

x=Ψθ(1)

构造满足约束等距性质的高斯随机矩阵Φ Μ × Ν 作为观测矩阵, 由Φ x可得到M个观测值

y=Φx=ΦΨθ=(2)

其中A为传感矩阵。 重构算法从M维测量值y求解稀疏系数θ 的估计值 θ˙, 进而通过 θ˙重构x。 当M< N时, (2)式有无穷多解, 但由于信号x在变换基Ψ 下具有稀疏度S, 则欠定方程组的求解问题可以转化为如式(3)的l0范数最优化问题

$\hat{\theta}=\underset{\theta}{\arg \min }\|y-\boldsymbol{\Phi} \boldsymbol{\Psi} \theta\|_{2}, \|\theta\|_{0}=S$ (3)

l0范数的稀疏重构问题是NP-hard问题, 目前主要通过贪婪算法求解, 包括匹配追踪(matching pursuit, MP)、 压缩感知匹配追踪(compressive sampling matching pursuit, CoSaMP)、 正交匹配追踪(orthogonal matching pursuit, OMP)等[10, 11]

1.2 正交匹配追踪变量选择(OMPBVS)

将近红外光谱矩阵作为传感矩阵A, 预测变量y作为观测变量, OMPBVS算法首先计算观测变量yA中所有光谱变量(原子)的内积, 选择内积最大的原子, 将信号投影到已选择原子张成的空间上, 并计算残差, 然后以残差作为新的观测变量迭代地选择新的原子, 直至满足给定的稀疏度要求。

正交匹配追踪变量选择算法(OMPBVS):

输入: 传感矩阵A, 观测变量y, 稀疏度S

输出: x的稀疏近似解x*

初始化: 残差r0=y, 原子索引集Λ 0=∅

t=1, 执行以下步骤:

(1)计算残差rt-1A中各列的内积u=< A, rt-1> , 内积最大值记为ut, 所在列为cj;

(2) 更新原子索引集: Λ t=Λ t-1∪ {ut}; 记录所有已选择的原子: At={At-1, cj};

(3) 最小二乘法求解如下问题:

argminxy-Atx, :xt* =(ATtAt)-1ATty

(4) 更新残差

rt=y-Atxt* =y-At(ATtAt)-1ATty

其中, At(ATtAt)-1ATt为正交投影变换矩阵;

(5) 令t=t+1, 重复步骤(1)— 步骤(4), 直至t> S时, 满足给定的稀疏度, 算法终止。

OMPBVS算法以长度为Nxt* 作为光谱变量的线性回归系数, 其中非零回归系数有S个, 其对应的变量即为选择的光谱变量。

2 结果与讨论
2.1 数据集及软件

正交匹配追踪算法变量选择实验在两个数据集上进行: beer数据集和Wheat kernels数据集。 beer数据集共60个样本, 使用Kennard Stone (KS)方法划分训练集和测试集, 其中训练集36个样本, 测试集24个样本, 波数范围为400~2 250 nm, 共926个波数点, 预测值为original extract concentration(OEC), 数据集下载地址为: http://www.mli.kvl.dk/foodtech/special/specials.htm。 Wheat kernels数据集共523个样本, 训练集和测试集样本数分别为415和108, 波数范围为850~1 048 nm, 共100个波数点, 预测值为蛋白质含量, 数据集下载地址为: http: //www.models.life.ku.dk/。 对Wheat kernels数据集进行2阶导数和SNV预处理, 窗口宽度为17, 多项式阶数为2。

软件平台为MATLAB R2018b、 Python 3.7及其机器学习库scikit-learn 0.22.1。

2.2 beer数据集实验结果及分析

使用OMPBVS方法对beer数据集进行变量选择, 最优变量个数通过scikit-learn中的OrthogonalMatchingPursuitCV确定, 选择准则为RMSECV最小。 结果如图1所示。

图1 beer数据集变量选择结果Fig.1 Wavelengths selection results with OMPBVS Algorithm on beer dataset

由图1可知, OMPBVS共选择2个变量: 1 184和1 326 nm, 均位于1 100~1 350 nm之间的有效信息区域, 这说明选择的波数具有较好的化学意义。 模型在训练集上的RMSEC=0.205 2, 在测试集上的RMSEP=0.159 8, 如图2所示。

图2 beer数据集预测结果Fig.2 Predicted value versus measured value for the beer dataset

分别使用PLS, MCUVE-PLS, CARS-PLS[12], WMSCVS, LASSOLarsCV[13]变量选择方法对beer数据集进行变量选择, 不同模型的参数设置及预测结果见表1。 MCUVE-PLS 和CARS-PLS预测性能相当, WMSCVS和LASSOLarsCV方法的RMSEC值较小, OMPBVS方法选择变量最少, RMSEP值最小, 其模型预测性能也与SBOSS方法[14]相当, 但选择变量个数更少。

表1 不同模型在两个数据集上的性能对比 Table 1 Summary of the performance indices of different models on two datasets
2.3 Wheat kernels数据集实验结果及分析

对Wheat kernels数据集分别使用6种变量选择方法, OMPBVS变量选择结果如图3所示。 选择的波数分别为884, 900, 912, 924, 956, 968, 986, 1 004和1 018 nm。 其中, 1 004和1 018 nm位于N— H基的二倍频峰1 010 nm附近, 且对应的回归系数分别为19.07和-27.14, 绝对值大于其余7个回归系数, 这说明选择的波数具有较好的化学意义。

图3 Wheat kernels数据集变量选择结果Fig.3 Wavelengths selection results with OMPBVS Algorithm on Wheat kernels dataset

使用OMPBVS选择的9个变量及其回归系数建立线性定量分析模型, 模型在训练集上的RMSEC=0.450 2, 在测试集上的RMSEP=0.412 5, 如图4所示。

图4 Wheat kernels数据集预测结果Fig.4 Predicted value versus measured value for the Wheat kernels dataset

图5给出了OMPBVS算法选择变量个数与模型预测能力之间的关系。 可以看出, 随着变量个数的增加, RMSEC和RMSEP都不断减小, 当变量个数为5时, RMSEP开始小于RMSEC值, 这也说明定量分析模型具有较好的泛化能力。

图5 Wheat kernels数据集变量个数对预测结果的影响Fig.5 Impact of the number of selected variables on the predicted results for Wheat kernels dataset

分别使用PLS, MCUVE-PLS, CARS-PLS, WMSCVS和LASSOLarsCV建立Wheat kernels中蛋白质含量的定量分析模型, 不同模型的参数设置及预测结果见表1

表1可知, 6种变量选择方法中, CARS-PLS和MCUVE-PLS选择变量数最多, 预测能力CARS-PLS优于MCUVE-PLS。 WMSCVS变量选择方法由于对重要变量进行了EMSC预处理, 故未再进行光谱2nd+SNV预处理, 与CARS-PLS和MCUVE-PLS方法相比, WMSCVS显著减少了变量选择数量, 获得了较好的预测性能。 OMPBVS选择变量较少, RMSEP值最小且小于KPLS方法[15]。 LASSOLarsCV选择变量数量和预测能力与OMPBVS相当, 显示了较强的变量选择能力。

3 结论

基于压缩感知中的稀疏信号重构理论, 提出了一种新的正交匹配追踪变量选择方法。 根据近红外光谱信号的稀疏先验特点, 通过对光谱信号的稀疏重构, 利用得到的稀疏回归系数可以实现对重要变量的选择, 其最优变量个数通过交叉验证方法得到。 在两个数据集上的实验结果表明, OMPBVS变量选择方法选择变量数量少于PLS, MCUVE-PLS, CARS-PLS和WMSCVS变量选择方法, 而预测性能有较大程度的提升, 其模型性能与LASSO相当, 但OMPBVS方法可以实现对选择变量个数的精确控制, 没有需要优化的正则化参数, 迭代速度快, 特别是在样本数量较少的情况下, 一定程度上能够减少变量选择的数量, 提高模型的预测能力和可解释性。

参考文献
[1] Yun Y H, Li H D, Deng B C, et al. Trends in Analytical Chemistry, 2019, 113: 102. [本文引用:1]
[2] Wu Y F, Peng S L, Xie Q, et al. Chemometrics and Intelligent Laboratory Systems, 2019, 185: 114. [本文引用:1]
[3] Zhang R Q, Zhang F Y, Chen W C, et al. Chemometrics and Intelligent Laboratory Systems, 2018, 175: 47. [本文引用:1]
[4] Kvalheim O M. Journal of Chemometrics, 2010, 24(7-8): 496. [本文引用:1]
[5] Afanador N L, Tran T N, Blanchet L, et al. Chemometrics and Intelligent Laboratory Systems, 2014, 139: 139. [本文引用:1]
[6] Donoho D L. IEEE Transactions on Information Theory, 2006, 52(4): 1289. [本文引用:1]
[7] BAI Lian-fa, WANG Xu, HAN Jing, et al(柏连发, 王旭, 韩静, ). Infrared and Laser Engineering(红外与激光工程), 2019, 48(6): 603001. [本文引用:1]
[8] DING Qian, HU Mao-hai(丁倩, 胡茂海). Infrared Technology(红外技术), 2019, 41(4): 72. [本文引用:1]
[9] GAO Yue, ZANG Ming-xiang, GUO Fu-ying(高悦, 臧明相, 郭馥英). Application Research of Computers(计算机应用研究), 2017, 34(12): 3672. [本文引用:1]
[10] Needell D, Vershynin R. IEEE Journal of Selected Topics in Signal Processing, 2010, 4(2): 310. [本文引用:1]
[11] Shi X S, Xing F Y, Guo Z H, et al. Neurocomputing, 2019, 349: 164. [本文引用:1]
[12] Li H D, Xu Q S, Liang Y Z. Chemometrics and Intelligent Laboratory Systems, 2018, 176: 34. [本文引用:1]
[13] Osborne M R, Presnell B, Turlach B A. IMA Journal of Numerical Analysis, 2000, 20(3): 389. [本文引用:1]
[14] Yan H, Song X Z, Tian K D, et al. Spectrochimica Acta Part A: Molecular and Biomolecular Spectroscopy, 2019, 210: 362. [本文引用:1]
[15] Huang X, Xia L. Chemometrics and Intelligent Laboratory Systems, 2017, 168: 107. [本文引用:1]