求助,关于libsvm的运算结果分类精度 5
请问libsvm分类后每一类具体的结果怎么查看,我现在得出只有总的准确率,在Matlab平台,代码如下file=importdata('Iris.mat');data=f...
请问libsvm 分类后每一类具体的结果怎么查看,我现在得出只有总的准确率,在Matlab平台,代码如下
file=importdata('Iris.mat');
data=file;
features=data(:,1:4);
classlabel=data(:,5);
n = randperm(size(features,1));
train_features=features(n(1:75),:);
train_label=classlabel(n(1:75),:);
test_features=features(n(76:end),:);
test_label=classlabel(n(76:end),:);
[Train_features,PS] = mapminmax(train_features');
Train_features = Train_features';
Test_features = mapminmax('apply',test_features',PS);
Test_features = Test_features';
model = libsvmtrain(train_label,Train_features);
[predict_train_label] = libsvmpredict(train_label,Train_features,model);
[predict_test_label] = libsvmpredict(test_label,Test_features,model);
compare_train = (train_label == predict_train_label);
accuracy_train = sum(compare_train)/size(train_label,1)*100;
fprintf('训练集准确率:%f\n',accuracy_train)
compare_test = (test_label == predict_test_label);
accuracy_test = sum(compare_test)/size(test_label,1)*100;
fprintf('测试集准确率:%f\n',accuracy_test) 展开
file=importdata('Iris.mat');
data=file;
features=data(:,1:4);
classlabel=data(:,5);
n = randperm(size(features,1));
train_features=features(n(1:75),:);
train_label=classlabel(n(1:75),:);
test_features=features(n(76:end),:);
test_label=classlabel(n(76:end),:);
[Train_features,PS] = mapminmax(train_features');
Train_features = Train_features';
Test_features = mapminmax('apply',test_features',PS);
Test_features = Test_features';
model = libsvmtrain(train_label,Train_features);
[predict_train_label] = libsvmpredict(train_label,Train_features,model);
[predict_test_label] = libsvmpredict(test_label,Test_features,model);
compare_train = (train_label == predict_train_label);
accuracy_train = sum(compare_train)/size(train_label,1)*100;
fprintf('训练集准确率:%f\n',accuracy_train)
compare_test = (test_label == predict_test_label);
accuracy_test = sum(compare_test)/size(test_label,1)*100;
fprintf('测试集准确率:%f\n',accuracy_test) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询