回归预测 | MATLAB实SVM支持向量机多输入单输出回归预测
效果一览
基本介绍
回归预测 | MATLAB实SVM支持向量机多输入单输出回归预测
…………训练集误差指标…………
1.均方差(MSE):166116.6814
2.根均方差(RMSE):407.5741
3.平均绝对误差(MAE):302.5888
4.平均相对百分误差(MAPE):5.6567%
5.R2:95.4204%
…………SVM测试集误差指标…………
1.均方差(MSE):144623.1697
2.根均方差(RMSE):380.2935
3.平均绝对误差(MAE):288.4765
4.平均相对百分误差(MAPE):5.8009%
5.R2:96.4116%
程序设计
- 完整源码和数据MATLAB实SVM支持向量机多输入单输出回归预测
P_train = res(1: num_train_s, 1: f_)';
T_train = res(1: num_train_s, f_ + 1: end)';
M = size(P_train, 2);
P_test = res(num_train_s + 1: end, 1: f_)';
T_test = res(num_train_s + 1: end, f_ + 1: end)';
N = size(P_test, 2);
% 数据归一化
[p_train, ps_input] = mapminmax(P_train, 0, 1);
p_test = mapminmax('apply', P_test, ps_input);
[t_train, ps_output] = mapminmax(T_train, 0, 1);
t_test = mapminmax('apply', T_test, ps_output);
bestc = 0.01;
bestg = 190;
cmd = [' -s 4',' -t 0',' -c ',num2str(bestc),' -g ',num2str(bestg)];
tic
mode= libsvmtrain(t_train',p_train',cmd);
toc
[t_sim1,acc,~]= libsvmpredict(t_train',p_train',mode);
[t_sim2,acc,~]= libsvmpredict(t_test',p_test',mode);
% 数据反归一化
T_sim1 = mapminmax('reverse', t_sim1, ps_output);
T_sim2 = mapminmax('reverse', t_sim2, ps_output);
T_train1 = T_train;
T_test2 = T_test;
参考资料
https://download.csdn.net/download/kjm13182345320/90268213?spm=1001.2014.3001.5503