You are on page 1of 6

Perhitungan KNN

Square distance
Id Sepal Sepal Petal Length PetalLength Species to query
Length Width
distance

1 5.4 3.4 1.7 0.2 Iris-Setosa 1.98

2 5.1 3.7 1.5 0.4 Iris-Setosa 1.22


3 4.6 3.6 1 0.2 Iris-Setosa 2.23
4 5.1 3.3 1.7 0.5 Iris-Setosa 1.29
5 4.8 3.4 1.9 0.2 Iris-Setosa 2.1
6 5.9 3.2 4.8 1.8 Iris-versicolor 11.98
7 6.1 2.8 4 1.3 Iris-versicolor 8.29
8 6.3 2.5 4.9 1.5 Iris-versicolor 14.69
9 6.1 2.8 4.7 1.2 Iris-versicolor 12.33
10 6.4 2.9 4.3 1.3 Iris-versicolor 10.38
11 6.9 3.2 5.7 2.3 Iris-virginica 21.88
12 5.6 2.8 4.9 2 Iris-virginica 13.06
13 7.7 2.8 6.7 2 Iris-virginica 35.05
14 6.3 2.7 4.9 1.8 Iris-virginica 14.3
15 6.7 3.3 5.7 2.1 Iris-virginica 20.81
Jarak Terkecil K1 K3 K5

3 Iris-Setosa Iris-Setosa Data Uji


Id
1 Iris-Setosa Iris-Setosa Iris-Setosa
5 Iris-Setosa -
2 Iris-Setosa Iris-Setosa
4 Iris-Setosa
8
6
12
9 Kategori Prediksi Specie
7 K1
14 Iris-Setosa
10
15
11
13
Petal PetalLen
Sepal Length Sepal Width
Length gth
5.1 3.8 1.5 1.5

Kategori Prediksi Species


K3 K5
Iris-Setosa Iris-Setosa
Iterasi 1
Data Fx Fy K1 K2 K3 K1Fx K1Fy K2Fx K2Fy
1 5.4 3.4 1 5.4 3.4 0
2 5.1 3.7 1 5.1 3.7 0
3 4.6 3.6 1 4.6 3.6 0
4 5.1 3.3 1 5.1 3.3 0
5 5.9 3.2 1 5.9 3.2
6 6.1 2.8 1 6.1 2.8
7 6.3 2.5 1 6.3 2.5
8 6.9 3.2 1 0
9 5.6 2.8 1 0
10 7.7 2.8 1 0
Total 4 3 3 20.2 14 18.3 8.5

Iterasi 2
Data Fx Fy K1 K2 K3 K1Fx K1Fy K2Fx K2Fy
1 5.4 3.4 1 5.4 3.4 0 0
2 5.1 3.7 1 5.1 3.7 0 0
3 4.6 3.6 1 4.6 3.6 0 0
4 5.1 3.3 1 5.1 3.3 0 0
5 5.9 3.2 1 0 0 5.9 3.2
6 6.1 2.8 1 0 0 6.1 2.8
7 6.3 2.5 1 0 0 6.3 2.5
8 6.9 3.2 1 0 0 0 0
9 5.6 2.8 1 0 0 5.6 2.8
10 7.7 2.8 1 0 0 0 0
Total 4 4 2 20.2 14 23.9 11.3
K3Fx K3Fy Jarak C1 Jarak C2 Jarak C3 Min Kelompok Baru
0 0 0.3640 0.9006 1.4126 0.3640 1
0 0 0.2062 1.3233 1.8043 0.2062 1
0 0 0.4610 1.6846 2.2351 0.4610 1
0 0 0.2062 1.1035 1.6740 0.2062 1
0 0 0.9014 0.4177 0.8750 0.4177 2
0 0 1.2619 0.0333 0.6472 0.0333 2
0 0 1.6008 0.3887 0.6128 0.3887 2
6.9 3.2 1.8742 0.8800 0.3145 0.3145 3
5.6 2.8 0.8902 0.5011 1.1411 0.5011 2
7.7 2.8 2.7409 1.6003 0.9758 0.9758 3
20.2 8.8

K3Fx K3Fy Jarak C1 Jarak C2 Jarak C3 Min Kelompok Baru


0 0 0.3640 0.8132 1.9416 0.3640 1
0 0 0.2062 1.2374 2.3087 0.2062 1
0 0 0.4610 1.5784 2.7659 0.4610 1
0 0 0.2062 0.9956 2.2204 0.2062 1
0 0 0.9014 0.3824 1.4142 0.3824 2
0 0 1.2619 0.1275 1.2166 0.1275 2
0 0 1.6008 0.4596 1.1180 0.4596 2
6.9 3.2 1.8742 0.9981 0.4472 0.4472 3
0 0 0.8902 0.3758 1.7117 0.3758 2
7.7 2.8 2.7409 1.7252 0.4472 0.4472 3
14.6 6
Hasil Centroid setiap cluster
Kelompok Lama K CFx Cfy
1 1 5.0500 3.5000
1 2 6.1000 2.8333
1 3 6.7333 2.9333
1
2
2
2
3
3
3

Hasil Centroid setiap cluster


Kelompok Lama K CFx Cfy
1 1 5.0500 3.5000
1 2 5.9750 2.8250
1 3 7.3000 3.0000
1
2
2
2
3
2
3

You might also like