How can I solve this problem?
%数据集中1-59样本为第一类,60-130第二类,131-178第三类
load wine.mat;%载入数据
train_wine = [wine(1:30,:);wine(60:95,:);wine(131:153,:)];%第一类的1-30,第二类60-95,第三类131-153作为训练集
train_wine_labels = [wine_labels(1:30);wine_labels(60:95);wine_labels(131:153)];%提取标签
test_wine = [wine(31:59,:);wine(96:130,:);wine(154:178,:)];%剩下样本作为测试集
test_wine_labels = [wine_labels(31:59);wine_labels(96:130);wine_labels(154:178)];%提取相应标签
[mtrain,ntrain] = size(train_wine);
[mtest,ntest] = size(test_wine);%数据预处理,归一化
datatest = [train_wine;test_wine];
[dataset_scale,ps] = mapminmax(dataset’,0,1);
dataset_scale = dataset_scale’;
train_wine = dataset_scale(1:mtrain,:);
test_wine = dataset_scale((mtrain+1):(mtrain+mtest),:);
%预测模型
model = svmtrain(train_wine_labels,train_wine,’-c 2 -g 1′);
[predict_label,accuracy] = svmpredict(test_wine_labels,test_wine,model);
函数或变量 ‘wine_labels’ 无法识别。
Function or variable ‘wine_labels’ is not recognised.%数据集中1-59样本为第一类,60-130第二类,131-178第三类
load wine.mat;%载入数据
train_wine = [wine(1:30,:);wine(60:95,:);wine(131:153,:)];%第一类的1-30,第二类60-95,第三类131-153作为训练集
train_wine_labels = [wine_labels(1:30);wine_labels(60:95);wine_labels(131:153)];%提取标签
test_wine = [wine(31:59,:);wine(96:130,:);wine(154:178,:)];%剩下样本作为测试集
test_wine_labels = [wine_labels(31:59);wine_labels(96:130);wine_labels(154:178)];%提取相应标签
[mtrain,ntrain] = size(train_wine);
[mtest,ntest] = size(test_wine);%数据预处理,归一化
datatest = [train_wine;test_wine];
[dataset_scale,ps] = mapminmax(dataset’,0,1);
dataset_scale = dataset_scale’;
train_wine = dataset_scale(1:mtrain,:);
test_wine = dataset_scale((mtrain+1):(mtrain+mtest),:);
%预测模型
model = svmtrain(train_wine_labels,train_wine,’-c 2 -g 1′);
[predict_label,accuracy] = svmpredict(test_wine_labels,test_wine,model);
函数或变量 ‘wine_labels’ 无法识别。
Function or variable ‘wine_labels’ is not recognised. %数据集中1-59样本为第一类,60-130第二类,131-178第三类
load wine.mat;%载入数据
train_wine = [wine(1:30,:);wine(60:95,:);wine(131:153,:)];%第一类的1-30,第二类60-95,第三类131-153作为训练集
train_wine_labels = [wine_labels(1:30);wine_labels(60:95);wine_labels(131:153)];%提取标签
test_wine = [wine(31:59,:);wine(96:130,:);wine(154:178,:)];%剩下样本作为测试集
test_wine_labels = [wine_labels(31:59);wine_labels(96:130);wine_labels(154:178)];%提取相应标签
[mtrain,ntrain] = size(train_wine);
[mtest,ntest] = size(test_wine);%数据预处理,归一化
datatest = [train_wine;test_wine];
[dataset_scale,ps] = mapminmax(dataset’,0,1);
dataset_scale = dataset_scale’;
train_wine = dataset_scale(1:mtrain,:);
test_wine = dataset_scale((mtrain+1):(mtrain+mtest),:);
%预测模型
model = svmtrain(train_wine_labels,train_wine,’-c 2 -g 1′);
[predict_label,accuracy] = svmpredict(test_wine_labels,test_wine,model);
函数或变量 ‘wine_labels’ 无法识别。
Function or variable ‘wine_labels’ is not recognised. 无法识别 MATLAB Answers — New Questions