0% found this document useful (0 votes)
55 views18 pages

Chapter 7

Uploaded by

sara.ayubian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views18 pages

Chapter 7

Uploaded by

sara.ayubian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Chapter 4

Unlike Supervised Learning, here we don’t categorize


Machine Learning Models label the input!

Unsupervised Learning
Group 1

Group 2

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

Unsupervised Learning Models


This time we need to ask machine to label our
data
Features

Sepal Sepal Pedal Pedal


Length Width Length Width
Setosa
Versicolor Samples
Virginica

Labels

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

Unsupervised Learning Models


But How?!
Color

Size Similarity

Season

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

Unsupervised Learning Models

Similarity
Between all Unlabeled Samples

Distance

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

Unsupervised Learning Models


Clustering Techniques

Clustering

Centroid Based Hierarchical Density Based

K-Mean

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

K-Mean Partitioning the Samples into


K clusters

Step 1 Defining Number of Clusters (k)

k=2

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

K-Mean

Step 2 Randomly Centroid Selection

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

K-Mean

Step 3 Assign Each Point to the Nearest Centroid

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

K-Mean

Step 4 Update the centroid

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

K-Mean

Step 5 Repeating Previous Step until the Centroid does not Change Anymore

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

K-Mean
How to Calculate Distance?

 Euclidean
(A line connecting two points)

 Manhattan (Taxicab Geometry)


Using horizontal and vertical lines

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

K-Mean
Evaluation Metric

𝑛𝑛 𝑚𝑚
2 2
� d 𝑖𝑖, c1 + � d 𝑗𝑗, c2 d(i, c1 )
𝑖𝑖=1 𝑗𝑗=1 d(j, c2 )

Inertia

Smaller inertia

Better Clustering

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

K-Mean
Evaluation Metric
Elbow Method inertia

Elbow Point ≈ Optimal Point

Elbow Point

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

Unsupervised Learning Models


Clustering Techniques

Clustering

Centroid Based Hierarchical Density Based

K-Mean DBSCAN

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

Unsupervised Learning Models


DBSCAN Density-Based Spatial Clustering of Applications with Noise
Core
Noise
Parameters: eps

• eps

• MinPoints = 4
If No. of Points ≥ MinPoints Core

If No. of Points ≤ MinPoints Border


Border

There are no other points Noise

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

Unsupervised Learning Models


Clustering Techniques

Clustering

Centroid Based Hierarchical Density Based

K-Mean Linkage DBSCAN

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7
Unsupervised Learning Models
Hierarchical Clustering Dendrogram

Bottom-up approach

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi
Chapter 7

Hierarchical Clustering Complete Linkage


Linkage Method

Average Linkage

Single Linkage

Data Science & Machine Learning A-Z: Hands on Python Instructor: Navid Shirzadi

You might also like