You are on page 1of 5

Data Structures

Notes for Lecture 16


Techniques of Data Mining
By
Samaher Hussein Ali
2007-2008

Clustering: Basic Concepts and Application


1. Clustering
is the process of grouping the data into classes or clusters, so that objects within a cluster have high
similarity in comparison to one another but are very dissimilar to objects in other clusters.
Dissimilarities are assessed based on the attribute values describing the objects. Often, distance
measures are used. Clustering has its roots in many areas, including data mining, statistics, biology, and
machine learning. In this lecture, we study the requirements of clustering methods for large amounts of
data. We explain how to compute dissimilarities between objects represented by various attribute or
variable types.
2. 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.

3. Types of Clustering
• A clustering is a set of clusters
• Important distinction between hierarchical and partitional sets of clusters
• Partitional Clustering: A division data objects into non-overlapping subsets (clusters) such that
each data object is in exactly one subset, such as following :
1
Original Points A Partitional Clustering

• Hierarchical clustering: A set of nested clusters organized as a hierarchical tree

4. Types of Clusters

• Well-separated clusters: A cluster is a set of points such that any point in a cluster is closer (or more
similar) to every other point in the cluster than to any point not in the cluster.
• Center-based clusters: A cluster is a set of objects such that an object in a cluster is closer (more
similar) to the “center” of a cluster, than to the center of any other cluster. The center of a cluster is often a
centroid, the average of all the points in the cluster, or a medoid, the most “representative” point of a
cluster.

• Contiguous clusters(Nearest neighbor or Transitive): A cluster is a set of points such that a point
in a cluster is closer (or more similar) to one or more other points in the cluster than to any point not in the
cluster.
• Density-based clusters: A cluster is a dense region of points, which is separated by low-density regions,
from other regions of high density. Used when the clusters are irregular or intertwined, and when noise and
outliers are present.

2
• Property or Conceptual: Finds clusters that share some common property or represent a particular
concept.

• Described by an Objective Function:


A: Clusters Defined by an Objective Function

1. Finds clusters that minimize or maximize an objective function.


2. Enumerate all possible ways of dividing the points into clusters and evaluate the
"goodness" of each potential set of clusters by using the given objective function. (NP
Hard).
3. Can have global or local objectives.
• Hierarchical clustering algorithms typically have local objectives
• Partitional algorithms typically have global objectives
4. A variation of the global objective function approach is to fit the data to a parameterized
model.
• Parameters for the model are determined from the data.
• Mixture models assume that the data is a "mixture" of a number of statistical
distributions.
B: Map the clustering problem to a different domain and solve a related problem in that domain
1. Proximity matrix defines a weighted graph, where the nodes are the points being clustered,
and the weighted edges represent the proximities between points
2. Clustering is equivalent to breaking the graph into connected components, one for each
cluster.
3. Want to minimize the edge weight between clusters and maximize the edge weight within
clusters
5. Clustering Algorithms
• K-means and its variants
• Hierarchical clustering
• Density-based clustering
K-means Clustering
• Partitional clustering approach
• Each cluster is associated with a centroid (center point)
• Each point is assigned to the cluster with the closest centroid
• Number of clusters, K, must be specified
• The basic algorithm is very simple

3
Algorithm: k-means. The k-means algorithm for partitioning, where each cluster’s center is represented
by the mean value of the objects in the cluster.
Input:
• k: the number of clusters,
• D: a data set containing n objects.
Output: A set of k clusters.
Method:
• arbitrarily choose k objects from D as the initial cluster centers;
• repeat
• (re)assign each object to the cluster to which the object is the most similar, based on the mean
value of the objects in the cluster;
• update the cluster means, i.e., calculate the mean value of the objects for each cluster;
• until no change;
K-means Clustering – Details
1. Initial centroids are often chosen randomly.
• Clusters produced vary from one run to another.
2. The centroid is (typically) the mean of the points in the cluster.
3. ‘Closeness’ is measured by Euclidean distance, cosine similarity, correlation, etc.
4. K-means will converge for common similarity measures mentioned above.
5. Most of the convergence happens in the first few iterations.
• Often the stopping condition is changed to ‘Until relatively few points change clusters’
6. Complexity is O( n * K * I * d )
Where: n = number of points, K = number of clusters, I = number of iterations, d = number of attributes
Evaluating K-means Clusters
Most common measure is Sum of Squared Error (SSE)
1. For each point, the error is the distance to the nearest cluster
2. To get SSE, we square these errors and sum them.

3. x is a data point in cluster Ci and mi is the representative point for cluster Ci


• can show that mi corresponds to the center (mean) of the cluster
4. Given two clusters, we can choose the one with the smallest error
5. One easy way to reduce SSE is to increase K, the number of clusters
• A good clustering with smaller K can have a lower SSE than a poor clustering with higher
4
As a Result
The K-means algorithm assigns each point to the cluster whose center (also called centroid) is nearest.
The center is the average of all the points in the cluster — that is, its coordinates are the arithmetic
mean for each dimension separately over all the points in the cluster.
Example:
The data set has three dimensions and the cluster has two points: X = (x1, x2, x3) and Y = (y1, y2, y3). Then
the centroid Z becomes Z = (z1, z2, z3), where z1 = (x1 + y1)/2 and z2 = (x2 + y2)/2 and z3 = (x3 + y3)/2.

The main advantages of this algorithm are its simplicity and speed which allows it to run on large
datasets. Its disadvantage is that it does not yield the same result with each run, since the resulting
clusters depend on the initial random assignments. It maximizes inter-cluster (or minimizes intra-cluster)
variance, but does not ensure that the result has a global minimum of variance.

Importance of Choosing Initial Centroids

You might also like