In this session, we will discuss about the first machine learning links, unsupervised learning algorithm,
which is hierarchical clustering.
Hierarchical clustering is one of the popular and easy to understand clustering techniques, and it
is also known as agglomerated clustering Begbie.
So in this particular technique, what we do is we initially find out the distance between each data
point and each data point is considered as a cluster innocent.
Now, at each iteration, the similar clusters merge with another cluster on the one cluster or clusters
are formed.
So what they will do is.
We will simply have.
Different data, datapoint.
So each data point will be considered as a cluster actual.
Then we will create a matrix which will have the distance of each data point with other data point.
Then we will combine the nearest data datapoints.
In one particular group.
Then once we have these Meurice data points, they will again be combined to.
Another group and so on, so it will keep on combining different groups, fill the required number of
clusters which are required and reached.
So what we do here is it creates a hierarchy of clusters and presents the hierarchy, then drugan cortically
structure.
Now, this method does not require the number of clusters to be specified at the beginning because in
the beginning all the data points will be considered as individual clusters.
So we will be starting the process and going to the point where there is only one cluster left.
So all the planes will slowly and gradually be convoy combined into one single cluster, now we can
subdivide or stop at any point of time when we want to have or when we actually achieve the cluster's.
So the distance connectivity between the observations is measured.
So we will find out the distance between each and every data point.
So to find out each and every data points distance, we will need to have them skewed.
We cannot have age to be ranging from zero to hundred and amount to be ranging in age, because that
will be having a very large difference in the skin.
When we have large difference in the scale, then the distance, which will be between the ages, will
be diminished with due to the distance which would be present in the amount.
So what will happen?
Because age will have smaller distance.
So all that age data, all the data points which are closer in age, will be grouped together and there
will be no impact of.
And the amount of.
So what we do is in this, we apply a bottom up approach, so each observation starts in its own disaster
and the similarity or the distance between each cluster is computing.
And then we merged the two most similar ones, each operation, until there is only one cluster left.
Now, these are the big computing, the distance between each and every cluster after every iteration.
So you can see that this is so much computationally expensive because there will be a lot of competition
which will be required for this.
And because that is such a high in need of computation required, because of this particular reason,
it is feasible to use agglomerated flustering or hierarchical clustering only when we have a small dataset,
if they have a large dataset.
It will take a lot of time to compute this.
Now, a three that shows how clusters are merged, split or split hierarchically.
This is what the underground is.
Each node on the tree is a cluster that is each subtype here is a cluster.
If we go further, deeper into it, there are some clusters internally present.
So let us see if we want to have two clusters, then we can simply divide it here.
And one cluster would be this one and another cluster would be this one.
In case I want to have three clusters, then I can divide it here and now I have three clusters.
Similarly, if I want to have four clusters, I can divide it here.
And then I will have one, two, three.
I would clusters in her.
So this is how we find out the clusters.
Now, let's talk about a few properties of this clustering technique.
The first one is that it is computationally heavy, that is if we have a small dataset, then it will
work really fine.
But if we have a very large dataset, then we will not recommend someone to use hierarchical clustering.
Next is gives same cluster every time.
So we have several different clustering algorithms which will give different clusters.
But hierarchical clustering is one method which will always give the same clusters every day.
So there is no need to provide the number of clusters at the beginning because it will create the clusters
in the same method I at the time or after the clusters have been created, we can decide what number
of clusters we need.
Lastly, it is having a difficulty in handling different sized clusters and the irregular shapes.
So if there is data where we have clusters with different size or irregular shape, then it will be
a little difficult to handle.
So it will, because it will always try to combine clusters in a field of two.
So that is why it will always kind of end up having clusters of similar sites.
So this is about hierarchical clustering, how we actually implement this.
We will have a look at this in the next session.
Then we will implement this particular code for hierarchical clustering.