0
8.2kviews
K-Nearest-Neighbor (KNN) Classifier Problem.

Apply KNN classification on the following dataset and predict the quality of paper_5 having Acid Durability = 3 and Strength = 7 for K= 3 (Nearest Neighbor).

The data from a survey and objective testing with two attributes (Acid durability and Strength) can be used to classify whether the quality of the sample paper is good or bad.

The below table shows four training samples

Sample Paper Acid Durability Strength Quality
Paper_1 7 7 Bad
Paper_2 7 4 Bad
Paper_3 3 4 Good
Paeper_4 1 4 Good

Now consider a new sample paper called Paper_5 that passes laboratory tests with Acid Durability = 3 and Strength = 7.

Without any expensive survey find out the quality of this new paper by using the KNN classifier.

1 Answer
0
1.7kviews

K-Nearest-Neighbor (KNN) Classifier Problem

Step 1

First, Number of parameters K = Number of nearest neighbors.

Therefore, from the given data K = 3


Step 2

Calculate the distance between the query instance and all the training samples.

Here query instance is (3,7) and calculates the distance by using the Euclidean Distance formula

$$ \sqrt {\sum_{j=1}^k (x_j - y_j)^2} $$

The below table shows the Euclidean Distance for every paper from the query instance (3, 7):

KNN 1


Step 3

Sort the distance and determine the nearest neighbors based on $K^{th}$ minimum distance

The below table shows the sorted distance and according to that nearest neighbor is decided for each paper:

KNN 2


Step 4

Collect the Quality of the nearest neighbors. Hence in the below, table Quality for Paper_2 is not included because the rank of this paper item is more than 3.

The below table shows the quality of each paper based on the nearest neighbor:

KNN 3


Step 5

Use the simple majority of the category of nearest neighbors as the prediction value of the query instance.

Here, it got 2 Good and 1 Bad value for the quality of nearest neighbors.

Hence, 2 Good > 1 Bad from which, the conclusion is that a new sample paper_5 that passes laboratory test with "Acid durability = 3" and "Strength = 7" is included in Good category quality.

Please log in to add an answer.