AGNES 資料探勘演算法 C語言

2021-10-01 11:49:10 字數 961 閱讀 7196

資料探勘演算法之agnes。(最暴力的實現)(別看到暴力就放棄,hh)

。(來自青島大學某學生)

自底向上的凝聚的方法。

隨便乙個輸入樣例:(8個點,最終聚成兩類)82

1 11 2

2 12 2

7 77 8

8 78 8

#include

#include

#include

struct diand[

1000];

struct zu

;//組使用帶有頭結點的鍊錶來儲存

intmain()

//迴圈找出最小的距離的兩個簇並合併,用p3與p4記錄兩個簇

for(

int it_cnt =

0;it_cnt) prep2=p2;

p2=p2->next;

} p1=p1->next;

}//一次遍歷,獲得距離最近的兩個簇p3,p4,將p4合併到p3,刪除p4.

//合併

for(

int i=

0;icnt;i++

)//刪除p4

prep4->next=p4->next;

free

(p4)

;//重新計算p3的中心點

int tempsumx=

0,tempsumy=0;

for(

int i =

0;i< p3->cnt;i++

) p3->x=

1.0*tempsumx/p3->cnt;

p3->y=

1.0*tempsumy/p3->cnt;

} p1=head->next;

while

(p1!=

null

) p1=p1->next;

}return0;

}

基於層次的聚類 AGNES演算法使用(R語言)

凝聚 產生資料集 x c rnorm 200,30,1 rnorm 200,10,1.5 rnorm 100,5,0.5 y c rnorm 200,30,1 rnorm 200,10,1.5 rnorm 100,5,0.5 data data.frame x,y 彩色空間 library colo...

基於層次的聚類 AGNES演算法使用(R語言)

凝聚 plain view plain copy 產生資料集 xy data 彩色空間 library colorspace 顯示資料集的結構 str data 系統聚類 聚類的一些必要的函式 library cluster library rattle 系統聚類函式在包amap中 require ...

資料探勘演算法

apriori演算法學習資料的關聯規則 association rules 適用於包含大量事務 transcation 的資料庫。關聯規則學習是學習資料庫中不同變數中的相互關係的一種資料探勘技術。你可能會對 apriori 演算法如何工作有疑問,在進入演算法本質和細節之前,得先明確3件事情 第一是你...