作者:办事繁华_491 | 来源:互联网 | 2022-12-26 07:23
文章目录导入文件划分数据集和测试集归一化处理导入文件划分数据集和测试集train[wine1(1:41,:);wine1(60:109,:);wine1(131:164,:)];t
导入文件
划分数据集和测试集
train= [wine1(1:41,:);wine1(60:109,:);wine1(131:164,:)];
train_label= [wine1label(1:41);wine1label(60:109);wine1label(131:164)];
test= [wine1(42:59,:);wine1(110:130,:);wine1(165:178,:)];
test_label= [wine1label(42:59);wine1label(110:130);wine1label(165:178)];
归一化处理
[mtrain,ntrain] = size(train);
[mtest,ntest] = size(test);
dataset = [train;test];
[dataset_scale,ps] = mapminmax(dataset’,0,1);
dataset_scale = dataset_scale’;
train= dataset_scale(1:mtrain,:);
test= dataset_scale( (mtrain+1):(mtrain+mtest),: );