我想在LIBSVM中使用加权内核进行测试,为此我使用以下语法获得了“模型”。测试语法是否会像标准内核一样保留,否则会改变?我的查询在代码的最后一行。
kernel_name={'Linear','sigmoid','RBF','poly'};
num_kernel=4;
% Suppose I have already computed kernels on training data
K{1} = linear_kernel(trainData,trainData); %
K{2}= sigmoid_kernel(trainData,trainData,sigma,cc);
K{3}= rbfKernel(trainData,trainData,sigma);
K{4}= polynomial_kernel(trainData,trainData,sigma,cc,degree);
K_comp=zeros(numTrain,numTrain);
for i=1:num_kernel
temp=K{1,i};
temp=WT_KA(i).*temp; % WT_KA contains weight for each kernel
K_comp=K_comp+temp; % K_COMP contains final weighted kernel
temp=[];
end
K_req=[(1:numTrain)' K_comp]; % required syntax for LIBSVM for precomputed kernel
%# train and test
model = svmtrain(trainClass, K_req, '-t 4');
% Is this statement correct to predict testing data
[output_true]= svmpredict(testClass,testData,model); %testClass are labels