📄 svmnlspex01fun.m
字号:
%SVMnLSPex01FUN.m
%
%Object function and Constrained function for Two Dimension SVM Problem, Two Class and Separable Situation;
%
%Method from Christopher J. C. Burges:
%Object function and Constrained function for Two Dimension SVM Problem, Two Class and Separable Situation;
%
%Method from Thorsten Joachims:
%"Making Large-Scale SVM Learning Practical", function (4)/(5)/(6)
%
% Objective: min "f(A)=-sum(A)+A'*Q*A/2" , function (4);
% Subject to: sum{A'*Y}=0 , function (5);
% 0 <= ai <= C , function (6);
%The optimizing variables is "Lagrange Multipliers": A=[a1,a2,...,am],m is the number of total samples.
%
function [F,G]= SVMnLSPex01FUN(A)
%Samples matrix X with (m*n), m samples with dimention n;
fid=fopen('a.dat','r'); %Get the samples
m1=fread(fid,1,'float'); %The number of Position Set
m2=fread(fid,1,'float'); %The number of Negative Set
n=fread(fid,1,'float'); %Dimension of the samples
m=m1+m2; %
for k=1:n
X(1:m,k)=fread(fid,m,'float');
end
fclose(fid);
Y=[ones(m1,1);-ones(m2,1)]; %Classfication value for both Positive/Negative samples
%Object Function value F and Constrained function value G, G(i) is the value of i'th constrained function.
Q = diag(Y)*K(X,X')*diag(Y); %Component of matrix Q is Q(ij)=yi*yj*Xi*Xj';
F = -sum(A)+ 0.5*(A'*Q*A); %Object Function after Mapping;
G = sum(A'*Y); %Constraint Functions after Mapping;
function Kernel = K(U,E) %Kernel function
Kernel = (U*E+1).^4;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -