# KNN Solved Example Diabetic Patient

[wptelegram-join-channel]

### KNN Solved Example to predict Sugar of Diabetic Patient given BMI and Age

Apply K nearest neighbor classifier to predict the diabetic patient with the given features BMI, Age. If the training examples are,

Assume K=3,

Test Example BMI=43.6, Age=40, Sugar=?

### Video Tutorial

The given training dataset has 10 instances with two features BMI (Body Mass Index) and Age. Sugar is the target label. The target label has two possibilities 0 and 1. 0 means the diabetic patient has no sugar and 1 means the diabetic patient has sugar.

Given the dataset and new test instance, we need to find the distance from the new test instance to every training example. Here we use the euclidean distance formula to find the distance.

In the next table, you can see the calculated distance from text example to training instances.

Once you calculate the distance, the next step is to find the nearest neighbors based on the value of k. In this case, the value of k is 3. Hence we need to find 3 nearest neighbors.

Now, we need to apply the majority voting technique to decide the resulting label fro the new example. Here the 1st and 2nd nearest neighbors have target label 1 and the 3rd nearest neighbor has target label 0. Target label 1 has the majority. Hence the new example is classified as 1, That is the diabetic patient has Sugar.

Test Example BMI=43.6, Age=40, Sugar=1

### Summary

Here you can find the solution to the KNN Example to predict the Sugar of Diabetic Patients given BMI and Age. If you like the material share it with your friends. Like the Facebook page for regular updates and YouTube channel for video tutorials.