All right.
So let's start from the top. We have to start from the top.
And so from the top it goes this way.
We start from here.
That's the first horizontal bar.
And when I move down you know move down like that.
There you go.
That's when I meet the next horizontal bar.
You know this one.
So actually we made very small vertical distance here,
which means that indeed the optimal number of clusters is definitely not two.
Right. Because here we have two vertical bars.
Then the next step is to start from this second horizontal bar.
And so let's do this with our mouse.
All right.
We start from here the second horizontal bar.
And we're going to go down until we meet the next horizontal bar
which is right here. This one right.
That's the second horizontal bar. This was the first.
And from this first to the second.
Well we made that vertical distance. Okay.
So that's pretty big.
Which means that maybe, you know, if it is the largest vertical move we can make.
Well, in that case, the optimal number of clusters would be one, two, three.
You know the number of vertical bars we have
within this vertical move, this one, this one and this one.
So that would go for three clusters.
All right. So maybe that's the optimal number of clusters.
But then let's continue.
Let's continue from here. Right.
So we're going to continue from here.
That last horizontal bar we met.
And now I'm going to expand over here.
And same we're going to go down until we meet the next horizontal bar.
And there we go. That's the next horizontal bar.
And here we made a small vertical distance.
So definitely
it is shorter than the previous vertical distance we made just before.
And therefore the optimal number of clusters is definitely not one, two
three and four. It's definitely not four.
Okay. Okay. But let's continue.
Maybe there is a higher vertical move we can make in the next step.
And you know exactly that.
This is going to be the case because we already did K-means.
But there we go.
That's next move.
We start from here.
That last horizontal bar we met.
And I'm going to expand this in order to, you know, not miss any horizontal bar.
And actually I should even take
the whole width, you know, I should take exactly this.
All right.
So that we can make sure we don't miss any horizontal bar.
So we start from here, and here we go.
Let's move down, let's move down, move down. Move.
Don't move down until we meet the next horizontal bar.
And here we go.
Right.
You see, that's the next horizontal bar we met the one from that last cluster
here.
And well, now the question is, is that vertical move.
You know, vertical distance
we just made here bigger than the one we made in the second step.
Meaning this one.
Well it seems to be the case, right.
It seems to be that this vertical distance is actually larger
than, you know, this vertical distance.
How could we actually measure this, you know, to be exactly. Sure.
Well, have a look at, you know, the pixel here 264 times 66.
I don't know if you can see it.
Well, but if I move up.
Remember there was 66.
Well actually zero okay. So that's very easy.
So there are actually 66 pixels here.
All right. Cool.
And now let's do this again here from that horizontal bar
and up to here.
And wow okay.
So that was very short actually
because here the vertical distance is actually 67 pixel.
You see it, you know 272 times 67 272 is actually the width of that rectangle.
I just made with my mouse.
And 67 is the height. And that's the height.
We're interesting because that corresponds to the distance of the vertical move.
So actually 67 versus 66.
So well you know three clusters is actually a good number of clusters.
But you know, since we already did it with K-means and on the elbow method,
we clearly identified that the optimal number of clusters was five.
Well, we're going to take that one pixel difference here
in order to still keep well five as the optimal number of clusters.
But it's really interesting that we did this dendrogram.
I actually didn't notice before that we were so close from my vision.
I had the impression that this distance was larger, but there you go.
This one was also very good.
Let's check it again, because I just want to make sure.
Yeah 66 but even, you know, 67
depends down to where you go exactly in that horizontal bar.
Actually, you know, to make it super thorough
we would need to start from here, you know, at the bottom
of the horizontal bar up to the top of the next vertical bar.
So here we have 65.
And for that next distance.
Well, you know
I'm starting from the bottom of the horizontal bar and going here 65.
The same is the same.
So actually three clusters of five clusters is very good.
And so feel free to, you know, continue this implementation with either 3 or 5.
But since with K-means we identified five clusters as the optimal number
of clusters, well, we're still going to go with five here, but there you go.
That's a very good example because indeed in some situations
we can have two optimal number of clusters.
All right.
So I'm really glad I showed you this.
And mostly this shows you the importance of trying several models
because indeed having another model can give you extra insight
when doing your machine learning task.
And with hierarchical clustering, that extra insight
is that three clusters actually makes a lot of sense as well.
So there you go.
Make sure to keep hierarchical clustering in your toolkit in order to get
these extra insights in your future data sets for your future clustering problems.
All right. Perfect.
So let's close this and let's go back to our implementation.
And now for the next step we're going to train that hierarchical
clustering model with as we said five clusters in the next tutorial.
And until then enjoy clustering and machine learning.