91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 7KB
    文件類型: .zip
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-08-08
  • 語言: Matlab
  • 標(biāo)簽: SVM??

資源簡介

matlab程序,基于SVM的數(shù)據(jù)分類預(yù)測——意大利葡萄酒種類識別,里面一個.m文件,一個.mat數(shù)據(jù)集,直接可以使用。

資源截圖

代碼片段和文件信息

%%?Matlab神經(jīng)網(wǎng)絡(luò)43個案例分析

%?基于SVM的數(shù)據(jù)分類預(yù)測——意大利葡萄酒種類識別
%?by?李洋(faruto)
%?http://www.matlabsky.com
%?Email:faruto@163.com
%?http://weibo.com/faruto?
%?http://blog.sina.com.cn/faruto
%?2013.01.01
%%?清空環(huán)境變量
close?all;
clear;
clc;
format?compact;
%%?數(shù)據(jù)提取

%?載入測試數(shù)據(jù)wine其中包含的數(shù)據(jù)為classnumber?=?3wine:178*13的矩陣wine_labes:178*1的列向量
load?chapter_WineClass.mat;

%?畫出測試數(shù)據(jù)的box可視化圖
figure;
boxplot(wine‘orientation‘‘horizontal‘‘labels‘categories);
title(‘wine數(shù)據(jù)的box可視化圖‘‘FontSize‘12);
xlabel(‘屬性值‘‘FontSize‘12);
grid?on;

%?畫出測試數(shù)據(jù)的分維可視化圖
figure
subplot(351);
hold?on
for?run?=?1:178
????plot(runwine_labels(run)‘*‘);
end
xlabel(‘樣本‘‘FontSize‘10);
ylabel(‘類別標(biāo)簽‘‘FontSize‘10);
title(‘class‘‘FontSize‘10);
for?run?=?2:14
????subplot(35run);
????hold?on;
????str?=?[‘a(chǎn)ttrib?‘num2str(run-1)];
????for?i?=?1:178
????????plot(iwine(irun-1)‘*‘);
????end
????xlabel(‘樣本‘‘FontSize‘10);
????ylabel(‘屬性值‘‘FontSize‘10);
????title(str‘FontSize‘10);
end

%?選定訓(xùn)練集和測試集

%?將第一類的1-30第二類的60-95第三類的131-153做為訓(xùn)練集
train_wine?=?[wine(1:30:);wine(60:95:);wine(131:153:)];
%?相應(yīng)的訓(xùn)練集的標(biāo)簽也要分離出來
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:)];
%?相應(yīng)的測試集的標(biāo)簽也要分離出來
test_wine_labels?=?[wine_labels(31:59);wine_labels(96:130);wine_labels(154:178)];

%%?數(shù)據(jù)預(yù)處理
%?數(shù)據(jù)預(yù)處理將訓(xùn)練集和測試集歸一化到[01]區(qū)間

[mtrainntrain]?=?size(train_wine);
[mtestntest]?=?size(test_wine);

dataset?=?[train_wine;test_wine];
%?mapminmax為MATLAB自帶的歸一化函數(shù)
[dataset_scaleps]?=?mapminmax(dataset‘01);
dataset_scale?=?dataset_scale‘;

train_wine?=?dataset_scale(1:mtrain:);
test_wine?=?dataset_scale(?(mtrain+1):(mtrain+mtest):?);
%%?SVM網(wǎng)絡(luò)訓(xùn)練
tic;
model?=?svmtrain(train_wine_labels?train_wine?‘-c?2?-g?1‘);
toc;
%%?SVM網(wǎng)絡(luò)預(yù)測
tic;
[predict_label?accuracydec_value1]?=?svmpredict(test_wine_labels?test_wine?model);
toc;
%%?結(jié)果分析

%?測試集的實(shí)際分類和預(yù)測分類圖
%?通過圖可以看出只有一個測試樣本是被錯分的
figure;
hold?on;
plot(test_wine_labels‘o‘);
plot(predict_label‘r*‘);
xlabel(‘測試集樣本‘‘FontSize‘12);
ylabel(‘類別標(biāo)簽‘‘FontSize‘12);
legend(‘實(shí)際測試集分類‘‘預(yù)測測試集分類‘);
title(‘測試集的實(shí)際分類和預(yù)測分類圖‘‘FontSize‘12);
grid?on;

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2458??2014-08-20?12:53??chapter_WineClass.m
?????文件???????20168??2010-01-30?18:38??chapter_WineClass.mat

評論

共有 條評論