?? testrbf.m
字號:
clear;clc;close all;
disp('-------------采用徑向基內積函數的支持向量機的應用-------------');
disp('輸入樣本矩陣(每行表示一個測試數據):');
x=[randn(1,20)-3 randn(1,20)+3;randn(1,40)]'
disp('樣本所屬類別:');
y=[-ones(1,20) ones(1,20)]'
[nsv,alpha,bias,T]=svm168(x,y,'rbf',10,4);
fprintf('運行時間T=%g\n',T);
fprintf('支持向量個數:%g\n',nsv);
svcplot(x,y,'linear',alpha,bias);
disp('測試數據:');
X_test=[randn(1,20)-3 randn(1,20)+3;randn(1,40)]'
disp('測試數據類別:');
Y_test=[-ones(1,20) ones(1,20)]'
disp('測試數據類別判決:');
Output=kernel('rbf',X_test,x(find(alpha),:),4)*alpha(find(alpha))+bias
disp('錯誤率:');
number_error=sum(abs(Y_test-sign(Output)))/2;
error=number_error/20
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -