4.71 out of 5
4107 reviews on Udemy

Cluster Analysis and Unsupervised Machine Learning in Python

Data science techniques for pattern recognition, data mining, k-means clustering, and hierarchical clustering, and KDE.
Lazy Programmer Team
21,859 students enrolled
English [Auto] More
Understand the regular K-Means algorithm
Understand and enumerate the disadvantages of K-Means Clustering
Understand the soft or fuzzy K-Means Clustering algorithm
Implement Soft K-Means Clustering in Code
Understand Hierarchical Clustering
Explain algorithmically how Hierarchical Agglomerative Clustering works
Apply Scipy's Hierarchical Clustering library to data
Understand how to read a dendrogram
Understand the different distance metrics used in clustering
Understand the difference between single linkage, complete linkage, Ward linkage, and UPGMA
Understand the Gaussian mixture model and how to use it for density estimation
Write a GMM in Python code
Explain when GMM is equivalent to K-Means Clustering
Explain the expectation-maximization algorithm
Understand how GMM overcomes some disadvantages of K-Means
Understand the Singular Covariance problem and how to fix it

Cluster analysis is a staple of unsupervised machine learning and data science.

It is very useful for data mining and big data because it automatically finds patterns in the data, without the need for labels, unlike supervised machine learning.

In a real-world environment, you can imagine that a robot or an artificial intelligence won’t always have access to the optimal answer, or maybe there isn’t an optimal correct answer. You’d want that robot to be able to explore the world on its own, and learn things just by looking for patterns.

Do you ever wonder how we get the data that we use in our supervised machine learning algorithms?

We always seem to have a nice CSV or a table, complete with Xs and corresponding Ys.

If you haven’t been involved in acquiring data yourself, you might not have thought about this, but someone has to make this data!

Those “Y”s have to come from somewhere, and a lot of the time that involves manual labor.

Sometimes, you don’t have access to this kind of information or it is infeasible or costly to acquire.

But you still want to have some idea of the structure of the data. If you’re doing data analytics automating pattern recognition in your data would be invaluable.

This is where unsupervised machine learning comes into play.

In this course we are first going to talk about clustering. This is where instead of training on labels, we try to create our own labels! We’ll do this by grouping together data that looks alike.

There are 2 methods of clustering we’ll talk about: k-means clustering and hierarchical clustering.

Next, because in machine learning we like to talk about probability distributions, we’ll go into Gaussian mixture models and kernel density estimation, where we talk about how to “learn” the probability distribution of a set of data.

One interesting fact is that under certain conditions, Gaussian mixture models and k-means clustering are exactly the same! We’ll prove how this is the case.

All the algorithms we’ll talk about in this course are staples in machine learning and data science, so if you want to know how to automatically find patterns in your data with data mining and pattern extraction, without needing someone to put in manual work to label that data, then this course is for you.

All the materials for this course are FREE. You can download and install Python, Numpy, and Scipy with simple commands on Windows, Linux, or Mac.

This course focuses on “how to build and understand“, not just “how to use”. Anyone can learn to use an API in 15 minutes after reading some documentation. It’s not about “remembering facts”, it’s about “seeing for yourself” via experimentation. It will teach you how to visualize what’s happening in the model internally. If you want more than just a superficial look at machine learning models, this course is for you.

“If you can’t implement it, you don’t understand it”

  • Or as the great physicist Richard Feynman said: “What I cannot create, I do not understand”.

  • My courses are the ONLY courses where you will learn how to implement machine learning algorithms from scratch

  • Other courses will teach you how to plug in your data into a library, but do you really need help with 3 lines of code?

  • After doing the same thing with 10 datasets, you realize you didn’t learn 10 things. You learned 1 thing, and just repeated the same 3 lines of code 10 times…

Suggested Prerequisites:

  • matrix addition, multiplication

  • probability

  • Python coding: if/else, loops, lists, dicts, sets

  • Numpy coding: matrix and vector operations, loading a CSV file


  • Check out the lecture “Machine Learning and AI Prerequisite Roadmap” (available in the FAQ of any of my courses, including the free Numpy course)

Introduction to Unsupervised Learning

Course Outline
What is unsupervised learning used for?

This lecture describes what unsupervised machine learning (not just clustering) is used for in general.

There are 2 major categories:

1) density estimation

