Clustering with DBSCAN, Clearly Explained!!!

StatQuest with Josh Starmer · Beginner ·📄 Research Papers Explained ·4y ago

Key Takeaways

The video explains the DBSCAN clustering algorithm, which can handle nested clusters in high-dimensional data. It demonstrates how DBSCAN works by identifying clusters based on point densities, using a user-defined radius and minimum number of close points to define core points.

Full Transcript

dp scan clusters just like a person can statquest [Music] hello i'm josh starmer and welcome to statquest today we're going to talk about clustering with db scan and it's going to be clearly explained now imagine we collected weight and height measurements from a bunch of people and we plotted the people on a two-dimensional graph like this where we have weight on the x-axis the first dimension and height on the y-axis the second dimension by eye we can see two different clusters by identifying two different but relatively dense clumps of people in contrast these people that are far from everyone else look a little bit like outliers so by eye clustering this data is pretty easy however because these clusters are nested meaning the green cluster wraps around the blue cluster a relatively standard clustering method like k-means clustering might have difficulty identifying these two clusters instead because of the nesting a simple clustering method might get something weird like this where these points are assigned to the blue cluster even though they look like they belong to the green cluster so we need a clustering algorithm that can handle nested clusters also remember this two-dimensional graph only uses weight and height data but if we wanted to include each person's age we would have to add a third axis and now our graph is three-dimensional drawing a three-dimensional graph on a two-dimensional computer screen is awkward but possible however if we wanted to include four or more features we'd need to draw a four or more dimensional graph and that's not possible and if we can't draw and look at a four or more dimensional graph then we need a way to identify nested clusters that we cannot see by eye the good news is that there are clustering algorithms that can identify nested clusters in high dimensions one of these algorithms is called db scan and that's what we'll talk about today so let's go back to the original two-dimensional graph and see how db scan tries to mimic what we can easily do by eye now remember by eye we identify clusters by the densities of the points clusters are in high density regions and outliers tend to be in low density regions so let's see how dbscan uses the densities of the points to identify these two clusters bam now starting with the raw unclustered data the first thing we can do is count the number of points close to each point for example if we start with this red point and we draw an orange circle around it then we can see that the orange circle overlaps at least partially eight other points so the red point is close to eight other points note the radius of the orange circle is user defined so when using dbscan you may need to fiddle around with this parameter now this red point is close to five other points because the orange circle overlaps at least partially five other points this red point is close to six other points and this red point is close to seven other points this red point is only close to two other points and this red point is not close to any other point because the orange circle does not overlap anything else likewise for all the remaining points we count the number of close points now in this example we will define a core point to be one that is close to at least four other points note the number of close points for a core point is user defined so when using db scan you might need to fiddle with this parameter as well anyway these four points are some of the core points because their orange circles overlap at least four other points hooray but neither of these points are core points because their orange circles do not overlap four or more other points ultimately we can call all of these red points core points because they are all close to four or more other points and the remaining points are non-core now we randomly pick a core point and assign it to the first cluster next the core points that are close to the first cluster meaning they overlap the orange circle are all added to the first cluster then the core points that are close to the growing first cluster join it and extend it to other core points that are close by here we see two core points and one non-core point that are all close to the growing first cluster and at this point we only add the core points to the first cluster that said eventually we will add this non-core point but right now we are only adding core points ultimately all of the core points that are close to the growing first cluster are added to it and then used to extend it further bam note at this point every single point in the first cluster is a core point and because we can no longer add any more core points to the first cluster we add all of the non-core points that are close to the core points to the first cluster for example this point which is a non-core point is close to a core point in the first cluster so we add it to the first cluster however because this is not a core point we do not use it to extend the first cluster any further that means that this other non-core point which is close to the non-core point that was just made part of the first cluster will not be added to the first cluster because it is not close to a core point so unlike core points non-core points can only join a cluster they cannot extend it further now we add all of the non-core points that are close to core points in the first cluster to the first cluster and now we are done creating the first cluster double bam to summarize how the first cluster was formed we picked a random core point and it started the first cluster then neighboring core points joined and extended the first cluster [Laughter] and non-core points only joined the first cluster bam now because none of these core points are close to the first cluster they form a new second cluster because they are close to each other and the non-core points that are close to the second cluster are added to it lastly because all of the core points have been assigned to a cluster we're done making new clusters and any remaining non-core points that are not close to core points in either cluster are not added to clusters and called outliers and that is how the db scan algorithm works triple bam note as we just saw clusters are created sequentially that means if we had a non-core point close to both clusters then when we built the first cluster beep we would add this non-core point to the first cluster because it is close to a core point along with all of the other non-core points that were close and now that this point is part of the first cluster it is no longer eligible to be in any other cluster small bam now it's time for some shameless self-promotion if you want to review statistics and machine learning offline check out the statquest study guides at statquest.org there's something for everyone hooray we've made it to the end of another exciting stat quest if you like this stat quest and want to see more please subscribe and if you want to support statquest consider contributing to my patreon campaign becoming a channel member buying one or two of my original songs or a t-shirt or a hoodie or just donate the links are in the description below alright until next time quest on

