📄 svrplot.m
字号:
function [x,z]=svrplot(X,Y,ker,beta,bias,epsi,par);%This is a routine to plot 1D regression problem with SVM%% [x,z]=svrplot(X,Y,ker,beta,bias,e);%% Parameters: %% X: matrix of input vectors. Each row of x1 represents a d-dimensional vector. % The number of rows is the number of training samples.% Y: column vector of the targets values. Each row represent the taerget of each sample in X.% ker: the kernel to be employed. It has to be a string out of: 'linear', 'poly_h', 'poly_i' and 'rbf'.% Type help kernel for further information.% beta: the value of the alphas-alpha*. (the second output of irwls1.m or irwls3.m)% bias: Bias term. (the third output of irwls1.m or irwls3.m).% epsi: is the epsilon insensitive zone defined arround the regression estimate. % (The 5th input to irwls1.m or the 4th output of irwls3.m)% par: is the parameter of the used kernel. type help kernel for further information.% (The same value used for the 6th input parater in irwls.m).%% Author: Steve Gunn (srg@ecs.soton.ac.uk)% Modified by: Fernando Perez-Cruz (fernandop@ieee.org) if (nargin < 5 | nargin > 7) % check correct number of arguments help svrplot else epsilon = 1e-4; if((nargin==5 | nargin==6) & ker(1)~='l') disp('The used kernel needs an input parameter.'); return elseif(nargin==6 | nargin==5) par=0; end if(nargin==5) epsi=0; end xmin = min(X(:,1));, xmax = max(X(:,1)); xa = (xmax - xmin); % Plot function value n = size(X,1); x = [xmin:(xmax-xmin)/300:xmax]; z = bias*ones(size(x));
Ind=find(abs(beta)>epsilon);
for x1 = 1 : length(x)
z(x1)=kernel(ker,x(x1),X(Ind,:),par)*beta(Ind)+bias; end plot(x,z,'k','linewidth',2); axis off hold on
% Plot epsi insensitive zone if (epsi > 0) plot(x,z+epsi,'b:') plot(x,z-epsi,'b:') end % Plot Training points for i = 1:size(Y) plot(X(i),Y(i),'k+') if (abs(beta(i)) > epsilon) plot(X(i),Y(i),'ro','markersize',10) % Support Vector end end set(gca,'XLim',[xmin xmax]); hold off end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -