Module III - Unsupervised Learning
Module III - Unsupervised Learning
UNSUPERVISED LEARNING:
Unsupervised learning is a type of machine learning that analyzes and models data without
labelled responses or predefined categories. Unlike supervised learning, where the algorithm
learns from input-output pairs, unsupervised learning algorithms work solely with input data
and aim to discover hidden patterns, structures or relationships within the dataset
independently, without any human intervention or prior knowledge of the data's meaning.
The image shows set of animals like elephants, camels and cows that represents raw
data that the unsupervised learning algorithm will process.
• The "Interpretation" stage signifies that the algorithm doesn't have predefined labels or
categories for the data. It needs to figure out how to group or organize the data based
on inherent patterns.
• An algorithm represents unsupervised learning process which can be clustering,
dimensionality reduction or anomaly detection to identify patterns in the data.
• The processing stage shows the algorithm working on the data.
The output shows the results of the unsupervised learning process. In this case, the algorithm
might have grouped the animals into clusters based on their species (elephants, camels, cows).
Working of Unsupervised Learning
The working of unsupervised machine learning can be explained in these steps:
Collect Unlabeled Data
• Gather a dataset without predefined labels or categories.
• Example: Images of various animals without any tags.
2. Select an Algorithm
• Choose a suitable unsupervised algorithm such as clustering like K-Means, association
rule learning like Apriori or dimensionality reduction like PCA based on the goal.
3. Train the Model on Raw Data
• Feed the entire unlabeled dataset to the algorithm.
• The algorithm looks for similarities, relationships or hidden structures within the data.
4. Group or Transform Data
• The algorithm organizes data into groups (clusters), rules or lower-dimensional forms
without human input.
• Example: It may group similar animals together or extract key patterns from large
datasets.
5. Interpret and Use Results
• Analyze the discovered groups, rules or features to gain insights or use them for further
tasks like visualization, anomaly detection or as input for other models.
Applications of Unsupervised learning:
Unsupervised learning has diverse applications across industries and domains. Key
applications include:
Uses labeled data (input features + Uses unlabeled data (only input
Input Data
corresponding outputs). features, no outputs).
Computational Less complex, as the model learns from More complex, as the model must find
Complexity labeled data with clear guidance. patterns without any guidance.
Model can be tested and evaluated using Cannot be tested in the traditional
Testing the Model
labeled test data. sense, as there are no labels.
TYPES OF UNSUPERVISED LEARNING:
1. Clustering Algorithms
Clustering is an unsupervised machine learning technique that groups unlabeled data into
clusters based on similarity. Its goal is to discover patterns or relationships within the data
without any prior knowledge of categories or labels.
• Groups data points that share similar features or characteristics.
• Helps find natural groupings in raw, unclassified data.
• Commonly used for customer segmentation, anomaly detection and data organization.
• Works purely from the input data without any output labels.
• Enables understanding of data structure for further analysis or decision-making.
Some common clustering algorithms:
• K-means Clustering: Groups data into K clusters based on how close the points are to
each other.
• Hierarchical Clustering: Creates clusters by building a tree step-by-step, either
merging or splitting groups.
• Density-Based Clustering (DBSCAN): Finds clusters in dense areas and treats
scattered points as noise.
• Mean-Shift Clustering: Discovers clusters by moving points toward the most crowded
areas.
• Spectral Clustering: Groups data by analyzing connections between points using
graphs.
2. Association Rule Learning
Association rule learning is a rule-based unsupervised learning technique used to discover
interesting relationships between variables in large datasets. It identifies patterns in the form of
“if-then” rules, showing how the presence of some items in the data implies the presence of
others.
• Finds frequent item combinations and the rules connecting them.
• Commonly used in market basket analysis to understand product purchase
relationships.
• Helps retailers design promotions and cross-selling strategies.
Some common Association Rule Learning algorithms:
• Apriori Algorithm: Finds patterns by exploring frequent item combinations step-by-
step.
• FP-Growth Algorithm: An Efficient Alternative to Apriori. It quickly identifies
frequent patterns without generating candidate sets.
• Eclat Algorithm: Uses intersections of itemsets to efficiently find frequent patterns.
• Efficient Tree-based Algorithms: Scales to handle large datasets by organizing data
in tree structures.
3. Dimensionality Reduction
Dimensionality reduction is the process of decreasing the number of features or variables in a
dataset while retaining as much of the original information as possible. This technique helps
simplify complex data making it easier to analyze and visualize. It also improves the efficiency
and performance of machine learning algorithms by reducing noise and computational cost.
• It reduces the dataset’s feature space from many dimensions to fewer, more meaningful
ones.
• Helps focus on the most important traits or patterns in the data.
• Commonly used to improve model speed and reduce overfitting.
Here are some popular Dimensionality Reduction algorithms:
• Principal Component Analysis (PCA): Reduces dimensions by transforming data
into uncorrelated principal components.
• Linear Discriminant Analysis (LDA): Reduces dimensions while maximizing class
separability for classification tasks.
• Non-negative Matrix Factorization (NMF): Breaks data into non-negative parts to
simplify representation.
• Locally Linear Embedding (LLE): Reduces dimensions while preserving the
relationships between nearby points.
• Isomap: Captures global data structure by preserving distances along a manifold.
CLUSTERING:
Clustering is an unsupervised machine learning technique that groups similar data points
together into clusters based on their characteristics, without using any labeled data. The
objective is to ensure that data points within the same cluster are more similar to each other
than to those in different clusters, enabling the discovery of natural groupings and hidden
patterns in complex datasets.
• Goal: Discover the natural grouping or structure in unlabeled data without
predefined categories.
• How: Data points are assigned to clusters based on similarity or distance measures.
• Similarity Measures: Can include Euclidean distance, cosine similarity or other
metrics depending on data type and clustering method.
• Output: Each group is assigned a cluster ID, representing shared characteristics within
the cluster.
For example, if we have customer purchase data, clustering can group customers with similar
shopping habits. These clusters can then be used for targeted marketing, personalized
recommendations or customer segmentation.
TYPES OF CLUSTERING
Let's see the types of clustering,
1. Hard Clustering: In hard clustering, each data point strictly belongs to exactly one cluster,
no overlap is allowed. This approach assigns a clear membership, making it easier to interpret
and use for definitive segmentation tasks.
• Example: If clustering customer data into 2 segments, each customer belongs fully to
either Cluster 1 or Cluster 2 without partial memberships.
• Use cases: Market segmentation, customer grouping, document clustering.
• Limitations: Cannot represent ambiguity or overlap between groups; boundaries are
crisp.
Let's see an example to see the difference between the hard and soft clustering using a
distribution,
int Hard Clustering Soft Clustering
2. Soft Clustering: Soft clustering assigns each data point a probability or degree of
membership to multiple clusters simultaneously, allowing data points to partially belong to
several groups.
• Example: A data point may have a 70% membership in Cluster 1 and 30% in Cluster
2, reflecting uncertainty or overlap in group characteristics.
• Use cases: Situations with overlapping class boundaries, fuzzy categories like customer
personas or medical diagnosis.
• Benefits: Captures ambiguity in data, models gradual transitions between clusters.
Types of Clustering Methods:
Clustering methods can be classified on the basis of how they form clusters,
1. Centroid-based Clustering (Partitioning Methods)
Centroid-based clustering organizes data points around central prototypes called centroids,
where each cluster is represented by the mean (or medoid) of its members. The number of
clusters is specified in advance and the algorithm allocates points to the nearest centroid,
making this technique efficient for spherical and similarly sized clusters but sensitive to outliers
and initialization.
Algorithms:
• K-means: Iteratively assigns points to nearest centroid and recalculates centroids to
minimize intra-cluster variance.
• K-medoids: Similar to K-means but uses actual data points (medoids) as centers, robust
to outliers.
Pros:
• Fast and scalable for large datasets.
• Simple to implement and interpret.
Cons:
• Requires pre-knowledge of kk.
• Sensitive to initialization and outliers.
• Not suitable for non-spherical clusters.
2. Density-based Clustering (Model-based Methods)
Density-based clustering defines clusters as contiguous regions of high data density separated
by areas of lower density. This approach can identify clusters of arbitrary shapes, handles noise
well and does not require predefining the number of clusters, though its effectiveness depends
on chosen density parameters.
Algorithms:
• DBSCAN (Density-Based Spatial Clustering of Applications with Noise): Groups
points with sufficient neighbors; labels sparse points as noise.
• OPTICS (Ordering Points To Identify Clustering Structure): Extends DBSCAN to
handle varying densities.
Pros:
• Handles clusters of varying shapes and sizes.
• Does not require cluster count upfront.
• Effective in noisy datasets.
Cons:
• Difficult to choose parameters like epsilon and min points.
• Less effective for varying density clusters (except OPTICS).
3. Connectivity-based Clustering (Hierarchical Clustering)
Connectivity-based (or hierarchical) clustering builds nested groupings of data by evaluating
how data points are connected to their neighbors. It creates a dendrogram a tree-like structure
that reflects relationships at various granularity levels and does not require specifying cluster
numbers in advance, but can be computationally intensive.
Approaches:
• Agglomerative (Bottom-up): Start with each point as a cluster; iteratively merge closest
clusters.
• Divisive (Top-down): Start with one cluster; iteratively split into smaller clusters.
Pros:
• Provides a full hierarchy, easy to visualize.
• No need to specify number of clusters upfront.
Cons:
• Computationally intensive for large datasets.
• Merging/splitting decisions are irreversible.
4. Distribution-based Clustering
Distribution-based clustering assumes data is generated from a mixture of probability
distributions, such as Gaussian distributions and assigns points to clusters based on statistical
likelihood. This method supports clusters with flexible shapes and overlaps, but usually
requires specifying the number of distributions.
Algorithm:
• Gaussian Mixture Model (GMM): Fits data as a weighted mixture of Gaussian
distributions; assigns data points based on likelihood.
Pros:
• Flexible cluster shapes.
• Provides probabilistic memberships.
• Suitable for overlapping clusters.
Cons:
• Requires specifying number of components.
• Computationally more expensive.
• Sensitive to initialization.
5. Fuzzy Clustering
Fuzzy clustering extends traditional methods by allowing each data point to belong to multiple
clusters with varying degrees of membership. This approach captures ambiguity and soft
boundaries in data and is particularly useful when the clusters overlap or boundaries are not
clear-cut.
Algorithm:
• Fuzzy C-Means: Similar to K-means but with fuzzy memberships updated iteratively.
Pros:
• Models data ambiguity explicitly.
• Useful for complex or imprecise data.
Cons:
• Choosing fuzziness parameter can be tricky.
• Computational overhead compared to hard clustering.
Use Cases:
• Customer Segmentation: Grouping customers based on behavior or demographics for
targeted marketing and personalized services.
• Anomaly Detection: Identifying outliers or fraudulent activities in finance, network
security and sensor data.
• Image Segmentation: Dividing images into meaningful parts for object detection,
medical diagnostics or computer vision tasks.
• Recommendation Systems: Clustering user preferences to recommend movies,
products or content tailored to different groups.
• Market Basket Analysis: Discovering products frequently bought together to optimize
store layouts and promotions.
HIERARCHICAL CLUSTERING :
Hierarchical clustering is an unsupervised learning technique used to group similar data points
into clusters by building a hierarchy (tree-like structure). Unlike flat clustering like k-
means hierarchical clustering does not require specifying the number of clusters in advance.
The algorithm builds clusters step by step either by progressively merging smaller clusters or
by splitting a large cluster into smaller ones. The process is often visualized using
a dendrogram, which helps to understand data similarity.
Imagine we have four fruits with different weights: an apple (100g), a banana (120g), a cherry
(50g) and a grape (30g). Hierarchical clustering starts by treating each fruit as its own group.
• Start with each fruit as its own cluster.
• Merge the closest items: grape (30g) and cherry (50g) are grouped first.
• Next, apple (100g) and banana (120g) are grouped.
• Finally, these two clusters merge into one.
Finally all the fruits are merged into one large group, showing how hierarchical clustering
progressively combines the most similar data points.
Dendrogram:
A dendrogram is like a family tree for clusters. It shows how individual data points or groups
of data merge together. The bottom shows each data point as its own group and as we move up,
similar groups are combined. The lower the merge point, the more similar the groups are. It
helps us see how things are grouped step by step.
• At the bottom of the dendrogram the points P, Q, R, S and T are all separate.
• As we move up, the closest points are merged into a single group.
• The lines connecting the points show how they are progressively merged based on
similarity.
• The height at which they are connected shows how similar the points are to each other;
the shorter the line the more similar they are
Types of Hierarchical Clustering:
Now we understand the basics of hierarchical clustering. There are two main types of
hierarchical clustering.
1. Agglomerative Clustering
2. Divisive clustering
1. Start with individual points: Each data point is its own cluster. For example if
we have 5 data points we start with 5 clusters each containing just one data point.
2. Calculate distances between clusters: Calculate the distance between every pair of
clusters. Initially since each cluster has one point this is the distance between the two
data points.
3. Merge the closest clusters: Identify the two clusters with the smallest distance and
merge them into a single cluster.
4. Update distance matrix: After merging we now have one less cluster. Recalculate the
distances between the new cluster and the remaining clusters.
5. Repeat steps 3 and 4: Keep merging the closest clusters and updating the distance
matrix until we have only one cluster left.
6. Create a dendrogram: As the process continues we can visualize the merging of
clusters using a tree-like diagram called a dendrogram. It shows the hierarchy of how
clusters are merged.
Approach Bottom-up: Starts with individual Top-down: Starts with all data in one
points and merges them. cluster and splits.
Functions:
❖ Load redistribution
❖ Efficient scheduling
Anomaly Detection and Fault Management
Cloud environments generate vast amounts of operational data, including metrics from
servers, networks, and applications.
Hierarchical clustering can be used to group normal behavior patterns of system
components based on features like response time, network traffic, and resource
utilization.
❖ Network issues
This approach reduces downtime and improves fault tolerance in cloud operations.
Cloud platforms often host a wide variety of applications, each with different
performance requirements.
This leads to more efficient cloud deployment strategies and better SLA (Service Level
Agreement) compliance.
Hierarchical clustering can also be used by cloud service providers to analyze customer
usage data and identify groups of users with similar consumption patterns.
For example, some users may have steady, predictable workloads, while others may
have bursty, seasonal usage.
For example, a cluster of users with high storage usage but low compute can be offered
specialized storage packages at lower costs, while users with fluctuating compute needs
can be offered auto-scaling plans
This benefits both the provider and the customer by reducing operational costs and
improving customer satisfaction.
K MEANS ALGORITHM:
K-means clustering is a way of grouping data based on how similar or close the data points are
to each other. Imagine you have a bunch of points, and you want to group them into clusters.
The algorithm works by first randomly picking some central points (called centroids) and then
assigning every data point to the nearest centroid.
Objective:
We randomly pick K (centroids). We name them c1,c2,..... ck, and we can say that
Step 2: Assign each x(i) to the closest cluster by implementing euclidean distance (i.e.,
calculating its distance to each centroid)
We assign each data point to its nearest center, which is accomplished by calculating the
euclidean distance.
Here, we calculate each x value's distance from each c value, i.e. the distance between x1-c1,
x1-c2, x1-c3, and so on. Then we find which is the lowest value and assign x1 to that centroid.
Similarly, we find the minimum distance for x2, x3, etc.
Step 3: Identify new centroids by taking the average of the assigned points.
We identify the actual centroid by taking the average of all the points assigned to that cluster.
It means the original point, which we thought was the centroid, will shift to the new position,
which is the actual centroid for each of these groups.
Step 4:
Advantages :
1. Simple and easy to implement: The k-means algorithm is easy to understand and
implement, making it a popular choice for clustering tasks.
2. Fast and efficient: K-means is computationally efficient and can handle large datasets
with high dimensionality.
3. Scalability: K-means can handle large datasets with many data points and can be easily
scaled to handle even larger datasets.
4. Flexibility: K-means can be easily adapted to different applications and can be used
with varying metrics of distance and initialization methods.
Applications :
1. Data Segmentation: One of the most common uses of K-Means is segmenting data
into distinct groups. For example, businesses use K-Means to group customers based
on behavior, such as purchasing patterns or website interaction.
5. Organizing Large Datasets: When dealing with large datasets, K-Means can help in
organizing the data into smaller, more manageable chunks based on similarities,
improving the efficiency of data analysis.
Challenges:
• Choosing the Right Number of Clusters (kk): One of the biggest challenges is
deciding how many clusters to use.
• Sensitive to Initial Centroids: The final clusters can vary depending on the initial
random placement of centroids.
• Non-Spherical Clusters: K-Means assumes that the clusters are spherical and equally
sized. This can be a problem when the actual clusters in the data are of different shapes
or densities.
• Outliers: K-Means is sensitive to outliers, which can distort the centroid and,
ultimately, the clusters.
K-MEDOIDS CLUSTERING:
K-Medoids (also called Partitioning Around Medoid) algorithm was proposed in 1987 by
Kaufman and Rousseeuw. A medoid can be defined as a point in the cluster, whose
dissimilarities with all the other points in the cluster are minimum. The dissimilarity of the
medoid(Ci) and object(Pi) is calculated by using E = |Pi - Ci|
Algorithm:
1. Initialize: select k random points out of the n data points as the medoids.
2. Associate each data point to the closest medoid by using any common distance metric
methods.
3. While the cost decreases: For each medoid m, for each data o point which is not a
medoid:
• Swap m and o, associate each data point to the closest medoid, and recompute
the cost.
• If the total cost is more than that in the previous step, undo the swap.
Example:
If a graph is drawn using the above data points, we obtain the following:
Step 1: Let the randomly selected 2 medoids, so select k = 2, and let C1 -(4, 5) and C2 -(8,
5) are the two medoids.
Step 2: Calculating cost. The dissimilarity of each non-medoid point with the medoids is
calculated and tabulated:
Here we have used Manhattan distance formula to calculate the distance matrices between
medoid and non-medoid points. That formula tell that Distance = |X1-X2| + |Y1-Y2|.
Each point is assigned to the cluster of that medoid whose dissimilarity is less. Points 1, 2, and
5 go to cluster C1 and 0, 3, 6, 7, 8 go to cluster C2. The Cost = (3 + 4 + 4) + (3 + 1 + 1 + 2 +
2) = 20
Step 3: randomly select one non-medoid point and recalculate the cost. Let the randomly
selected point be (8, 4). The dissimilarity of each non-medoid point with the medoids - C1 (4,
5) and C2 (8, 4) is calculated and tabulated.
Each point is assigned to that cluster whose dissimilarity is less. So, points 1, 2, and 5 go to
cluster C1 and 0, 3, 6, 7, 8 go to cluster C2. The New cost = (3 + 4 + 4) + (2 + 2 + 1 + 3 + 3) =
22 Swap Cost = New Cost - Previous Cost = 22 - 20 and 2 >0 As the swap cost is not less than
zero, we undo the swap. Hence (4, 5) and (8, 5) are the final medoids.
Advantages:
Disadvantages:
1. The main disadvantage of K-Medoid algorithms is that it is not suitable for clustering
non-spherical (arbitrarily shaped) groups of objects. This is because it relies on
minimizing the distances between the non-medoid objects and the medoid (the cluster
center) - briefly, it uses compactness as clustering criteria instead of connectivity.
2. It may obtain different results for different runs on the same dataset because the first k
medoids are chosen randomly.
OUTLIERS:
Outliers are data point that is essentially a statistical anomaly, a data point that significantly
deviates from other observations in a dataset. Outliers can arise due to measurement errors,
natural variation, or rare events, and they can have a disproportionate impact on statistical
analyses and machine learning models if not appropriately handled.
Example: If you have the following dataset of student test scores:
[85, 87, 90, 88, 92, 89, 45]
Note: Outliers can be valid observations or errors in data entry, mesurement, or processing.
Types of Outliers:
1. Global Outliers: Also known as point anomalies, these data points significantly differ
from the rest of the dataset.
2. Contextual Outliers: These are data points that are considered outliers in a specific
context. For example, a high temperature may be normal in summer but an outlier in
winter.
3. Collective Outliers: A collection of data points that deviate significantly from the rest
of the dataset, even if individual points within the collection are not outliers.
Outlier Detection:
Outliers can distort statistical analyses, leading to erroneous conclusions and misleading
interpretations. When calculating means, medians, or standard deviations, outliers can exert
disproportionate influence, skewing the results and undermining the validity of the analysis.
By detecting and appropriately addressing outliers, analysts can mitigate the impact of these
anomalies on statistical measures, ensuring that the insights drawn from the data are
representative and accurate.
Detecting outliers:
• Data Quality: Regular outlier detection is crucial to maintain the integrity and quality
of data, which in turn affects the decision-making processes based on this data.
Standard Deviation Method is based on the assumption that the data follows a normal
distribution. Data points outside of three standard deviations from the mean are considered
outliers.
It is commonly used for univariate data analysis where the distribution can be assumed to be
approximately normal.
Step 1: Calculate the average and standard deviation of the data set, if applicable.
Step 3: Identify outliers as data points that fall outside these bounds:
Example: Dataset: [1, 2, 2, 3, 1, 3, 10]. Find an outlier using the Standard Deviation Method.
2. IQR Method
The Interquartile Range (IQR) method focuses on the spread of the middle 50% of data. It
calculates the IQR as the difference between the 75th and 25th percentiles of the data and
identifies outliers as those points that fall below 1.5 times the IQR below the 25th percentile or
above 1.5 times the IQR above the 75th percentile. This method is robust to outliers and does
not assume a normal distribution.
• Step 1: Find Q1(25th percentage) and Q3(75th percentage)
• Step 2: IQR = Q3 - Q1.
• Step 3: Find Lower Bound: Q1 - 1.5 × IQR and Upper Bound Lower Bound: Q1 - 1.5
× IQR
It is suitable for datasets with skewed or non-normal distributions. Useful for identifying
outliers in datasets where the spread of the middle 50% of the data is more relevant than the
mean and standard deviation.
3. Z-Score Method
The Z-score method calculates the number of standard deviations each data point is from the
mean. A Z-score threshold is set, commonly 3, and any data point with a Z-score exceeding
this threshold is considered an outlier. This method assumes a normal distribution and is
sensitive to extreme values in small datasets.
• Step 4: Apply Threshold Rule: Mild outlier: |Z| > 2 and Extreme outlier: |Z| > 3
Suitable for datasets with large sample sizes and where the underlying distribution of the data
can be reasonably approximated by a normal distribution.
The choice of outlier detection technique depends on the characteristics of the data, the
underlying distribution, and the specific requirements of the analysis.
Challenges with Outlier Detection:
Detecting outliers effectively poses several challenges:
• Determining the Threshold: Deciding the correct threshold that accurately separates
outliers from normal data is critical and difficult.
• Distinguishing Noise from Outliers: In datasets with high variability or noise, it can
be particularly challenging to differentiate between noise and actual outliers.
Outlier detection plays a crucial role across various domains, enabling the identification of
anomalies that can indicate errors, fraud, or novel insights. Here are some key applications of
outlier detection with specific examples:
• Fraud Detection: Outlier detection is extensively used in the financial sector to identify
fraudulent activities. For instance, credit card companies use outlier detection
algorithms to flag unusual spending patterns that may indicate stolen card usage.
• Example: A credit card transaction for a large amount in a foreign country when the
cardholder usually makes small, local purchases could be flagged as an outlier,
triggering a fraud alert.
2. Cybersecurity
• Network Intrusion Detection: Outlier detection is critical in cybersecurity for
identifying unusual patterns of network traffic that could indicate a security breach.
• Example: A sudden increase in data transmission to an external IP address not
previously contacted by the network could be an outlier, suggesting a potential data
exfiltration attack.
3. AI/ML Modeling
Principal Component Analysis is an unsupervised learning algorithm that is used for the
dimensionality reduction in machine learning. It is a statistical process that converts the
observations of correlated features into a set of linearly uncorrelated features with the help of
orthogonal transformation. These new transformed features are called the Principal
Components. It is one of the popular tools that is used for exploratory data analysis and
predictive modeling. It is a technique to draw strong patterns from the given dataset by reducing
the variances.
PCA generally tries to find the lower-dimensional surface to project the high-dimensional data.
PCA works by considering the variance of each attribute because the high attribute shows the
good split between the classes, and hence it reduces the dimensionality. Some real-world
applications of PCA are image processing, movie recommendation system, optimizing the
power allocation in various communication channels. It is a feature extraction technique, so
it contains the important variables and drops the least important variable.
Properties:
o The principal component must be the linear combination of the original features.
o These components are orthogonal, i.e., the correlation between a pair of variables is
zero.
o The importance of each component decreases when going to 1 to n, it means the 1 PC
has the most importance, and n PC will have the least importance.
General Steps for PCA algorithm:
PCA Algorithm:
DBSCAN CLUSTERING:
DBSCAN is a density-based clustering algorithm that groups data points that are closely
packed together and marks outliers as noise based on their density in the feature space. It
identifies clusters as dense regions in the data space separated by areas of lower density. Unlike
K-Means or hierarchical clustering which assumes clusters are compact and spherical,
DBSCAN perform well in handling real-world data irregularities such as:
• Arbitrary-Shaped Clusters: Clusters can take any shape not just circular or convex.
• Noise and Outliers: It effectively identifies and handles noise points without assigning
them to any cluster.
The figure above shows a data set with clustering algorithms: K-Means and Hierarchical
handling compact, spherical clusters with varying noise tolerance while DBSCAN manages
arbitrary-shaped clusters and noise handling.
1. eps: This defines the radius of the neighborhood around a data point. If the distance between
two points is less than or equal to eps they are considered neighbors. A common method to
determine eps is by analyzing the k-distance graph. Choosing the right eps is important:
• If eps is too small most points will be classified as noise.
• If eps is too large clusters may merge and the algorithm may fail to distinguish between
them.
2. MinPts: This is the minimum number of points required within the eps radius to form a
dense region. A general rule of thumb is to set MinPts >= D+1 where D is the number of
dimensions in the dataset.
1. Core points which have a sufficient number of neighbors within a specified radius
(eplison)
2. Border points which are near core points but lack enough neighbors to be core points
themselves
2. Form Clusters: For each core point that is not already assigned to a cluster create a
new cluster. Recursively find all density-connected points i.e points within
the eps radius of the core point and add them to the cluster.
4. Label Noise Points: After processing all points any point that does not belong to a
cluster is labeled as noise.
DBSCAN K-Means
In DBSCAN we need not specify the number It is very sensitive to the number of clusters (k),
of clusters. which must be specified in advance.
Clusters formed in DBSCAN can be of any Clusters formed are spherical or convex in
arbitrary shape. shape
It can work well with datasets having noise It does not work well with outliers data.
and outliers Outliers can skew the clusters in K-Means to a
very large extent.
In DBSCAN two parameters are required for In K-Means only one parameter is required is
training the Model for training the model
Concept Description
Steps:
• It is a square matrix where each block represents the relationship between two
variables.
• Factor map (plots) show how categories and individuals are positioned.
Limitations:
Applications
• Market research (customer profiling, brand preference).
• Social sciences (survey analysis).
• U: This part tells you about the people (like their general preferences).
• Σ: This part shows how important each factor is (how much each rating matters).
• Vᵀ: This part tells you about the products (how similar they are to each other)
Lets understand this with help of an example: Suppose you have a small table of people’s
ratings for two movies,