导入文件
划分数据集和测试集
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),: );
|
请发表评论