If we can figure out the probability distribution of the data, not only is this a model of the data, but we can then sample from the distribution to generate new data.

For example, we can train a model to read lots of Shakespeare and then generate writing in the style of Shakespeare.

2) latent variables

This allows us to find the underlying cause of the data we've observed by reducing it to a small set of factors.

For example, if we measure the heights of all the people in our class and plot them on a histogram, we may notice 2 "bumps".

These "bumps" correspond to male heights and female heights.

Thus, being male or female is the hidden cause of higher / lower height values.

Clustering does exactly this - it tells us how the data can be split up into distinct groups / segments / categories.

Unsupervised machine learning can also be used for:

  • dimensionality reduction - modern datasets can have millions of features, but many of them may be correlated

  • visualization - you can't see a million-dimensional dataset, but if you reduce the dimensionality to 2, then it can be visualized

Why Use Clustering?
Where to get the code
How to Succeed in this Course

K-Means Clustering

An Easy Introduction to K-Means Clustering
Hard K-Means: Exercise Prompt 1
Hard K-Means: Exercise 1 Solution
Hard K-Means: Exercise Prompt 2
Hard K-Means: Exercise 2 Solution
Hard K-Means: Exercise Prompt 3
Hard K-Means: Exercise 3 Solution
Hard K-Means Objective: Theory
Hard K-Means Objective: Code
Soft K-Means
The Soft K-Means Objective Function
Soft K-Means in Python Code
How to Pace Yourself
Visualizing Each Step of K-Means
Examples of where K-Means can fail
Disadvantages of K-Means Clustering
How to Evaluate a Clustering (Purity, Davies-Bouldin Index)
Using K-Means on Real Data: MNIST
One Way to Choose K
K-Means Application: Finding Clusters of Related Words
Clustering for NLP and Computer Vision: Real-World Applications
Suggestion Box

Hierarchical Clustering

Visual Walkthrough of Agglomerative Hierarchical Clustering
Agglomerative Clustering Options

Learn about the different possible distance metrics that can be used for both k-means and agglomerative clustering, and what constitutes a valid distance metric. Learn about the different linkage methods for hierarchical clustering, like single linkage, complete linkage, UPGMA, and Ward linkage.

Using Hierarchical Clustering in Python and Interpreting the Dendrogram
Application: Evolution
Application: Donald Trump vs. Hillary Clinton Tweets

Gaussian Mixture Models (GMMs)

Gaussian Mixture Model (GMM) Algorithm
Write a Gaussian Mixture Model in Python Code
Practical Issues with GMM / Singular Covariance
Comparison between GMM and K-Means
Kernel Density Estimation
GMM vs Bayes Classifier (pt 1)
GMM vs Bayes Classifier (pt 2)
Expectation-Maximization (pt 1)
Expectation-Maximization (pt 2)
Expectation-Maximization (pt 3)
Future Unsupervised Learning Algorithms You Will Learn

Setting Up Your Environment (FAQ by Student Request)

Windows-Focused Environment Setup 2018
How to install Numpy, Scipy, Matplotlib, Pandas, IPython, Theano, and TensorFlow

Extra Help With Python Coding for Beginners (FAQ by Student Request)

How to Code by Yourself (part 1)
How to Code by Yourself (part 2)
Proof that using Jupyter Notebook is the same as not using it
Python 2 vs Python 3

Effective Learning Strategies for Machine Learning (FAQ by Student Request)

How to Succeed in this Course (Long Version)
Is this for Beginners or Experts? Academic or Practical? Fast or slow-paced?
Machine Learning and AI Prerequisite Roadmap (pt 1)
Machine Learning and AI Prerequisite Roadmap (pt 2)

Appendix / FAQ Finale

What is the Appendix?
BONUS: Where to get discount coupons and FREE deep learning material
You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.7 out of 5
4107 Ratings

Detailed Rating

Stars 5
Stars 4
Stars 3
Stars 2
Stars 1
30-Day Money-Back Guarantee


8 hours on-demand video
Full lifetime access
Access on mobile and TV
Certificate of Completion
Cluster Analysis and Unsupervised Machine Learning in Python


For Professionals

For Businesses

We support Sales, Marketing, Account Management and CX professionals. Learn new skills. Share your expertise. Connect with experts. Get inspired.


Partnership Opportunities

Layer 1
Register New Account
Compare items
  • Total (0)