⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demou2.m~

📁 SVM支持向量机 里面包含一个教程
💻 M~
字号:
% -disclaimer-disp(' This demo illustrates the idea of fixed size LS-SVM. ');disp(' The program consists of 2 steps. In the former, one ');disp(' constructs a reduced set of support vectors base on ');disp(' an apropriate criterion on the data. In this case');disp(' the measure ''kentropy'' is optimized.');disp(' ');disp(' In the latter step, one constructs the implicit mapping');disp(' to feature space based on the eigenvalue decomposition.');disp(' A parametric linear regression is executed on the mapped');disp(' data');disp(' ');disp(' To see the used cose, use the call');disp(' ');disp('>> type demo_fixedsize ');disp(' ');disp(' or ');disp(' ');disp('>> edit demo_fixedsize ');disp(' ');disp(' A dataset is constructed at first...');%% datasetclearclose allfigure;randn('state',0);nb = 10000x = sort(normrnd(0,2,nb,1));x0 = sort(normrnd(0,2,nb,1));%x=(-9.95:0.1:10)';%x0=(-9.95:0.05:10)';y0=(sin(pi.*x0+eps)./(pi.*x0+eps));y=(sin(pi.*x+eps)./(pi.*x+eps))+normrnd(0,0.05,size(x,1),1);disp(' The parameters are initialized...');%% initiate valueskernel = 'RBF_kernel'sigma2=.75gamma=1crit_old=-inf;Nc=15Xs=x(1:Nc,:);Ys=y(1:Nc,:);disp(' The optimal reduced set is constructed iteratively: ');%% iterate over data%tictv = 1;for tel=1:500,%length(x)       %  % new candidate set  %  Xsp=Xs; Ysp=Ys;  S=ceil(length(x)*rand(1));  Sc=ceil(Nc*rand(1));  Xs(Sc,:) = x(S,:);  Ys(Sc,:) = y(S);  Ncc=Nc;  %  % automaticly extract features and compute entropy  %  crit = kentropy(Xs,kernel, sigma2);    if crit <= crit_old,    crit = crit_old;    Xs=Xsp;    Ys=Ysp;  else    crit_old = crit;    %    % ridge regression        %    %[features,U,lam] = AFE(Xs,kernel, sigma2,x);    %[w,b,Yh] = ridgeregress(features,y,gamma,features);    %    % make-a-plot    %    plot(x,y,'*'); hold on    %plot(x,Yh,'r-')    plot(Xs,Ys,'go','Linewidth',7)    xlabel('X'); ylabel('Y');     title(['Approximation by fixed size LS-SVM based on maximal entropy: ' num2str(crit)]);    hold off;  drawnow       end    %  % validate  %  %Yh0 = AFE(Xs,kernel, sigma2,x0)*w + b;  %val(tv,2) = mse(Yh0-y0); tv=tv+1;  endtocdisp(' The parametric linear ridge regression is calculated:');%% ridge regression    %echo on;features = AFE(Xs,kernel, sigma2,x);    % Bayesian inference of the gamma[CostL3, gamma_optimal] = bay_rr(features,y,gamma,3);[w,b] = ridgeregress(features,y,gamma_optimal);Yh0 = AFE(Xs,kernel, sigma2,x0)*w+b;echo off;         %% make-a-plotplot(x,y,'*'); hold onplot(x0,Yh0,'r-')plot(Xs,Ys,'go','Linewidth',7)xlabel('X'); ylabel('Y'); title(['Approximation by fixed size LS-SVM based on maximal entropy: ' num2str(crit)]);hold off;  figure;plot(x0,Yh0,'r-')plot(Xs,Ys,'go','Linewidth',7)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -