资源简介
竞争性自适应重加权算法(CARS)是通过自适应重加权采样(ARS)技术选择出PLS模型中回归系数绝对值大的波长点,去掉权重小的波长点,利用交互验证选出RMSECV指最低的子集,可有效寻出最优变量组合。
代码片段和文件信息
function F=carspls(XyAKmethodnum)
%+++ CARS: Competitive Adaptive Reweighted Sampling method for variable selection.
%+++ X: The data matrix of size m x p
%+++ y: The reponse vector of size m x 1
%+++ A: the maximal principle to extract.
%+++ K: the group number for cross validation.
%+++ num: the number of Monte Carlo Sampling runs.
%+++ method: pretreatment method.
%+++ Hongdong Li Dec.15 2008.
%+++ Advisor: Yizeng Liang yizeng_liang@263.net
%+++ lhdcsu@gmail.com
%+++ Ref: Hongdong Li Yizeng Liang Qingsong Xu Dongsheng Cao Key
% wavelengths screening using competitive adaptive reweighted sampling
% method for multivariate calibration Anal Chim Acta 2009 648(1):77-84
tic;
%+++ Initial settings.
if nargin<6;num=50;end;
if nargin<5;method=‘center‘;end;
if nargin<4;K=5;end;
if nargin<3;A=2;end;
%+++ Initial settings.
[MxNx]=size(X);
A=min([Mx Nx A]);
index=1:Nx;
ratio=0.9;
r0=1;
r1=2/Nx;
Vsel=1:Nx;
Q=floor(Mx*ratio);
W=zeros(Nxnum);
Ratio=zeros(1num);
%+++ Parameter of exponentially decreasing function.
b=log(r0/r1)/(num-1); a=r0*exp(b);
%+++ Main Loop
for iter=1:num
perm=randperm(Mx);
Xcal=X(perm(1:Q):); ycal=y(perm(1:Q)); %+++ Monte-Carlo Sampling.
PLS=pls(Xcal(:Vsel)ycalAmethod); %+++ PLS model
w=zeros(Nx1);coef=PLS.coef_origin(1:end-1end);
w(Vsel)=coef;W(:iter)=w;
w=abs(w); %+++ weights
[wsindexw]=sort(-w); %+++ sort weights
ratio=a*exp(-b*(iter+1)); %+++ Ratio of retained variables.
Ratio(iter)=ratio;
K=round(Nx*ratio);
w(indexw(K+1:end))=0; %+++ Eliminate some variables with small coefficients.
Vsel=weightsampling_in(w); %+++ Reweighted Sampling from the pool of retained variables.
Vsel=unique(Vsel);
fprintf(‘The %dth variable sampling finished.\n‘iter); %+++ Screen output.
end
%+++ Cross-Validation to choose an optimal subset;
RMSEP=zeros(1num);
Q2_max=zeros(1num);
Rpc=zeros(1num);
for i=1:num
vsel=find(W(:i)~=0);
CV=plscvfold(X(:vsel)yAKmethod0);
RMSEP(i)=CV.RMSECV;
Q2_max(i)=CV.Q2_max;
Rpc(i)=CV.optPC;
fprintf(‘The %d/%dth subset finished.\n‘inum);
end
[RminindexOPT]=min(RMSEP);
Q2_max=max(Q2_max);
%+++ save results;
time=toc;
%+++ output
F.W=W;
F.time=time;
F.cv=RMSEP;
F.Q2_max=Q2_max;
F.minRMSECV=Rmin;
F.iterOPT=indexOPT;
F.optPC=Rpc(indexOPT);
Ft.ratio=Ratio;
F.vsel=find(W(:indexOPT)~=0)‘;
function sel=weightsampling_in(w)
%Bootstrap sampling
%2007.9.6H.D. Li.
w=w/sum(w);
N1=length(w);
min_sec(1)=0; max_sec(1)=w(1);
for j=2:N1
max_sec(j)=sum(w(1:j));
min_sec(j)=sum(w(1:j-1));
end
% figure;plot(max_sec‘r‘);hold on;plot(min_sec);
for i=1:N1
bb=rand(1);
i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3383 2012-03-23 20:22 cars\carspls.m
文件 49218 2012-03-23 20:22 cars\CARS_manual.pdf
文件 920 2012-03-23 20:22 cars\classplot2.m
文件 608872 2017-07-07 15:09 cars\corn_m51.mat
文件 624151 2017-07-07 15:20 cars\corn_m52.mat
文件 288 2012-03-23 20:22 cars\csvd奇异值分解.m
文件 506 2012-03-23 20:22 cars\example_nir.m
文件 465 2012-03-23 20:22 cars\expred1.m
文件 736 2012-03-23 20:22 cars\expred2.m
文件 812 2012-03-23 20:22 cars\ks.m
文件 46264 2012-03-23 20:22 cars\LOGO_CARS.JPG
文件 966 2012-03-23 20:22 cars\lsreg.m
文件 1132 2012-03-23 20:22 cars\Manne_bi.m
文件 2983 2012-03-23 20:22 cars\mcs.m
文件 1217 2012-03-23 20:22 cars\mcuvepls.m
文件 976 2012-03-23 20:22 cars\mwpls.m
文件 3013 2012-03-23 20:22 cars\oscplscv.m
文件 835 2012-03-23 20:22 cars\plotcars.m
文件 592 2012-03-23 20:22 cars\plotmcs.m
文件 1953 2012-03-23 20:22 cars\pls.m
文件 2639 2012-03-23 20:22 cars\plscvfold.m
文件 1955 2012-03-23 20:22 cars\plsdcv.m
文件 2977 2012-03-23 20:22 cars\plsmccv.m
文件 1734 2012-03-23 20:22 cars\plsnipals.m
文件 2179 2012-03-23 20:22 cars\plsrdcv.m
文件 4180 2012-03-23 20:22 cars\plssim.m
文件 342 2012-03-23 20:22 cars\plsval.m
文件 1788 2012-03-23 20:22 cars\pls_nipals.m
文件 739 2012-03-23 20:22 cars\pretreat.m
文件 2944 2012-03-23 20:22 cars\scarspls.m
............此处省略11个文件信息
相关资源
- Carsim软件入门与精通PDF
- CarSim Training2—— 参数详解.ppt
- CarSim软件入门与精通.PDF
- carsim路径跟踪仿真视频
- CarSim Training参数详解
- Robot Ethics 2.0 From Autonomous Cars to Artif
- Unity3D汽车模型集合 Cars and Trucks Coll
- 民航acars资料整理
- 二手车小程序weixinmao_cars2.7全开源版
- carsim 轮胎模型
- 车牌图片集(237幅车牌照片).zip
- Machine Vision Algorithms and Applications 2nd
- 汽车行驶工况构建2019 D题.zip
- carsim教学文档
- CARSIM悬架和轮胎设置
- Carsim整车建模参数
- ACARS报文学习
- Carsim_LKA.par
评论
共有 条评论