12/10/26 Mon 15:38pm
KNN / K Nearest Neighbour Algorithm
It is a widely used Machine Learning algorithm for classification and regression tasks.
It works by identifying the K closest data points to the given inputs and making prediction based on the majority class or average value of those neighbours.
Steps to implement KNN
- Select the value of for prediction
- Calculate Euclidian Distance from the stored dataset
- Find the K nearest neighbour, the smallest euclidian distance
- Apply majority voting for classification (or) taking average for regression
Q&A
Question
A transformer predicts oil temperature after 10 minutes using present loading and present oil temperature. The historic data is given below,
using K = 3 Predict the temperature after 10 minutes if the present loading is 75% and present temp is 62
| Point | Loading % | Present Temperature | Temperature after 10 minutes |
|---|---|---|---|
| A | 50 | 50 | 52 |
| B | 60 | 55 | 58 |
| C | 70 | 60 | 64 |
| D | 80 | 65 | 70 |
| E | 90 | 70 | 76 |
| Solution: | |||
| Calculate the distance using the euclidian distance formula |
Question
A pump uses two features as vibration and as flow deficit the following historical data is given below.
Classify new observation (4,3) using K=3
| Data Point | Condition of Pump | ||
|---|---|---|---|
| A | 1 | 1 | Normal |
| B | 2 | 1 | Normal |
| C | 3 | 3 | Bearing Fault |
| D | 4 | 4 | Bearing Fault |
| E | 1 | 5 | Blockage |