資源簡介
利用K均值聚類對鳶尾花樣本進行聚類的matlab程序,包含源代碼、樣本數(shù)據(jù)、聚類結(jié)果(The matlab program of clustering iris samples by K-means clustering, including source code, sample data and clustering results)
代碼片段和文件信息
function?Bayes3
%clear
%判別矩陣的初始化
Result(1:31:3)=0;?
load?hh.txt
hh;
a=input(‘請輸入隨機抽取矩陣行數(shù):‘);
randIndex?=?randperm(50);
‘隨機抽取行數(shù)‘;
selected?=?randIndex(1:a);
‘第一類隨機抽取的訓練樣本為‘;
b=hh(selected:);
‘剩余行數(shù)‘;
train?=?randIndex(a+1:end);
‘第一類的測試樣本為‘;
c=hh(train:);
hh1=hh(51:1001:4);
randIndex?=?randperm(50);
‘隨機抽取行數(shù)‘;
aa=input(‘請輸入隨機抽取矩陣行數(shù):‘);
A=?randIndex(1:aa);
A1=A+50;
‘第二類隨機抽取的訓練樣本為‘;
e=hh1(A:);
‘剩余行數(shù)‘;
B?=?randIndex(a+1:end);
B1=B+50;
‘第二類的測試樣本為‘;
f=hh1(B:);
hh2=hh(101:1501:4);
randIndex?=?randperm(50);
‘隨機抽取行數(shù)‘;
aaa=input(‘請輸入隨機抽取矩陣行數(shù):‘);
A2=?randIndex(1:aaa);
A3=A1+100;
‘第三類隨機抽取的訓練樣本為‘;
g=hh2(A2:);
‘剩余行數(shù)‘;
B2?=?randIndex(aaa+1:end);
B3=B1+100;
‘第三類的測試樣本為‘;
h=hh2(B2:);
%求訓練樣本的均值
mean1=sum(b1)/a;
mean2=sum(e1)/aa;
mean3=sum(g1)/aaa;
%求協(xié)方差矩
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4700??2013-07-04?21:39??《模式識別》K均值分類\1111.txt
?????文件???????4496??2011-07-14?23:58??《模式識別》K均值分類\Bayes3.m
?????文件???????2538??2011-07-09?12:50??《模式識別》K均值分類\hh.txt
?????文件???????4704??2011-07-03?17:03??《模式識別》K均值分類\huaban.txt
?????文件???????1251??2012-07-12?17:16??《模式識別》K均值分類\ICA.m
?????文件???????5280??2003-10-10?00:00??《模式識別》K均值分類\Iris.mat
?????文件???????1613??2012-07-13?09:23??《模式識別》K均值分類\KL.m
?????文件???????2478??2013-07-06?15:54??《模式識別》K均值分類\k_mean_classcify_fossil.m
?????文件???????3269??2012-07-07?09:48??《模式識別》K均值分類\Unti
?????文件??????15375??2011-07-08?21:00??《模式識別》K均值分類\unti
?????文件????????997??2012-07-07?09:33??《模式識別》K均值分類\Unti
?????文件?????????74??2011-07-10?23:13??《模式識別》K均值分類\均值.txt
?????文件???????2320??2011-07-10?22:50??《模式識別》K均值分類\歸類.txt
?????文件???????2538??2011-07-09?12:32??《模式識別》K均值分類\新建?文本文檔.txt
?????文件????????179??2011-07-10?22:48??《模式識別》K均值分類\程序.txt
?????文件???????4278??2011-07-10?23:14??《模式識別》K均值分類\程序代碼.txt
?????文件????????796??2011-07-09?18:35??《模式識別》K均值分類\隨機取樣本程序代碼.txt
?????目錄??????????0??2013-07-08?10:25??《模式識別》K均值分類
-----------?---------??----------?-----??----
????????????????56886????????????????????18
評論
共有 條評論