int i, j;
int jumdat; //berisi jumlah data
double[,] A; // baris (m) untuk data i=1....jumlah data, kolom (n) untuk kluster j=1...jumlah cluster
double[,] CENTROID; //titik centroid, baris untuk data, kolom untuk rata-rata atribut ke m=1...jumlah atribut
double x, y;
double min;
int cluster = 0; // nilai default
double d; //hasil euclid jarak-masing-masing titik
double jarak_x;
double jarak_y;
double[,] sumxy; //untuk proses perhitungan baris (m) untuk data i=1....jumlah data, kolom (n) untuk kluster j=1...jumlah cluster
for (i = 1; i < jumdat; i++) //menghitung jarak dari data pertama sampai data terakhir
{
min = 100000; //nilai awal jarak minimum
x = A[i, 0]; // Nilai x objek data ke-i
y = A[i, 1]; // Nilai y objek data ke-i
for (j = 1; j <= jumcen; j++)
{
jarak_x = Math.Pow(Math.Abs(x - CENTROID[j, 0]), 2);
jarak_y = Math.Pow(Math.Abs(y - CENTROID[j, 1]), 2);
d = Math.Sqrt(jarak_x + jarak_y);
if (d < min)
{
min = d;
cluster = j;
}
}
A[i, 2] = cluster;
}
//Iterasi Ke-2
bool IsStillMoving;
IsStillMoving = true;
int itung = 1; //jumlah iterasi
do
{
itung = 1 + itung;
double[,] sumxy = new double[jumdat, 4];
for (i = 1; i < jumdat; i++)
{
sumxy[Convert.ToInt32(A[i, 2]), 0] = A[i, 0] + sumxy[Convert.ToInt32(A[i, 2]), 0];
sumxy[Convert.ToInt32(A[i, 2]), 1] = A[i, 1] + sumxy[Convert.ToInt32(A[i, 2]), 1];
sumxy[Convert.ToInt32(A[i, 2]), 2] = 1 + sumxy[Convert.ToInt32(A[i, 2]), 2];
}
for (i = 1; i <= jumcen; i++)
{
CENTROID[i, 0] = ((sumxy[i, 0]) / (sumxy[i, 2])); //Rata2 x di masing2 cluster
CENTROID[i, 1] = ((sumxy[i, 1]) / (sumxy[i, 2])); //Rata2 y di masing2 cluster
}
IsStillMoving = false;
for (i = 1; i < jumdat; i++)
{
min = 100000;
x = A[i, 0];
y = A[i, 1];
for (j = 1; j <= jumcen; j++)
{
jarak_ipk = Math.Pow(Math.Abs(x - CENTROID[j, 0]), 2);
jarak_lmstd = Math.Pow(Math.Abs(y - CENTROID[j, 1]), 2);
d = Math.Sqrt(jarak_ipk + jarak_lmstd);
if (d < min)
{
min = d;
cluster = j;
}
}
if (A[i, 2] != cluster)
{
A[i, 2] = cluster;
IsStillMoving = true;
}
}
itung++;
} while (IsStillMoving);
MessageBox.Show("Proses Selesai");
sumber : Kharismawan, Bagus 2015 (Unpad: University of Padjadjaran) Aplikasi K-Means dan Fuzzy C-Means Clustering untuk Mengelompokkan Data Mahasiswa FMIPA
sumber : Kharismawan, Bagus 2015 (Unpad: University of Padjadjaran) Aplikasi K-Means dan Fuzzy C-Means Clustering untuk Mengelompokkan Data Mahasiswa FMIPA
How to get to Tropicana Atlantic City using public transportation
BalasHapusDirections to Tropicana Atlantic City using public transportation. The following transit 여주 출장샵 lines have routes 전라남도 출장샵 that 부천 출장샵 pass near 대전광역 출장안마 Tropicana 광주 출장마사지 Atlantic City Lyft: Personal ride