📄 r2smallestsphere.m
字号:
function [beta,r2,pos]= r2smallestsphere(xapp,kernel,kerneloption,Cpenalization)
% usage
% [beta,r2,pos]= r2smallestsphere(xapp,kernel,kerneloption,Cpenalization)
%------------------------------------------------------------------------------------
%
% Processing the radius of the smallest sphere including learning data
%
%-------------------------------------------------------------------------------------
%
%
% if you are using a linear slacks Cpenalization is equal to 0
% otherwise as you are changing the kernel you have to take C into account
%
%
% if you want to pass just the kernel matrix, then pass the struct with a field
% 'matrix'
if nargin < 5
Cpenalization=0;
end;
if ~isempty(xapp)
[kapp]=svmkernel(xapp,kernel,kerneloption);
if Cpenalization~=0
kapp=kapp+Cpenalization*eye(size(kapp));
end;
elseif isfield(kerneloption,'matrix')
kapp=kerneloption.matrix+Cpenalization*eye(size(kerneloption.matrix));
else
error('No ways for processing the radius. Check inputs...');
end;
D=diag(kapp);
A = ones(size(D));
b=1;
lambda=1e-7;
verbose=0;
C=inf;
%[betaaux,lagrangian,pos]=monqp(kapp,D,A,b,C,lambda,verbose);
[betaaux,lagrangian,pos]=monqpCinfty(kapp,D,A,b,lambda,verbose);
beta=zeros(size(D));
beta(pos)=betaaux;
r2=-betaaux'*kapp(pos,pos)*betaaux + betaaux'*D(pos);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -