0% found this document useful (0 votes)
14 views2 pages

Unsupervised Learning Techniques

K-Means Clustering is an unsupervised machine learning algorithm that organizes unlabeled data into K clusters based on similarity. K Nearest Neighbour (KNN) finds the nearest neighbors for a given data point and categorizes it based on the most common class among those neighbors. The document outlines the steps for KNN and provides an example to illustrate how to classify a new data point using Euclidean distance.

Uploaded by

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

Unsupervised Learning Techniques

K-Means Clustering is an unsupervised machine learning algorithm that organizes unlabeled data into K clusters based on similarity. K Nearest Neighbour (KNN) finds the nearest neighbors for a given data point and categorizes it based on the most common class among those neighbors. The document outlines the steps for KNN and provides an example to illustrate how to classify a new data point using Euclidean distance.

Uploaded by

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

K-Means Clustering:-

It is an unsupervised machine learning algorithm in which the unlabeled data set is


organized into
different clusters. Here K is number of clusters to be created in the process. It
is an iterative
algorithm that divides unlabeled dataset into K different clusters such that each
dataset that
belongs to one group has similar properties.

K Nearest Neighbour (KNN) :-

KNN is an algorithm which tries to find all the nearest neighbours for the given
data point. It
assumes similarity between new data and the available one and puts new data into
category that
is most similar to available categories. It can be used to solve problems of
classification as
well as regression.

Steps:-

(i) Select the number K of the neighbours.


(ii) Calculate Eucledian distance of K Number of Neighbours.
(iii) Take the K Nearest Neighbours as per calculated Eucledian distance.
(iv) Amongst K neighbours count the number of data points in each category
(v) Assign the new data points to that category for which the number of
neighbours is maximum.

16/11/22

Example:-

Consider below dataset for KNN algorithm.

X1 x2 CLASS
8 4 A
4 5 B
4 6 B
7 7 A
5 6 B
6 5 A

Here the data given for both coordinates indicates the point belongs to either
class A or
class B. Consider point (7,4), here the question is to decide to which class (7,4)
belongs.

For finding class of (7,4) we must find the distance of this point with respect to
all
the given datapoints.

Eucledian Distance formuala: sqrt[(X2-X1)+ (Y2-Y1)]


X1 X2 Dist Class
8 4 1 A
6 5 2 A
5 6 8 B
7 7 9 A
4 5 10 B
4 6 13 B

Here it means we will decide the class of point (7,4) by considering the class of
first nearest
neighbour.

Arrange distance in ascending order:-


1,2,8,9,10,13

Here we will take only first neighbour from the list since K = 1. The class for
that neighbour is
class A. Hence datapoint (7,4) belongs to class A.

You might also like