SVMによるデータ分類予測——イタリアワインの種類識別

4345 ワード

udate:プログラムのソースとデータセットも添付します.http://download.csdn.net/detail/zjccoder/8832699
205.6.24
----------------------------------------------------------------------------------------------------------------------------------------------------------------
wineデータはUCIデータベースから来て、記録したのはイタリアの同じ地区の3の中で異なっている品種のワインの13の中で化学の成分の含有量で、科学的な方法を通じて(通って)、自動的にワインを分類する目的を達成します.
今回の分類のデータは全部で178個のサンプルがあり、各サンプルには13個の属性があり、各サンプルの正確な分類を提供して、SVM分類の準決定を検査する.
まず、データの可視化図を描きます.
%       wine,        classnumber = 3,wine:178*13   ,wine_labes:178*1    
load chapter_WineClass.mat;

%        box    
figure;
boxplot(wine,'orientation','horizontal','labels',categories);
title('wine   box    ','FontSize',12);
xlabel('   ','FontSize',12);
grid on;

%              
figure
subplot(3,5,1);
hold on
for run = 1:178
    plot(run,wine_labels(run),'*');
end
xlabel('  ','FontSize',10);
ylabel('    ','FontSize',10);
title('class','FontSize',10);
for run = 2:14
    subplot(3,5,run);
    hold on;
    str = ['attrib ',num2str(run-1)];
    for i = 1:178
        plot(i,wine(i,run-1),'*');
    end
    xlabel('  ','FontSize',10);
    ylabel('   ','FontSize',10);
    title(str,'FontSize',10);
end
基于SVM的数据分类预测——意大利葡萄酒种类识别_第1张图片
(図1)
基于SVM的数据分类预测——意大利葡萄酒种类识别_第2张图片
(図2)
図1はwineデータのbox可視化図であり、図2はwineの箱図であり、図からワインの種類を区別するのは難しいです.次はSVMで分類してみよう.
データの前処理
%          

%      1-30,    60-95,    131-153     
train_wine = [wine(1:30,:);wine(60:95,:);wine(131:153,:)];
%                
train_wine_labels = [wine_labels(1:30);wine_labels(60:95);wine_labels(131:153)];
%      31-59,    96-130,    154-178     
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)];

<strong>%%      </strong>
%      ,            [0,1]  

[mtrain,ntrain] = size(train_wine);
[mtest,ntest] = size(test_wine);

dataset = [train_wine;test_wine];
% mapminmax MATLAB        
[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),: );
SVMネットワークの確立、トレーニング、予測
<span style="font-size:12px;">%% SVM    
model = svmtrain(train_wine_labels, train_wine, '-c 2 -g 1');

%% SVM    
[predict_label, accuracy,dec_value1] = svmpredict(test_wine_labels, test_wine, model);</span>
結果分析
%%     

%               
%                     
figure;
hold on;
plot(test_wine_labels,'o');
plot(predict_label,'r*');
xlabel('     ','FontSize',12);
ylabel('    ','FontSize',12);
legend('       ','       ');
title('              ','FontSize',12);
grid on;
基于SVM的数据分类预测——意大利葡萄酒种类识别_第3张图片
基于SVM的数据分类预测——意大利葡萄酒种类识别_第4张图片
svm分類を利用した精度は98.764%に達し、89個のテストサンプルの中で一つだけ分類されたエラーがあります.SVMのデータ分類における強力さが見られます.
END