A- 1
LAMPIRAN A KLUSTER SOM DAN VALIDASI RMSSTD A. Algoritma SOM
Berikut ini merupakan source code algoritma SOM kluster 3 – kluster 6: B. Perhitungan Kluster
Berikut ini merupakan source code untuk kluster B, yang hasilnya memiliki 3 kluster Source Code Kluster 3 SOM % inisialisasi data ht=0.6; % melakukan random weight weight1=[0.1875 0.7690 0.3960 0.4600]; weight2=[0.2729 0.4517 0.6099 0.7421]; weight3=[0.0594 0.1253 0.1302 0.4574]; for i=1:4000; a=(weight1(1,1)-data(i,1))^2+(weight1(1,2)data(i,2))^2+(weight1(1,3)-data(i,3))^2; b=(weight2(1,1)-data(i,1))^2+(weight2(1,2)data(i,2))^2+(weight2(1,3)-data(i,3))^2; c=(weight3(1,1)-data(i,1))^2+(weight3(1,2)data(i,2))^2+(weight3(1,3)-data(i,3))^2;
if a
2
else if b
A- 3
Berikut ini merupakan source code kluster c, yang memiliki hasil 4 kluster Source Code Kluster 4 % inisialisasi Data ht=0.6;
%melakukan random weight weight1=[0.1875 0.7690 0.3960 0.4600]; weight2=[0.2729 0.4517 0.6099 0.7421]; weight3=[0.0594 0.1253 0.1302 0.4574]; weight4=[0.0924 0.7229 0.5312 0.4327];
for i=1:4000; a=(weight1(1,1)-Data(i,1))^2+(weight1(1,2)Data(i,2))^2+(weight1(1,3)-Data(i,3))^2+(weight1(1,4)Data(i,4))^2; b=(weight2(1,1)-Data(i,1))^2+(weight2(1,2)Data(i,2))^2+(weight2(1,3)-Data(i,3))^2+(weight1(1,4)Data(i,4))^2; c=(weight3(1,1)-Data(i,1))^2+(weight3(1,2)Data(i,2))^2+(weight3(1,3)-Data(i,3))^2+(weight1(1,4)Data(i,4))^2; d=(weight4(1,1)-Data(i,1))^2+(weight4(1,2)Data(i,2))^2+(weight4(1,3)-Data(i,3))^2+(weight1(1,4)Data(i,4))^2; if a
4
else if b
end; disp ('update weight berhasil')
A- 5
weight1 weight2 weight3 weight4 for j=1:4000; a=(weight1(1,1)-Data(j,1))^2+(weight1(1,2)Data(j,2))^2+(weight1(1,3)-Data(j,3))^2+(weight1(1,4)Data(j,4))^2; b=(weight2(1,1)-Data(j,1))^2+(weight2(1,2)Data(j,2))^2+(weight2(1,3)-Data(j,3))^2+(weight1(1,4)Data(j,4))^2; c=(weight3(1,1)-Data(j,1))^2+(weight3(1,2)Data(j,2))^2+(weight3(1,3)-Data(j,3))^2+(weight1(1,4)Data(j,4))^2; d=(weight4(1,1)-Data(j,1))^2+(weight4(1,2)Data(j,2))^2+(weight4(1,3)-Data(j,3))^2+(weight1(1,4)Data(j,4))^2; if a
6
D. Kluster D
Berikut ini merupakan source code kluster d, yang meimliki hasil 5 kluster Source Code Kluster d data ht=0.6; %melakukan random weight weight1=[0.1875 0.7690 0.3960 weight2=[0.2729 0.4517 0.6099 weight3=[0.0594 0.1253 0.1302 weight4=[0.0924 0.7229 0.5312 weight5=[0.1088 0.0986 0.1420
0.4600]; 0.7421]; 0.4574]; 0.8327]; 0.7521];
for i=1:4000; a=(weight1(1,1)-data(i,1))^2+(weight1(1,2)data(i,2))^2+(weight1(1,2)-data(i,2))^2+(weight1(1,2)data(i,2))^2; b=(weight2(1,1)-data(i,1))^2+(weight2(1,2)data(i,2))^2+(weight1(1,2)-data(i,2))^2+(weight1(1,2)data(i,2))^2; c=(weight3(1,1)-data(i,1))^2+(weight3(1,2)data(i,2))^2+(weight1(1,2)-data(i,2))^2+(weight1(1,2)data(i,2))^2; d=(weight4(1,1)-data(i,1))^2+(weight4(1,2)data(i,2))^2+(weight1(1,2)-data(i,2))^2+(weight1(1,2)data(i,2))^2; e=(weight5(1,1)-data(i,1))^2+(weight5(1,2)data(i,2))^2+(weight1(1,2)-data(i,2))^2+(weight1(1,2)data(i,2))^2; data_temp = [a b c d e];
A- 7
if min(data_temp)==a; z=data(i,:)-weight1(1,:); weight1=weight1(1,:)+(ht*z); weight2=weight2(1,:); weight3=weight3(1,:); weight4=weight4(1,:); weight5=weight5(1,:); i else if min(data_temp)==b; z=data(i,:)-weight2(1,:); weight2=weight2(1,:)+(ht*z); weight1=weight1(1,:); weight3=weight3(1,:); weight4=weight4(1,:); weight5=weight5(1,:); i else if min(data_temp)==c; z=data(i,:)-weight3(1,:); weight3=weight3(1,:)+(ht*z); weight1=weight1(1,:); weight2=weight2(1,:); weight4=weight4(1,:); weight5=weight5(1,:); i else if min(data_temp)==d; z=data(i,:)-weight4(1,:); weight4=weight4(1,:)+(ht*z); weight5=weight5(1,:); weight1=weight1(1,:); weight2=weight2(1,:); weight3=weight3(1,:); i else if min(data_temp)==e; z=data(i,:)-weight5(1,:); weight5=weight5(1,:)+(ht*z); weight4=weight4(1,:); weight1=weight1(1,:); weight2=weight2(1,:); weight3=weight3(1,:); i
8
end end end end end end disp('update weight berhasil') weight1 weight2 weight3 weight4 weight5 for j=1:4000; a=(weight1(1,1)-data(j,1))^2+(weight1(1,2)data(j,2))^2+(weight1(1,3)-data(j,3))^2+(weight1(1,4)data(j,4))^2; b=(weight2(1,1)-data(j,1))^2+(weight2(1,2)data(j,2))^2+(weight1(1,3)-data(j,3))^2+(weight1(1,4)data(j,4))^2; c=(weight3(1,1)-data(j,1))^2+(weight3(1,2)data(j,2))^2+(weight1(1,3)-data(j,3))^2+(weight1(1,4)data(j,4))^2; d=(weight4(1,1)-data(j,1))^2+(weight4(1,2)data(j,2))^2+(weight1(1,3)-data(j,3))^2+(weight1(1,4)data(j,4))^2; e=(weight5(1,1)-data(j,1))^2+(weight5(1,2)data(j,2))^2+(weight1(1,3)-data(j,3))^2+(weight1(1,4)data(j,4))^2;
A- 9
if (a
end;
10
E. Kluster E
Source Code Kluster 6 % inisialisasi data ht=0.6; % melakukan random weight weight1=[0.1875 0.7690 0.3960 weight2=[0.2729 0.4517 0.6099 weight3=[0.0594 0.1253 0.1302 weight4=[0.0924 0.7229 0.5312 weight5=[0.1088 0.0986 0.1420 weight6=[0.1683 0.2176 0.2510
0.4600]; 0.7421]; 0.4574]; 0.8327]; 0.7521]; 0.8472];
for i=1:4000; a=(weight1(1,1)-data(i,1))^2+(weight1(1,2)data(i,2))^2+(weight1(1,3)-data(i,3))^2+(weight1(1,4)data(i,4))^2; b=(weight2(1,1)-data(i,1))^2+(weight2(1,2)data(i,2))^2+(weight2(1,3)-data(i,3))^2+(weight1(1,4)data(i,4))^2; c=(weight3(1,1)-data(i,1))^2+(weight3(1,2)data(i,2))^2+(weight3(1,3)-data(i,3))^2+(weight1(1,4)data(i,4))^2; d=(weight4(1,1)-data(i,1))^2+(weight4(1,2)data(i,2))^2+(weight4(1,3)-data(i,3))^2+(weight1(1,4)data(i,4))^2; e=(weight5(1,1)-data(i,1))^2+(weight5(1,2)data(i,2))^2+(weight5(1,3)-data(i,3))^2+(weight1(1,4)data(i,4))^2; f=(weight6(1,1)-data(i,1))^2+(weight6(1,2)data(i,2))^2+(weight6(1,3)-data(i,3))^2+(weight1(1,4)data(i,4))^2; data_temp = [a b c d e f];
A- 11
if min(data_temp)==a; z=data(i,:)-weight1(1,:); weight1=weight1(1,:)+(ht*z); weight2=weight2(1,:); weight3=weight3(1,:); weight4=weight4(1,:); weight5=weight5(1,:); weight6=weight6(1,:); i else if min(data_temp)==b; z=data(i,:)-weight2(1,:); weight2=weight2(1,:)+(ht*z); weight1=weight1(1,:); weight3=weight3(1,:); weight4=weight4(1,:); weight5=weight5(1,:); weight6=weight6(1,:); i else if min(data_temp)==c; z=data(i,:)-weight3(1,:); weight3=weight3(1,:)+(ht*z); weight1=weight1(1,:); weight2=weight2(1,:); weight4=weight4(1,:); weight5=weight5(1,:); weight6=weight6(1,:); i else if min(data_temp)==d; z=data(i,:)-weight4(1,:); weight4=weight4(1,:)+(ht*z); weight5=weight5(1,:); weight6=weight6(1,:); weight1=weight1(1,:); weight2=weight2(1,:); weight3=weight3(1,:); i
12
else if min(data_temp)==e; z=data(i,:)-weight5(1,:); weight5=weight5(1,:)+(ht*z); weight6=weight6(1,:); weight4=weight4(1,:); weight1=weight1(1,:); weight2=weight2(1,:); weight3=weight3(1,:); i else if min(data_temp)==f; z=data(i,:)-weight6(1,:); weight6=weight6(1,:)+(ht*z); weight5=weight5(1,:); weight4=weight4(1,:); weight1=weight1(1,:); weight2=weight2(1,:); weight3=weight3(1,:); i end; end;
end; end; end; end; end; disp('update weight berhasil')
A- 13
weight1 weight2 weight3 weight4 weight5 weight6 for j=1:4000; a=(weight1(1,1)-data(j,1))^2+(weight1(1,2)data(j,2))^2+(weight1(1,3)-data(j,3))^2+(weight1(1,4)-data(j,4))^2; b=(weight2(1,1)-data(j,1))^2+(weight2(1,2)data(j,2))^2+(weight2(1,3)-data(j,3))^2+(weight2(1,4)-data(j,4))^2; c=(weight3(1,1)-data(j,1))^2+(weight3(1,2)data(j,2))^2+(weight3(1,3)-data(j,3))^2+(weight3(1,4)-data(j,4))^2; d=(weight4(1,1)-data(j,1))^2+(weight4(1,2)data(j,2))^2+(weight4(1,3)-data(j,3))^2+(weight4(1,4)-data(j,4))^2; e=(weight5(1,1)-data(j,1))^2+(weight5(1,2)data(j,2))^2+(weight5(1,3)-data(j,3))^2+(weight5(1,4)-data(j,4))^2; f=(weight6(1,1)-data(j,1))^2+(weight6(1,2)data(j,2))^2+(weight6(1,3)-data(j,3))^2+(weight6(1,4)-data(j,4))^2;
if a
14
Hasil Algoritma SOM :
Jumlah Kluster 2 Jumlah Kluster 3 Jumlah Kluster 4 Jumlah Kluster 5 Jumlah Kluster 6
Kluster Kluster Kluster Kluster 2 3 4 5 1823 1801 1801 0 2177
Kluster 6 0
1699
1699
1699
1699
500
500
1801
1801
0
0
0
500
500
F. Validasi RMSSTD
Perhitungan validasi RMSSTD: Tabel Perhitungan RMSSTD Kluster A Rata2 (Kluster 1) Rata2 (kluster 2) jumlah(xi-x) pd kluster 1 jumlah(xi-x) pd kluster 2
1.0272254 0.377964 1.026148 0.812861 -0.860188 2662.426 3584.401
-0.3165
-0.85929
-0.68068
A- 15
nij pada kluster 1 dimensi ... nij pada kluster 2 dimensi ... RMSSTD
1823
1823
1823
1823 7292
2177
2177
2177
2177 8708
0.6248804
Tabel Perhitungan RMSSTD Kluster B Rata2 (kluster 1) Rata2 (kluster 2) Rata2 (kluster 3) jumlah(xi-x) pd kluster 1 jumlah(xi-x) pd kluster 2 jumlah(xi-x) pd kluster 3 nij pada kluster 1 dimensi ... nij pada kluster 2 dimensi ... nij pada kluster 3 dimensi ... RMSSTD
-0.82968 0.377964 -0.85929 -0.59349 1.16275 0.377964 1.163755 0.881045 -0.96251 -2.64575 -0.85929 -0.85606 65.90982833 1614.10295 0.379604129 1801
1801
1801
1801
7204
1699
1699
1699
1699
6796
500
500
500
500
2000
0.3241053
16
Tabel Perhitungan RMSSTD Kluster C Rata2 (kluster1 ) -0.82968 0.377964 -0.85929 -0.59349 Rata2 (kluster 2) 1.16275 0.377964 1.163755 0.881045 Rata2 (kluster 3) -0.96251 -2.64575 -0.85929 -0.85606 Rata2 (kluster 4) 0 0 0 0 jumlah(xi-x) pd kluster 65.90982833 1 jumlah(xi-x) pd kluster 1614.10295 2 jumlah(xi-x) pd kluster 0.379604129 3 jumlah(xi-x) pd kluster 4 nij pada kluster 1 1801 1801 1801 1801 7204 dimensi ... nij pada kluster 2 1699 1699 1699 1699 6796 dimensi ... nij pada kluster 3 500 500 500 500 2000 dimensi ... nij pada kluster 4 0 0 0 0 0 dimensi ... RMSSTD 0.3241154
A- 17
Tabel Perhitungan RMSSTD Kluster D Rata2 (kluster 1) Rata2 (kluster 2) Rata2 (kluster 3) Rata2 (kluster 4) Rata2 (kluster 5) jumlah(xi-x) pd kluster 1 jumlah(xi-x) pd kluster 2 jumlah(xi-x) pd kluster 3 jumlah(xi-x) pd kluster 4 jumlah(xi-x) pd kluster 5 nij pada kluster 1 dimensi ... nij pada kluster 2 dimensi ... nij pada kluster 3 dimensi ... nij pada kluster 4 dimensi ... nij pada kluster 5 dimensi ... RMSSTD
0 0 1.16275 0.377964 -0.82968 0.377964 0 0 -0.96251 -2.64575
0 0 1.163755 0.88104541 -0.85929 -0.5934863 0 -0.85929 -0.8560592 0 1614.10295 65.90982833 0 0.379604129
0 1699 1801 0 500 0.324125523
0 1699 1801 0 500
0 1699 1801 0 500
0 1699 1801 0 500
6796 7204 0 2000
18
Tabel Perhitungan RMSSTD Kluster E Rata2 (kluster 1) Rata2 (kluster 2) Rata2 (kluster 3) Rata2 (kluster 4) Rata2 (kluster 5) Rata2 (kluster 6) jumlah(xi-x) pd kluster 1 jumlah(xi-x) pd kluster 2 jumlah(xi-x) pd kluster 3 jumlah(xi-x) pd kluster 4 jumlah(xi-x) pd kluster 5 jumlah(xi-x) pd kluster 6 nij pada kluster 1 dimensi ... nij pada kluster 2 dimensi ... nij pada kluster 3 dimensi ... nij pada kluster 4 dimensi ... nij pada kluster 5 dimensi ... nij pada kluster 6 dimensi ... RMSSTD
0 0 0 0 1.16275 0.377964 1.163755 0.881045 -0.82968 0.377964 -0.85929 -0.59349 0 0 0 -0.96251 -2.64575 -0.85929 -0.85606 0 0 0 0 0 1614.035 65.89382 0 0.378869 0 0 1699 1801 0 499 0 0.324168
0 1699 1801 0 499 0
0 1699 1801 0 499 0
0 1699 1801 0 499 0
6796 7204 0 1996 0
A-19
Hasil Validasi RMSSTD A- 1 Tabel Hasil RMSSTD RMSSTD Kluster a Kluster b Kluster c Kluster d Kluster e
Nilai 0.6248804 0.3241053 0.3241154 0.3241255 0.324168
Grafik Hasil RMSSTD
A- 2 Grafik Hasil RMSSTD
B-120 LAMPIRAN B Kluster Kmeans beserta Validasi DBI A. Source Code Algoritma Kombinasi SOM dan Kmeans
Ketik pada Matlab [klaster, ctrs]=kmeans(data,3)
Segmen Kode K-Means Hasil Dari Algoritma Kmeans
Hasil dari Algoritma K-means
B-2 A-21 Hasil Algoritma Kmeans Tabel Perhitungan algoritma K-means
Hasil Kluster 1 Hasil Kluster 2 Hasil Kluster 3
Kluster 1 500
Kluster 2
1801 1699
B. Hasil Validasi Davies Bouldin Index
Tabel Hasil Validasi DBI Klaster SOM SOM + Kmeans
Kluster 3
Nilai DBI 0.26902 0.184783