欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
k均值算法的matlab源代碼
[打印本頁]
作者:
playgamewy
時間:
2019-2-10 15:20
標題:
k均值算法的matlab源代碼
用于實現k均值算法的matlab源代碼,簡單易懂,方便理解。自己可以參考注釋修改源代碼,以便深入的了解該算法的本質。
x1=[0 1 0 1 2 1 2 3 6 7 8 6 7 8 9 7 8 9 8 9];
x2=[0 0 1 1 1 2 2 2 6 6 6 7 7 7 7 8 8 9 9 9];
cities = [x1;x2];
num = size(cities,2);
m1 = round(rand()*num);
m2 = round(rand()*num);
while m1==m2
m2 = round(rand()*num);
end
u1 = cities(:,m1);
u2 = cities(:,m2);
u_old = [u1,u2];
u_new = [u2,u1];
while u_old ~= u_new
u_old = u_new ;
for j=1:num
dis1 = norm(cities(:,j)-u1);
dis2 = norm(cities(:,j)-u2);
if dis1>=dis2 c(j) = 2;
else c(j) = 1;
end
end
index1 = find(c==1);
index2 = find(c==2);
sum1 = sum(cities(:,index1),2);
sum2 = sum(cities(:,index2),2);
u1 = sum1/length(index1);
u2 = sum2/length(index2);
u_new = [u1,u2];
end
hold on,plot(cities(1,index1),cities(2,index1),'*');
hold on,plot(cities(1,index2),cities(2,index2),'+');
hold on,plot(u1(1),u1(2),'o',u2(1),u2(2),'o');
mean = u_new;
復制代碼
源程序.docx
2019-2-10 15:20 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
13.37 KB, 下載次數: 2, 下載積分: 黑幣 -5
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1