Original Description

DBSCAN is a super useful clustering algorithm that can handle nested clusters with ease. This StatQuest shows you exactly how it works. BAM! For a complete index of all the StatQuest videos, check out: https://statquest.org/video-index/ If you'd like to support StatQuest, please consider... Patreon: https://www.patreon.com/statquest ...or... YouTube Membership: https://www.youtube.com/channel/UCtYLUTtgS3k1Fg4y5tAhLbw/join ...buying one of my books, a study guide, a t-shirt or hoodie, or a song from the StatQuest store... https://statquest.org/statquest-store/ ...or just donating to StatQuest! https://www.paypal.me/statquest Lastly, if you want to keep up with me as I research and create new StatQuests, follow me on twitter: https://twitter.com/joshuastarmer 0:00 Awesome song and introduction 1:01 The problems solved by DBSCAN 3:00 How DBSCAN works 8:12 How DBSCAN deals with ties #StatQuest #DBSCAN #Clustering
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from StatQuest with Josh Starmer · StatQuest with Josh Starmer · 0 of 60

← Previous Next →
1 Cutting Butter
Cutting Butter
StatQuest with Josh Starmer
2 onion-dice
onion-dice
StatQuest with Josh Starmer
3 R-squared, Clearly Explained!!!
R-squared, Clearly Explained!!!
StatQuest with Josh Starmer
4 Wrapping up dumplings for pot stickers.
Wrapping up dumplings for pot stickers.
StatQuest with Josh Starmer
5 The standard error, Clearly Explained!!!
The standard error, Clearly Explained!!!
StatQuest with Josh Starmer
6 That Dude (in the movies)
That Dude (in the movies)
StatQuest with Josh Starmer
7 How to puree garlic
How to puree garlic
StatQuest with Josh Starmer
8 Confidence Intervals, Clearly Explained!!!
Confidence Intervals, Clearly Explained!!!
StatQuest with Josh Starmer
9 RPKM, FPKM and TPM, Clearly Explained!!!
RPKM, FPKM and TPM, Clearly Explained!!!
StatQuest with Josh Starmer
10 Principal Component Analysis (PCA) clearly explained (2015)
Principal Component Analysis (PCA) clearly explained (2015)
StatQuest with Josh Starmer
11 StatQuest: RNA-seq - the problem with technical replicates
StatQuest: RNA-seq - the problem with technical replicates
StatQuest with Josh Starmer
12 That's Alright
That's Alright
StatQuest with Josh Starmer
13 Christmas In Rio! (now on iTunes!)
Christmas In Rio! (now on iTunes!)
StatQuest with Josh Starmer
14 Drawing and Interpreting Heatmaps
Drawing and Interpreting Heatmaps
StatQuest with Josh Starmer
15 Rachel's Song (the ballad of Hazel Motes)
Rachel's Song (the ballad of Hazel Motes)
StatQuest with Josh Starmer
16 Deal With It
Deal With It
StatQuest with Josh Starmer
17 Say Your Goodbyes
Say Your Goodbyes
StatQuest with Josh Starmer
18 Another Day
Another Day
StatQuest with Josh Starmer
19 StatQuest: Linear Discriminant Analysis (LDA) clearly explained.
StatQuest: Linear Discriminant Analysis (LDA) clearly explained.
StatQuest with Josh Starmer
20 Maybe It'll Go Away
Maybe It'll Go Away
StatQuest with Josh Starmer
21 Nasty Weather
Nasty Weather
StatQuest with Josh Starmer
22 Roses
Roses
StatQuest with Josh Starmer
23 p-hacking and power calculations
p-hacking and power calculations
StatQuest with Josh Starmer
24 I Love You
I Love You
StatQuest with Josh Starmer
25 The Coldest Day of the Year
The Coldest Day of the Year
StatQuest with Josh Starmer
26 Psycho Killer
Psycho Killer
StatQuest with Josh Starmer
27 False Discovery Rates, FDR, clearly explained
False Discovery Rates, FDR, clearly explained
StatQuest with Josh Starmer
28 A New Song
A New Song
StatQuest with Josh Starmer
29 StatQuickie: Thresholds for Significance
StatQuickie: Thresholds for Significance
StatQuest with Josh Starmer
30 Logs (logarithms), Clearly Explained!!!
Logs (logarithms), Clearly Explained!!!
StatQuest with Josh Starmer
31 Bar Charts Are Better than Pie Charts
Bar Charts Are Better than Pie Charts
StatQuest with Josh Starmer
32 Mr  Hattie
Mr Hattie
StatQuest with Josh Starmer
33 StatQuickie: Which t test to use
StatQuickie: Which t test to use
StatQuest with Josh Starmer
34 Fisher's Exact Test and the Hypergeometric Distribution
Fisher's Exact Test and the Hypergeometric Distribution
StatQuest with Josh Starmer
35 Standard Deviation vs Standard Error, Clearly Explained!!!
Standard Deviation vs Standard Error, Clearly Explained!!!
StatQuest with Josh Starmer
36 StatQuest: DESeq2, part 1, Library Normalization
StatQuest: DESeq2, part 1, Library Normalization
StatQuest with Josh Starmer
37 The Rainbow
The Rainbow
StatQuest with Josh Starmer
38 StatQuest: edgeR, part 1, Library Normalization
StatQuest: edgeR, part 1, Library Normalization
StatQuest with Josh Starmer
39 The Main Ideas behind Probability Distributions
The Main Ideas behind Probability Distributions
StatQuest with Josh Starmer
40 StatQuest:  One or Two Tailed P-Values
StatQuest: One or Two Tailed P-Values
StatQuest with Josh Starmer
41 Evil Genius
Evil Genius
StatQuest with Josh Starmer
42 Sampling from a Distribution, Clearly Explained!!!
Sampling from a Distribution, Clearly Explained!!!
StatQuest with Josh Starmer
43 StatQuest: edgeR and DESeq2, part 2 - Independent Filtering
StatQuest: edgeR and DESeq2, part 2 - Independent Filtering
StatQuest with Josh Starmer
44 The Main Ideas of Fitting a Line to Data (The Main Ideas of Least Squares and Linear Regression.)
The Main Ideas of Fitting a Line to Data (The Main Ideas of Least Squares and Linear Regression.)
StatQuest with Josh Starmer
45 The Sum of Regrets
The Sum of Regrets
StatQuest with Josh Starmer
46 Lowess and Loess, Clearly Explained!!!
Lowess and Loess, Clearly Explained!!!
StatQuest with Josh Starmer
47 StatQuest: Hierarchical Clustering
StatQuest: Hierarchical Clustering
StatQuest with Josh Starmer
48 StatQuest: K-nearest neighbors, Clearly Explained
StatQuest: K-nearest neighbors, Clearly Explained
StatQuest with Josh Starmer
49 Your Dark Side
Your Dark Side
StatQuest with Josh Starmer
50 Boxplots are Awesome!!!
Boxplots are Awesome!!!
StatQuest with Josh Starmer
51 What is a (mathematical) model?
What is a (mathematical) model?
StatQuest with Josh Starmer
52 Linear Regression, Clearly Explained!!!
Linear Regression, Clearly Explained!!!
StatQuest with Josh Starmer
53 Linear Regression in R, Step-by-Step
Linear Regression in R, Step-by-Step
StatQuest with Josh Starmer
54 Maximum Likelihood, clearly explained!!!
Maximum Likelihood, clearly explained!!!
StatQuest with Josh Starmer
55 Brothers
Brothers
StatQuest with Josh Starmer
56 Using Linear Models for t-tests and ANOVA, Clearly Explained!!!
Using Linear Models for t-tests and ANOVA, Clearly Explained!!!
StatQuest with Josh Starmer
57 StatQuest: How to make a Mean Pizza Crust!!!
StatQuest: How to make a Mean Pizza Crust!!!
StatQuest with Josh Starmer
58 StatQuest: A gentle introduction to RNA-seq
StatQuest: A gentle introduction to RNA-seq
StatQuest with Josh Starmer
59 I'm Alive
I'm Alive
StatQuest with Josh Starmer
60 StatQuest: t-SNE, Clearly Explained
StatQuest: t-SNE, Clearly Explained
StatQuest with Josh Starmer

The DBSCAN clustering algorithm can handle nested clusters in high-dimensional data by identifying clusters based on point densities. It uses a user-defined radius and minimum number of close points to define core points, which are then used to form clusters.

Key Takeaways
  1. Define the radius and minimum number of close points for core points
  2. Identify core points and non-core points
  3. Form clusters by adding core points and non-core points
  4. Assign non-core points to clusters based on proximity to core points
  5. Identify outliers as non-core points not close to any cluster
💡 DBSCAN can handle nested clusters in high-dimensional data by focusing on point densities rather than distance between points

Related Reads

Chapters (4)

Awesome song and introduction
1:01 The problems solved by DBSCAN
3:00 How DBSCAN works
8:12 How DBSCAN deals with ties
Up next
The Secret Methodology Structure Q1 Reviewers Expect (But Journals Never Tell You)
Academic English Now
Watch →