1.

What is the difference between kNN and k means clustering?

Answer»

This can be described in the below table.

kNN
K-means clustering
This is supervised machine learning
This is unsupervised machine learning
This is used for CLASSIFICATION and regression problems.
As the name suggests, it is a clustering algorithm.
This is based on feature similarity.
This DIVIDES objects or set of data points into clusters.
No such mechanism here.
Typically k=3 or based on elbow diagram, k value can be determined

For example, let’s consider a dataset of football PLAYERS, their positions, their measurements, etc. We want to assign a position to these players in a new dataset which is unseen by the model which is learned using earlier training data. We may use kNN algorithm since there are measurements, but no positions are KNOWN. At the same time, let’s say we have another scenario where we have a dataset of these football players who are to be grouped into some specific groups based on some similarity between them. In this case, k-means could be used. So, both of these are context specific to the problem we are trying to solve.



Discussion

No Comment Found

Related InterviewSolutions