Click here to load reader
View
7
Download
0
Embed Size (px)
Data Mining: Clustering (K-means)
— Chapter 8 —
1
2
Chapter 8. Cluster Analysis: Basic Concepts and Methods
Cluster Analysis: Basic Concepts
Partitioning Methods
Hierarchical Methods
Density-Based Methods
Grid-Based Methods
Evaluation of Clustering
Summary
2
3
What is Cluster Analysis?
Cluster: A collection of data objects
similar (or related) to one another within the same group
dissimilar (or unrelated) to the objects in other groups
Cluster analysis (or clustering, data segmentation, …)
Finding similarities between data according to the
characteristics found in the data and grouping similar
data objects into clusters
Unsupervised learning: no predefined classes (i.e., learning
by observations vs. learning by examples: supervised)
Typical applications
As a stand-alone tool to get insight into data distribution
As a preprocessing step for other algorithms
การจดักลุ่มในการท าเหมืองข้อมูลคอือะไร
Cluster : เป็นกลุ่มหรือแหล่งเกบ็สะสม (collection) ของวตัถุต่างๆ สามารถน ามาจดักลุ่มกนัตามความเหมือน (Similarity) สามารถน ามาจดักลุ่มกนัตามความแตกต่าง (Dissimilarity or Distance)
Cluster Analysis เป็นกระบวนการจดัวตัถุต่างๆ ใหอ้ยูก่ลุ่มท่ีเหมาะสม ซ่ึงมีคุณสมบติัท่ีวตัถุท่ีอยูใ่นกลุ่มเดียวกนัจะ
คลา้ยกนั แต่มีความแตกต่างจากวตัถุในกลุ่มอ่ืน
Clustering การจดักลุ่มจะแตกต่างจากการแบ่งประเภทขอ้มูล (Classification) โดยจะแบ่งกลุ่มขอ้มูล
จากความคลา้ย โดยไม่มีการก าหนดคลาสประเภทขอ้มูลไวก่้อนหรือไม่ทราบจ านวนกลุ่มล่วงหนา้ เป็นการเรียนรู้แบบไม่มีผูส้อน (unsupervised classification)
What is Cluster Analysis? Finding groups of objects such that the objects in a group
will be similar (or related) to one another and different
from (or unrelated to) the objects in other groups
Inter-cluster distances are maximized
Intra-cluster distances are
minimized
What is Good Clustering?
จดักลุ่มโดยพยายามใหร้ะยะห่างของส่ิงท่ีอยูใ่นกลุ่มเดียวกนัอยูใ่กลก้นัใหม้าก ท่ีสุด (Minimize Intra-Cluster Distances) และระยะห่างท่ีอยูต่่างกลุ่มมีความ ห่างแตกต่างกนัมากท่ีสุด (Maximize Inter-Cluster Distances)
Inter-cluster distances are maximized
Intra-cluster distances are
minimized
Notion of a Cluster can be Ambiguous
How many clusters?
Four Clusters Two Clusters
Six Clusters
Clustering Algorithms
K-means clustering **
Hierarchical clustering
K-means Clustering
ใชห้ลกัการการตดัแบ่ง (Partition) แบ่งวตัถุ n ตวัในฐานขอ้มูล D ออกเป็นจ านวน k กลุ่ม (สมมติวา่เราทราบค่า k)
อลักอริทึม k-Means จะตดัแบ่งวตัถุออกเป็น k กลุ่ม โดยการแทนแต่ ละกลุ่มดว้ยค่าเฉล่ียของกลุ่ม ซ่ึงใชเ้ป็นจุดศนูยก์ลางของกลุ่มในการวดั ระยะห่างของตวัอยา่งในกลุ่มเดียวกนั
ประเภทของ Clustering
Partitional Clustering คือการแบ่งกลุ่มอยา่งชดัเจนโดยไม่มีกลุ่ม ไหนซอ้นทบักนัอยู ่
Original Points A Partitional Clustering
Hierarchical clustering แบบท่ีมีความสัมพนัธ์แบบล าดบัชั้น
p4
p1 p3
p2
p4
p1 p3
p2
p4p1 p2 p3
p4p1 p2 p3
Hierarchical Clustering#1
Hierarchical Clustering#2
Traditional Dendrogram 1
Traditional Dendrogram 2
Partitioning Algorithms: Basic Concept
Partitioning method: Partitioning a database D of n objects into a set of
k clusters, such that the sum of squared distances is minimized (where
ci is the centroid or medoid of cluster Ci)
Given k, find a partition of k clusters that optimizes the chosen
partitioning criterion
Global optimal: exhaustively enumerate all partitions
Heuristic methods: k-means and k-medoids algorithms
k-means (MacQueen’67, Lloyd’57/’82): Each cluster is represented
by the center of the cluster
k-medoids or PAM (Partition around medoids) (Kaufman &
Rousseeuw’87): Each cluster is represented by one of the objects
in the cluster
2
1 )),(( iCp k
i cpdE i
12
The K-Means Clustering Method
Given k, the k-means algorithm is implemented in four
steps:
Partition objects into k nonempty subsets
Compute seed points as the centroids of the
clusters of the current partitioning (the centroid is
the center, i.e., mean point, of the cluster)
Assign each object to the cluster with the nearest
seed point
Go back to Step 2, stop when the assignment does
not change
13
K-means Clustering Algorithm
Method
1) ก าหนดหรือสุ่มค่าเร่ิมตน้ จ านวน k ค่า(กลุ่ม) และก าหนดจุดศนูยก์ลาง เร่ิมตน้ k จุด เรียกวา่ cluster centers หรือ(centroid)
2) น าวตัถุทั้งหมดจดัเขา้กลุ่ม โดยท าการหาค่าระยะห่างระหวา่งขอ้มูลกบัจุด ศนูยก์ลาง หากขอ้มูลไหนใกลค้่าจุดศนูยก์ลางตวัไหนท่ีสุดอยูก่ลุ่มนั้น
3) หาค่าเฉล่ีย (Mean) แต่ละกลุ่ม ใหเ้ป็นค่าจุดศนูยก์ลางใหม่ 4) ท าซ ้ าขอ้ 2) จนกระทัง่ค่าเฉล่ียหรือจุดศนูยก์ลางในแต่ละกลุ่มจะไม่
เปล่ียนแปลง
An Example of K-Means Clustering
K=2
Arbitrarily partition objects into k groups
Update the cluster centroids
Update the cluster centroids
Reassign objects Loop if needed
15
The initial data set
Partition objects into k nonempty
subsets
Repeat
Compute centroid (i.e., mean
point) for each partition
Assign each object to the
cluster of its nearest centroid
Until no change
Variations of the K-Means Method
Most of the variants of the k-means which differ in
Selection of the initial k means
Dissimilarity calculations
Strategies to calculate cluster means
16
17
มาตรวดัความเหมือน
18
การจดักลุ่มโดยใช้หลกัเกณฑ์ต่างๆ
Example: K-Mean Clustering
ID X Y
A1 2 10
A2 2 5
A3 8 4
A4 5 8
A5 7 5
A6 6 4
A7 1 2
A8 4 9
2, 10
2, 5
8, 4
5, 8
7, 5
6, 4
1, 2
4, 9
0
2
4
6
8
10
12
0 2 4 6 8 10
Y
X
Example: K-Mean Clustering
สุ่มค่าเร่ิมตน้ จ านวน k ค่า เรียกวา่ cluster centers (centroid);