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

📄 svm_light_transductive.m

📁 一个matlab的工具包,里面包括一些分类器 例如 KNN KMEAN SVM NETLAB 等等有很多.
💻 M
字号:
function  [Y_compute, Y_prob] = svm_light_transductive(para, X_train, Y_train, X_test, Y_test, num_class)

global temp_model_file SVMLight_dir;
class_set = GetClassSet(Y_train);

if (num_class > 2)
    error('SVM_light: The class number is larger than 2!\n');
end;
%p = sscanf(para, 'Kernel %d KernelParam %f CostFactor %f TransPosFrac %f');
p = str2num(char(ParseParameter(para, {'-Kernel';'-KernelParam'; '-CostFactor'; '-Threshold'; '-TransPosFrac'}, {'0';'0.05';'1';'0';'1'})));

Y_train =  (Y_train == class_set(1)) - (Y_train ~= class_set(1));
X_train_tran = [X_train; X_test];
Y_train_tran = [Y_train; zeros(size(Y_test))];

net = svml(temp_model_file, 'Kernel', p(1), 'KernelParam', p(2), 'CostFactor', p(3), 'TransPosFrac', p(5), 'ExecPath', SVMLight_dir);
if (~isempty(X_train)),
    net = svmltrain(net, X_train_tran, Y_train_tran);
end;
% Compute prediction on the test data
Ypred = svmlfwd(net, X_test);

threshold = p(4);
Y_compute = class_set(1) * (Ypred >= threshold) + class_set(2) * (Ypred < threshold);
% Y_prob = (1 ./ (1 + exp(-Ypred))) .* (Ypred >= threshold) + (1 ./ ( 1 + exp(Ypred) )) .* (Ypred < threshold) ;
Y_prob = 1 ./ (1 + exp(-Ypred));

⌨️ 快捷键说明

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