我无法从我的代码中找到错误,花了我几个小时试图解决它但仍然无法使其工作。
我已经在浏览器控制台上查看了它,并在下面显示为ascreenshot:
这是我的代码:
<?php
session_start();
use Phpml\Classification\SVC;
use Phpml\SupportVectorMachine\Kernel;
include "koneksi.php";
include "function.php";
if(!isset($_SESSION['username'])){
header('location:login.php');
}else{
$username = $_SESSION['username'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Pelatihan SVM</title>
<link rel="stylesheet" type="text/css" href="styles/2nd.css">
<script src="jquery-3.1.1.min.js"></script>
<?php
cekUser();
?>
</head>
<body>
<div class="tab">
<button class="menuTab" onclick="switchMenu(event, 'useDatabase')" id="admin">Data Mentah</button>
<button class="menuTab" onclick="switchMenu(event, 'term')" id="nonAdmin">Data Feature Selection</button>
</div>
<div id="useDatabase" class="tabContent">
<?php
$start=0;
$limit=100;
if(isset($_GET['id'])){
$id=$_GET['id'];
$start=($id-1)*$limit;
}else{
$id=1;
}
$q = mysqli_query($db, "SELECT * FROM dataset_latih LIMIT $start, $limit")or die(mysqli_error($db));
$no=$start+1;
$q1=mysqli_query($db, "SELECT COUNT('label') AS 'label positif' FROM dataset_latih WHERE label='positif'");
$row=mysqli_fetch_assoc($q1);
$positif=$row['label positif'];
$q2=mysqli_query($db, "SELECT COUNT('label') AS 'label negatif' FROM dataset_latih WHERE label='negatif'");
$row2=mysqli_fetch_assoc($q2);
$negatif=$row2['label negatif'];
?>
<h2 align="center">Dataset Latih</h2>
<h3 style="text-align: center;">Positif : <?php echo $positif; ?> | Negatif : <?php echo $negatif; ?> | Total : <?php echo $positif+$negatif; ?></h3>
<table border=1 align="center" class="h-header">
<thead>
<tr>
<th width="25">No.</th>
<th width="1200">Komentar</th>
<th width="70">Kelas</th>
</tr>
</thead>
<?php
while ( $result = mysqli_fetch_assoc($q) ) {
echo "<tr>";
echo "<td>" . $no . "</td>";
echo "<td class='kiri'>" . $result['komentar'] . "</td>";
echo "<td>" . $result['label'] . "</td>";
echo "</tr>";
$no++;
}
?>
</table>
<div class='wrapper'>
<button class='button' id="prosesData">Proses</button>
</div>
<div class="paging" style="text-align: center;">
<?php
$rows=mysqli_num_rows(mysqli_query($db, "SELECT * FROM dataset_latih"));
$total=ceil($rows/$limit);
if ($id>1) {
echo "<a href='?id=".($id-1)."' class='button' id='table1'>Previous </a>";
}
for ($i=1; $i <=$total ; $i++) {
if ($i==$id) {
echo "<span class='active'>$i</span>";
}else{
echo "<a href='?id=".$i."' id='table1'> ".$i." </a>";
}
}
if ($id!=$total) {
echo "<a href='?id=".($id+1)."' class='button' id='table1'> Next</a>";
}
?>
</div>
</div>
<div id="term" class="tabContent">
<h2 align="center">Term Latih</h2>
<?php
$start=0;
$limit=100;
if(isset($_GET['id1'])){
$id1=$_GET['id1'];
$start=($id1-1)*$limit;
}else{
$id1=1;
}
$q = mysqli_query($db, "SELECT * FROM data_latih_ready LIMIT $start, $limit")or die(mysqli_error($db));
$no=$start+1;
$rowPersentase = mysqli_fetch_assoc(mysqli_query($db, "SELECT * FROM selected_feature"))or die(mysqli_error($db));
$persentase = $rowPersentase['persentase'];
$td1 = '';
$td2 = '';
$td3 = '';
while ($row1 = mysqli_fetch_assoc($q)) {
$td1 .= "<td>$no</td>";
$td2 .= "<td>".$row1['term']."</td>";
$td3 .= "<td>".$row1['tf_idf_normalisasi']."</td>";
$no++;
}
?>
<h3 style="text-align: center;">Feature Selection : <?php echo $persentase; ?>%</h3>
<div class="v-header">
<table border="1" align="center" cellpadding="20">
<thead>
<tr>
<th>No.</th>
<?php echo $td1; ?>
</tr>
<tr>
<th>Term</th>
<?php echo $td2; ?>
</tr>
<tr>
<th>Normalisasi TF.IDF</th>
<?php echo $td3; ?>
</tr>
</thead>
</table>
</div>
<!-- <br> -->
<div class="paging2" style="text-align: center;">
<?php
$rows=mysqli_num_rows(mysqli_query($db, "SELECT * FROM data_latih_ready"));
$total=ceil($rows/$limit);
if ($id1>1) {
echo "<a href='?id1=".($id1-1)."' class='button' id='table2'>Previous </a>";
}
for ($i=1; $i <=$total; $i++) {
if ($i==$id1) {
echo "<span class='active'>$i</span>";
}else{
echo "<a href='?id1=".$i."' id='table2'> ".$i." </a>";
}
}
if ($id1!=$total) {
echo "<a href='?id1=".($id1+1)."' class='button' id='table2'> Next</a>";
}
?>
<div class="btnFeature">
<ul>
<li>
<button class="button" onclick="train();">Latih SVM</button>
</li>
<li>
<button class="button" id="featureSelection">Feature Selection</button>
</li>
</ul>
</div>
</div>
</div>
<div class="info" align="center">
<p>Tabel di atas merupakan tabel term dengan nilai yang telah disesuaikan dengan nilai <strong>Feature Selection</strong><br>
Silahkan menekan tombol <strong>Latih SVM</strong> jika <strong>Feature Selection</strong> sudah sesuai kebutuhan.
</p>
</div>
<?php
$cek = cekTabelToken();
?>
<script type="text/javascript">
// biar otomatis tab aktif waktu halaman svmLatih.php dibuka
document.getElementById("admin").click();
$(".info").hide();
$("#admin").click(function(){
$(".info").hide();
});
$("#nonAdmin").click(function(){
$(".info").show();
});
// var untuk cek tabel term kosong gk
var cek = "<?php echo "$cek"; ?>"
$("#prosesData").click(function(){
// kalau tabel term gk kosong, alert mau proses ulang gk
if (cek > 0) {
var conf = confirm("Preprocessing data latih sudah pernah dilakukan.\nIngin memproses ulang ?");
if (conf == true) {
$.ajax({
url: "action.php",
data:{action: "prosesUlangDataLatih"},
type: "POST",
// kalau berhasil kasih alert lalu redirect
success: function(){
alert("Preprocessing ulang selesai.");
setTimeout(function(){
window.location.href = 'featureSelection.php';
},1000);
}
});
}
}else{
// kalau tabel term kosong ya langsung aja proses
$.ajax({
url: "action.php",
data:{action: "preprocessing"},
type: "POST",
// kalau berhasil kasih alert lalu redirect
success: function(){
alert("Preprocessing selesai.");
setTimeout(function(){
window.location.href = 'featureSelection.php';
},1000);
}
});
}
});
// fungsi untuk switch tab
function switchMenu(evt, selectedMenu){
var i, tabContent, menuTab;
tabContent = document.getElementsByClassName("tabContent");
for (i = 0; i < tabContent.length; i++) {
tabContent[i].style.display = "none";
}
menuTab = document.getElementsByClassName("menuTab");
for(i = 0; i < menuTab.length; i++){
menuTab[i].className = menuTab[i].className.replace(" active", "");
}
document.getElementById(selectedMenu).style.display = "block";
evt.currentTarget.className += " active";
}
// tombol feature selection
$("#featureSelection").click(function(){
window.location = "featureSelection.php";
});
// tombol latih SVM
function train(){
$.ajax({
type: "POST",
url: "action.php",
data:{
action: "trainDatabase"
},
success: function(){
alert("Model SVM sudah dibuat.");
},
error: function(){
alert("Error");
}
});
}
</script>
</body>
</html>
我希望有人可以帮助我找到错误,我已经被困在这里好几个小时了。谢谢。