Postingan lainnya
Data Hasil Sorting Euclidian Tidak Muncul
Saya menggunakan rumus KNN + WP yang ada di google untuk ranking, setelah dijalankan Data Hasil Sorting Euclidian Tidak Muncul, lalu bagaimana cara menampilkan data hasil sorting tersebut dalam tabel
Hasil Sorting Euclidian.jpg
Hasil Sorting Euclidian (1).jpg
Berikut codingan fullnya :
<div class="table-responsive col-md-8 col-md-offset-2" style="height:350px;overflow:auto;">
<table class="table table-bordered">
<thead>
<tr>
<th>Array [DataTesting] [DataTraining]</th>
<th>Jarak Euclidian</th>
<th>Klasifikasi</th>
</tr>
</thead>
<tbody>
<tr>
<?php
for($k=0;$k<$banyak_data2;$k++){
${'keys'.$k} = array();
${'val'.$k} = array();
${'klasifikasi'.$k} = array();
for($l=0;$l<$kvall;$l++){
${'keys'.$k}[$l] = 0;
${'val'.$k}[$l] = 0;
${'klasifikasi'.$l}[${'keys'.$k}[$l]] = 0;
}
}
//echo "banyak data : "; var_dump($result_klas1); //line 221
$query_klas_del = "TRUNCATE TABLE temp"; //line 222
mysqli_query($koneksi,$query_klas_del); //line 223
//$k = isset($array['k']) ? $array['k'] : ''; //line 224
//$l = isset($array['l']) ? $array['l'] : ''; //line 225
for($k=0;$k<$banyak_data2;$k++){ //line 226
for($l=0;$l<$kvall;$l++){ //line 227
echo "<tr>"; //line 228
echo "<td>"."[".$k."][".${'keys'.$k}[$l]."]"."</td>"; //line 229
echo "<td>".${'val'.$k}[$l]."</td>";//line 230
echo "<td>".${'klasifikasi'.$l}[${'keys'.$k}[$l]]."</td>";//line 231
echo "</tr>";//line 232
//echo ${'keys'.$k}[$l]; //line 233
if(${'klasifikasi'.$l}[${'keys'.$k}[$l]] == $kelas1) { //line 235
$counterClass1++; //line 236
}
else if(${'klasifikasi'.$l}[${'keys'.$k}[$l]] == $kelas2) { //line 238
$counterClass2++; //line 239
}
else { //line 241
$counterClass3++; //line 242
}
}
if($counterClass1>$counterClass2 && $counterClass1>$counterClass3) { //line 246
$query_klas1 = "insert into temp (klasifikasi) values ('$kelas1')"; //line 247
$result_klas1 = mysqli_query($koneksi,$query_klas1); //line 248
}
else if($counterClass2>$counterClass1 && $counterClass2>$counterClass3) { //line 250
$query_klas2 = "insert into temp (klasifikasi) values ('$kelas2')"; //line 251
$result_klas2 = mysqli_query($koneksi,$query_klas2); //line 252
}
else if($counterClass3>$counterClass1 && $counterClass3>$counterClass2) { //line 254
$query_klas3 = "insert into temp (klasifikasi) values ('$kelas3')"; //line 255
$result_klas3 = mysqli_query($koneksi,$query_klas3); //line 256
}
$counterClass1=0; //line 259
$counterClass2=0; //line 260
$counterClass3=0; //line 261
}
//line 264
?>
</tr>
</tbody>
</table>
</div>
berikut codingan fungsi logikanya :
<?php
for($k=0;$k<$banyak_data2;$k++){
${'keys'.$k} = array();
${'val'.$k} = array();
${'klasifikasi'.$k} = array();
for($l=0;$l<$kvall;$l++){
${'keys'.$k}[$l] = 0;
${'val'.$k}[$l] = 0;
${'klasifikasi'.$l}[${'keys'.$k}[$l]] = 0;
}
}
//echo "banyak data : "; var_dump($result_klas1); //line 221
$query_klas_del = "TRUNCATE TABLE temp"; //line 222
mysqli_query($koneksi,$query_klas_del); //line 223
//$k = isset($array['k']) ? $array['k'] : ''; //line 224
//$l = isset($array['l']) ? $array['l'] : ''; //line 225
for($k=0;$k<$banyak_data2;$k++){ //line 226
for($l=0;$l<$kvall;$l++){ //line 227
echo "<tr>"; //line 228
echo "<td>"."[".$k."][".${'keys'.$k}[$l]."]"."</td>"; //line 229
echo "<td>".${'val'.$k}[$l]."</td>";//line 230
echo "<td>".${'klasifikasi'.$l}[${'keys'.$k}[$l]]."</td>";//line 231
echo "</tr>";//line 232
//echo ${'keys'.$k}[$l]; //line 233
if(${'klasifikasi'.$l}[${'keys'.$k}[$l]] == $kelas1) { //line 235
$counterClass1++; //line 236
}
else if(${'klasifikasi'.$l}[${'keys'.$k}[$l]] == $kelas2) { //line 238
$counterClass2++; //line 239
}
else { //line 241
$counterClass3++; //line 242
}
}
if($counterClass1>$counterClass2 && $counterClass1>$counterClass3) { //line 246
$query_klas1 = "insert into temp (klasifikasi) values ('$kelas1')"; //line 247
$result_klas1 = mysqli_query($koneksi,$query_klas1); //line 248
}
else if($counterClass2>$counterClass1 && $counterClass2>$counterClass3) { //line 250
$query_klas2 = "insert into temp (klasifikasi) values ('$kelas2')"; //line 251
$result_klas2 = mysqli_query($koneksi,$query_klas2); //line 252
}
else if($counterClass3>$counterClass1 && $counterClass3>$counterClass2) { //line 254
$query_klas3 = "insert into temp (klasifikasi) values ('$kelas3')"; //line 255
$result_klas3 = mysqli_query($koneksi,$query_klas3); //line 256
}
$counterClass1=0; //line 259
$counterClass2=0; //line 260
$counterClass3=0; //line 261
}
//line 264
?>
Mohon Bantuannya Master
0
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban