• 大小: 4KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: Matlab
  • 标签: sg平滑  

资源简介

用于信号去噪,光谱去噪,数据是使用近红外光谱进行验证,可以使用

资源截图

代码片段和文件信息

clc;clear;close all
disp(‘原始数据,不同预处理方法进行处理的RMSECVRMSEP训练集及预测集的R‘)
load UV
cal    = calset(:1:600);
caltar = calsettar;
for columm  = 1:4;
    dataname   = ynames{columm};
    disp(dataname);      
   %----------------------------因子数的确定--------------------------------
   switch columm
    case 1
         maxrank = 8;
        
    case 2
         maxrank = 6;
         
    case 3
         maxrank = 7;
        
    case 4
         maxrank = 6;    
    end 
    [mn]                     = size(cal);
    %-----------------KS对数据划分,训练集2/3,预测集1/3---------------------
    [modeltest]                    = kenstone(calfloor(2/3*m));
    x_train                         = cal(model:);
    x_pred                          = cal(test:);
    y_train                         = caltar(modelcolumm);
    y_pred                          = caltar(testcolumm);
    [m_trainn_train]               = size(x_train);
    %-------------------------------PLS------------------------------------
    disp(‘偏最小二乘-PLS‘)
    b                               = simpls(x_trainy_trainmaxrank);
    c                               = x_pred*b(:maxrank);
    [c_trainvalpresses]            = loocv(x_trainy_trainmaxrank);
    disp(‘RMSECVRMSEP训练集及预测集的R‘);
    rmsecv_PLS                      = sqrt(valpresses./m_train);
    rmsep_PLS                       = rms(c-y_pred);
    r_train                         = corrcoef(c_trainy_train);
    r_train                         = r_train(12);
    r_PLS                           = corrcoef(cy_pred);
    r_PLS                           = r_PLS(12);
    disp([rmsecv_PLSrmsep_PLSr_trainr_PLS]);
    disp(‘回收率最大最小值‘);
    recovery_PLS                    = 100*c./y_pred;
    max_recovery_PLS(columm)        = max(recovery_PLS);
    min_recovery_PLS(columm)        = min(recovery_PLS);
    disp([max_recovery_PLS(columm)min_recovery_PLS(columm)]);
    clear b c c_train valpresses r_train 
    %-----------------------------

评论

共有 条评论