﻿1
00:00:00,266 --> 00:00:02,833
Hello and welcome to this art tutorial.

2
00:00:02,833 --> 00:00:04,966
This tutorial is the fun tutorial

3
00:00:04,966 --> 00:00:08,700
because we did our job
by finding the optimal number of clusters.

4
00:00:08,700 --> 00:00:10,066
Thanks to the dendrogram,

5
00:00:10,066 --> 00:00:13,533
and by fitting the hierarchical clustering
algorithm to our data x.

6
00:00:13,800 --> 00:00:14,400
And now.

7
00:00:14,400 --> 00:00:19,200
So time we will be visualizing
our clusters using the class plot method.

8
00:00:19,666 --> 00:00:22,666
However,
we will not rewrite the whole code because

9
00:00:22,933 --> 00:00:26,966
as you will see, we made the exact
same code structure as we did for K-means.

10
00:00:27,300 --> 00:00:31,233
So now what I'm going to do
is I'm going to open our K-means code,

11
00:00:31,400 --> 00:00:33,666
and I will show you that
because we have the same code

12
00:00:33,666 --> 00:00:36,633
structure between K-means
and hierarchical clustering,

13
00:00:36,633 --> 00:00:39,766
we just need to replace
one tiny little thing to plot

14
00:00:39,766 --> 00:00:42,866
our five clusters
obtained by hierarchical clustering.

15
00:00:43,200 --> 00:00:45,200
So let's go to files here.

16
00:00:45,200 --> 00:00:48,933
Then let's click on these two dots
here to go back to our part

17
00:00:48,933 --> 00:00:52,700
three clustering folder
to find our K-means clustering folder.

18
00:00:53,466 --> 00:00:57,700
And in this K-means folder let's open
the K-means r r file.

19
00:00:58,333 --> 00:01:01,733
And now let's compare
our two codes for hierarchical clustering

20
00:01:01,733 --> 00:01:03,500
and K-means clustering.

21
00:01:03,500 --> 00:01:06,933
So in step one,
we both did exactly the same thing.

22
00:01:06,933 --> 00:01:09,000
We imported our small data set.

23
00:01:09,000 --> 00:01:12,533
Then in step two we looked
for the optimal number of clusters

24
00:01:12,533 --> 00:01:15,933
using two different methods
the elbow method for K-means

25
00:01:16,233 --> 00:01:19,233
and the dendrogram
for hierarchical clustering.

26
00:01:19,366 --> 00:01:23,200
Then in step three,
we fitted our algorithm to our data X

27
00:01:23,700 --> 00:01:27,933
and we created our vector of clusters
y k means in K-means.

28
00:01:28,666 --> 00:01:31,166
And you see in hierarchical clustering.

29
00:01:32,933 --> 00:01:34,000
And now if we look

30
00:01:34,000 --> 00:01:38,966
at the last step visualizing the clusters
in the K-means algorithm, we can see that

31
00:01:38,966 --> 00:01:43,900
the only thing in our code that is related
to K-means is a y k K-means vector.

32
00:01:43,900 --> 00:01:45,133
Here.

33
00:01:45,133 --> 00:01:49,300
And we have the same vector of clusters
in our hierarchical clustering code.

34
00:01:49,733 --> 00:01:51,000
It's y h c.

35
00:01:51,000 --> 00:01:52,533
So basically the only thing

36
00:01:52,533 --> 00:01:56,266
that we have to do to plot
our cluster is in hierarchical clustering

37
00:01:56,800 --> 00:02:00,300
is to take our class plot function here
with the same parameters.

38
00:02:02,400 --> 00:02:05,033
Copy it

39
00:02:05,033 --> 00:02:08,566
and paste it in our hierarchical
clustering visualizing the clusters.

40
00:02:09,000 --> 00:02:12,000
And then the only thing that we have to do
is to replace

41
00:02:12,000 --> 00:02:15,000
y k means by y axis.

42
00:02:15,266 --> 00:02:16,366
And now it's ready.

43
00:02:16,366 --> 00:02:18,600
Let's select our code section here.

44
00:02:18,600 --> 00:02:19,633
Execute it.

45
00:02:19,633 --> 00:02:24,266
And voila that's our hierarchical
clustering results.

46
00:02:25,800 --> 00:02:27,300
That's the end of this tutorial.

47
00:02:27,300 --> 00:02:29,900
But the fun continues
in the next tutorial,

48
00:02:29,900 --> 00:02:33,966
where we'll be analyzing our results
and explain what those clusters are.

49
00:02:34,433 --> 00:02:38,400
I will also explain how you can reuse
this code for any other business problem.

50
00:02:38,533 --> 00:02:41,066
And this will conclude our our tutorials.

51
00:02:41,066 --> 00:02:43,600
So I look forward to seeing you
in the next tutorial.

52
00:02:43,600 --> 00:02:46,600
And until then, enjoy machine learning.
