0% found this document useful (0 votes)
111 views4 pages

Lab Assignment 8: Nishiv Singh (B20MT029) Google Colab Notebooks Link: Task 1

The document summarizes two lab assignments on clustering algorithms: 1. The first task applies KMeans clustering to biological data on animals grouped into 4 clusters, as determined by analyzing cluster results with different numbers of clusters. 2. The second task performs agglomerative clustering on the same data, identifying 4 clusters in a dendrogram, and applies KMeans clustering with 4 clusters, visualizing the results. 3. A scratch implementation of KMeans clustering is described and applied to the animal data, also identifying 4 clusters.

Uploaded by

Nishiv Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views4 pages

Lab Assignment 8: Nishiv Singh (B20MT029) Google Colab Notebooks Link: Task 1

The document summarizes two lab assignments on clustering algorithms: 1. The first task applies KMeans clustering to biological data on animals grouped into 4 clusters, as determined by analyzing cluster results with different numbers of clusters. 2. The second task performs agglomerative clustering on the same data, identifying 4 clusters in a dendrogram, and applies KMeans clustering with 4 clusters, visualizing the results. 3. A scratch implementation of KMeans clustering is described and applied to the animal data, also identifying 4 clusters.

Uploaded by

Nishiv Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Report

Lab Assignment 8
Nishiv Singh (B20MT029)

Google Colab notebooks link :

Task 1 :
https://colab.research.google.com/drive/1YknZ7WZxuPGaUt9Yuk7K2X
uOm_FKMRP6?usp=sharing

Task 2
:https://colab.research.google.com/drive/1M7oXOz4s5M8awpX8P6KP
df2L7h3Ge667?usp=sharing

Task 1 :-

> Loaded the dataset , the dataset consists of different animals and their
respective biological details , the feature data has shape of (25*5).
> Here we have to categorize the data into different groups which was achieved
by KMeans clustering
> Implemented KMeans Clustering with different number of cluster groups which
are shown below.
Result :
Here we can see that 4 clusters are best grouping among the three graphs.So
we can conclude that the whole data can be divided into 4 groups and can be
studied further.

Task 2:-
> The data is the same as task 1 , so loaded the data and extracted feature data.

> Plotted a Dendrogram of the given feature data :


> Here we can see that the whole data can be ideally grouped in 4 clusters.

> Performed agglomerative clustering for different numbers of clusters and


linkage and then visualized the scatter plot thus obtained using 4 clusters.

> Written code for scratch model of KMeans Clustering, the steps are :

1. Imported useful libraries.


2. Made class K_means which contains various functions.
3. Here taken some default values of tolerance , max iteration and number of
clusters in case none of them are mentioned explicitly.
4. First initialized the centroids as random data points from within the data .
5. Then calculated the distances of all data points from these centroids and
then assign the data points to the nearest centroid.
6. Again changes the centroid to the mean of the assigned data points and
calculated the mean absolute error of the new centroid with previous one.
7. The steps 6 is repeated until mae(new_cent,prev_cent) < tolerance or the
number of iterations = max iteration.
8. Usually for data which have a tendency of grouping , the cluster forms
within 5-10 iterations.
9. Once the criteria is satisfied from step 6 , the class returns labels once
get_labels() function is called.

> So applied scratch model on the given dataset with n_clusters= 4 and got a
clustered graph which is shown below:
Result :
After applying KMeans Clustering we can see that as this is a unsupervised
learning method , it provides a quick information about data where grouping is
required like Malls,Colleges etc,

You might also like