tic
clear;
clc;
Fnum = 4; %输入个数/输出个数只能为1个
TnumX = 0.8; %训练数据比例
Terror = 0.2; %误差小于Terror的预测比例
eps = 10^(-7); %误差阈值
v=6; %交互检验
% 寻找最佳c参数/g参数 CV
cmax = 10;
cmin = -10;
gmax = 10;
gmin = -10;
cstep = 1;
gstep = 1;
msestep = 0.05;
local = 'C:\Users\37989\Desktop\2688.xlsx';%数据文件地址
data = xlsread(local);
[Ynum,Xnum] = size(data);
Train = data(randperm(Ynum),:);
Tnum = round(TnumX * Ynum);
TSnum = Ynum - Tnum;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%主要修改以上数据%以下代码不要修改
% 训练集
p_train = Train(1:Tnum,1:Fnum);%2:4 是回弹后的零件 5列是分组标记
t_train = Train(1:Tnum,Fnum+1);
% 测试集
p_test = Train(Tnum + 1:Ynum,1:Fnum); %这个改了 R8000生成的只有3列
t_test = Train(Tnum + 1:Ynum,Fnum+1);
%无所谓
%% 数据归一化
% 训练集
[pn_train,inputps] = mapminmax(p_train'); %归一化方法?
pn_train = pn_train';
[tn_train,outputps] = mapminmax(t_train&
利用Matlab_libsvm构造支持向量机回归算法
最新推荐文章于 2024-09-09 16:50:48 发布