| Height (CM) | Weight (KG) | Class |
|---|---|---|
| 167 | 51 | Underweight |
| 182 | 62 | Normal |
| 176 | 69 | Normal |
| 173 | 64 | Normal |
| 172 | 65 | Normal |
| 174 | 56 | Underweight |
| 169 | 58 | Normal |
| 173 | 57 | Normal |
| 170 | 55 | Normal |
| 170 | 57 | ? |
X = [
[167, 51],
[182, 62],
[176, 69],
[173, 64],
[172, 65],
[174, 56],
[169, 58],
[173, 57],
[170, 55]
]
y = ['Underweight', 'Normal', 'Normal', 'Normal', 'Normal', 'Underweight', 'Normal', 'Normal', 'Normal']
x = [[170, 57]]
$$d(x,y) = \sqrt{\sum{(x_i - y_i)^2}}$$
Select k = 5
from sklearn.metrics.pairwise import euclidean_distances
euclidean_distances(X, x)
from sklearn.neighbors import KNeighborsClassifier
classifier = KNeighborsClassifier(n_neighbors = 5)
classifier.fit(X, y)
x = [[170, 57]]
classifier.predict(x)
classifier.predict_proba(x)
classifier.score(X, y)
| Brightness | Saturation | Class |
|---|---|---|
| 40 | 20 | Red |
| 50 | 50 | Blue |
| 60 | 90 | Blue |
| 10 | 25 | Red |
| 70 | 70 | Blue |
| 60 | 10 | Red |
| 25 | 80 | Blue |
| 20 | 35 | ? |
| Youtube | https://www.youtube.com/watch?v=HZT0lxD5h6k https://www.youtube.com/watch?v=T0YkfWssHjk |
|---|---|
| sklearn | https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html |