📄 m2.m
字号:
N=100;noise=0.5;
X= 10*[-1:2/(N-1):1]';
t= sin(X).*exp(-0.2*X);
Y=t+ noise*randn(N,1);
model = svmtrain(Y, X, '-s 3 -t 2 -g 0.32 -c 10 -p 0.1 -b 1 -p 1');
[y, accuracy] = svmpredict(Y, X, model);
figure(3)
clf;
h_y=plot(X,t,'r--','LineWidth',2);
hold on
plot(X,Y,'g.');
hold on
h_ysvm=plot(X,y,'b','linewidth',2);
%legend([h_y h_ysvm],'initial function','SVM predictor')
fprintf('\nSVM regression test error (RMSE): %g\n', ...
sqrt(mean((t-Y).^2)))
fprintf('\nSVM regression test error (MAXE): %g\n', ...
max(abs(t-Y)))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -