Senin, 20 Mei 2019

NAIVE BAYES




HASIL:





<?php

if(isset($_POST["Analisa"])){

$sql="select * from `$tbkerusakan` order by `id_kerusakan` asc";
  $arr=getData($conn,$sql);
$i=0;
foreach($arr as $d) {
$ik[$i]=$d["id_kerusakan"];
$nk[$i]=$d["nama_kerusakan"];
$pk[$i]=$d["penyebab"];
$sk[$i]=$d["solusi"];
$kk[$i]=$d["keterangan"];
$gk[$i]=$d["gambar"];
$i++;
}
$id_user=strip_tags($_POST["id_user"]);
$tanggal=BAL(strip_tags($_POST["tanggal"]));

$pilih1=strip_tags($_POST["pilih1"]);
$pilih2=strip_tags($_POST["pilih2"]);
$pilih3=strip_tags($_POST["pilih3"]);
$pilih4=strip_tags($_POST["pilih4"]);
$pilih5=strip_tags($_POST["pilih5"]);
$pilih6=strip_tags($_POST["pilih6"]);
$pilih7=strip_tags($_POST["pilih7"]);
$pilih8=strip_tags($_POST["pilih8"]);
$pilih9=strip_tags($_POST["pilih9"]);
$pilih10=strip_tags($_POST["pilih10"]);
$keterangan=strip_tags($_POST["keterangan"]);

$jumK1=getOut($conn,$ik[0]);
$jumK2=getOut($conn,$ik[1]);
$jumK3=getOut($conn,$ik[2]);
$totK=$jumK1+$jumK2+$jumK3;

$jumG1A=getKK($conn,'gejala1',$pilih1,$ik[0]);
$jumG1B=getKK($conn,'gejala1',$pilih1,$ik[1]);
$jumG1C=getKK($conn,'gejala1',$pilih1,$ik[2]);

$jumG2A=getKK($conn,'gejala2',$pilih2,$ik[0]);
$jumG2B=getKK($conn,'gejala2',$pilih2,$ik[1]);
$jumG2C=getKK($conn,'gejala2',$pilih2,$ik[2]);

$jumG3A=getKK($conn,'gejala3',$pilih3,$ik[0]);
$jumG3B=getKK($conn,'gejala3',$pilih3,$ik[1]);
$jumG3C=getKK($conn,'gejala3',$pilih3,$ik[2]);

$jumG4A=getKK($conn,'gejala4',$pilih4,$ik[0]);
$jumG4B=getKK($conn,'gejala4',$pilih4,$ik[1]);
$jumG4C=getKK($conn,'gejala4',$pilih4,$ik[2]);

$jumG5A=getKK($conn,'gejala5',$pilih5,$ik[0]);
$jumG5B=getKK($conn,'gejala5',$pilih5,$ik[1]);
$jumG5C=getKK($conn,'gejala5',$pilih5,$ik[2]);

$jumG6A=getKK($conn,'gejala6',$pilih6,$ik[0]);
$jumG6B=getKK($conn,'gejala6',$pilih6,$ik[1]);
$jumG6C=getKK($conn,'gejala6',$pilih6,$ik[2]);

$jumG7A=getKK($conn,'gejala7',$pilih7,$ik[0]);
$jumG7B=getKK($conn,'gejala7',$pilih7,$ik[1]);
$jumG7C=getKK($conn,'gejala7',$pilih7,$ik[2]);

$jumG8A=getKK($conn,'gejala8',$pilih8,$ik[0]);
$jumG8B=getKK($conn,'gejala8',$pilih8,$ik[1]);
$jumG8C=getKK($conn,'gejala8',$pilih8,$ik[2]);

$jumG9A=getKK($conn,'gejala9',$pilih9,$ik[0]);
$jumG9B=getKK($conn,'gejala9',$pilih9,$ik[1]);
$jumG9C=getKK($conn,'gejala9',$pilih9,$ik[2]);

$jumG10A=getKK($conn,'gejala10',$pilih10,$ik[0]);
$jumG10B=getKK($conn,'gejala10',$pilih10,$ik[1]);
$jumG10C=getKK($conn,'gejala10',$pilih10,$ik[2]);



if($jumG1A==0 || $jumG2A==0 || $jumG3A==0 || $jumG4A==0 || $jumG5A==0 || $jumG6A==0 || $jumG7A==0 || $jumG8A==0 || $jumG9A==0 || $jumG10A==0 ){
$jumK1+=1;
$totK+=1;
$jumG1A+=1;$jumG2A+=1;$jumG3A+=1;$jumG4A+=1;$jumG5A+=1;$jumG6A+=1;$jumG7A+=1;$jumG8A+=1;$jumG9A+=1;$jumG10A+=1;
}
if($jumG1B==0 || $jumG2B==0 || $jumG3B==0 || $jumG4B==0 || $jumG5B==0 || $jumG6B==0 || $jumG7B==0 || $jumG8B==0 || $jumG9B==0 || $jumG10B==0 ){
$jumK1+=1;
$totK+=1;
$jumG1B+=1;$jumG2B+=1;$jumG3B+=1;$jumG4B+=1;$jumG5B+=1;$jumG6B+=1;$jumG7B+=1;$jumG8B+=1;$jumG9B+=1;$jumG10B+=1;
}
if($jumG1C==0 || $jumG2C==0 || $jumG3C==0 || $jumG4C==0 || $jumG5C==0 || $jumG6C==0|| $jumG7C==0|| $jumG8C==0|| $jumG9C==0|| $jumG10C==0 ){
$jumK1+=1;
$totK+=1;
$jumG1C+=1;$jumG2C+=1;$jumG3C+=1;$jumG4C+=1;$jumG5C+=1;$jumG6C+=1;$jumG7C+=1;$jumG8C+=1;$jumG9C+=1;$jumG10C+=1;
}


$HA=($jumK1/$totK)*($jumG1A/$jumK1)*($jumG2A/$jumK1)*($jumG3A/$jumK1)*($jumG4A/$jumK1)*($jumG5A/$jumK1)*($jumG6A/$jumK1)*($jumG7A/$jumK1)*($jumG8A/$jumK1)*($jumG9A/$jumK1)*($jumG10A/$jumK1);
$HB=($jumK2/$totK)*($jumG1B/$jumK2)*($jumG2B/$jumK2)*($jumG3B/$jumK2)*($jumG4B/$jumK2)*($jumG5B/$jumK2)*($jumG6B/$jumK2)*($jumG7B/$jumK2)*($jumG8B/$jumK2)*($jumG9B/$jumK2)*($jumG10B/$jumK2);
$HC=($jumK3/$totK)*($jumG1C/$jumK3)*($jumG2C/$jumK3)*($jumG3C/$jumK3)*($jumG4C/$jumK3)*($jumG5C/$jumK3)*($jumG6C/$jumK3)*($jumG7C/$jumK3)*($jumG8C/$jumK3)*($jumG9C/$jumK3)*($jumG10C/$jumK3);

$SHA="($jumK1/$totK) x ($jumG1A/$jumK1) x ($jumG2A/$jumK1) x ($jumG3A/$jumK1) x ($jumG4A/$jumK1) x ($jumG5A/$jumK1) x ($jumG6A/$jumK1) x ($jumG7A/$jumK1) x ($jumG8A/$jumK1) x ($jumG9A/$jumK1) x ($jumG10A/$jumK1)";
$SHB="($jumK2/$totK) x ($jumG1B/$jumK2) x ($jumG2B/$jumK2) x ($jumG3B/$jumK2) x ($jumG4B/$jumK2) x ($jumG5B/$jumK2) x ($jumG6B/$jumK2) x ($jumG7B/$jumK2) x ($jumG8B/$jumK2) x ($jumG9B/$jumK2) x ($jumG10B/$jumK2)";
$SHC="($jumK3/$totK) x ($jumG1C/$jumK3) x ($jumG2C/$jumK3) x ($jumG3C/$jumK3) x ($jumG4C/$jumK3) x ($jumG5C/$jumK3) x ($jumG6C/$jumK3) x ($jumG7C/$jumK3) x ($jumG8C/$jumK3) x ($jumG9C/$jumK3) x ($jumG10C/$jumK3)";




$max=0;
$keterangan="";
$index=0;
if($HA>=$HB && $HA>=$HC){
$max=$HA;
$index=0;
}
else if($HB>=$HA && $HB>=$HB){
$max=$HB;
$index=1;
}
else if($HC>=$HA && $HC>=$HC){
$max=$HC;
$index=2;
}
$iout=$ik[$index];
$nout=$nk[$index];
$pout=$pk[$index];
$sout=$sk[$index];
$gout=$gk[$index];
$kout=$kk[$index];

$sql="select * from `$tbuser` where `id_user`='$id_user'";
$d=getField($conn,$sql);
$nama_user=$d["nama_user"];
$email=$d["email"];
$teleopn=$d["telepon"];


$gab="<h3>Hasil Analisa</h3>";
$gab.= "<strong>$nk[0] => $SHA =$HA</strong><br>";
$gab.= "<strong>$nk[1] => $SHB =$HB</strong><br>";
$gab.= "<strong>$nk[2] => $SHC =$HC</strong><hr>";

$gab2= "<b>Yth $nama_user ($id_user) <br>Mobil Anda Terdiagnosa : $nout ($max)<br>";
$gab2.= "<i>Penyebab: $pout</i><hr>";
$gab2.= "<i>Solusi: $sout</i><hr>";

$rekapitulasi= "$nk[0] => $SHA =$HA<br>";
$rekapitulasi.= "$nk[1] => $SHB =$HB<br>";
$rekapitulasi.= "$nk[2] => $SHC =$HC<hr>";


echo $gab;
echo $gab2;
echo "<img src='ypathfile/$gout' title='$nout' width='500' height='400'><br>";
$_SESSION["gab"]=$gab;
$_SESSION["gab2"]=$gab2;
echo"<img src='ypathicon/print.png' title='PRINT' OnClick='PRINTME()'>";

$tanggal=date("Y-m-d");
$jam=date("H:i:s");
$sql=" INSERT INTO `$tbpengujian` (
`id_pengujian` ,
`id_user` ,
`tanggal` ,
`pilih1` ,
`pilih2` ,
`pilih3`,
`pilih4` ,
`pilih5` ,
`pilih6` ,
`pilih7` ,
`pilih8`,
`pilih9`,
`pilih10`,
`id_kerusakan`,
`rekapitulasi`,
`keterangan`
) VALUES (
'',
'$id_user',
'$tanggal',
'$pilih1',
'$pilih2',
'$pilih3',
'$pilih4',
'$pilih5',
'$pilih6',
'$pilih7',
'$pilih8',
'$pilih9',
'$pilih10',
'$iout',
'$rekapitulasi',
'$gab $gab2'
)";

$simpan=process($conn,$sql);
}

?>
<?php

function getKK($conn,$kolom,$data,$kat){
  $sql="select `id_kerusakan` from `tb_datalatih` where `$kolom`='$data' and `id_kerusakan`='$kat'";
  $jum=getJum($conn,$sql);
  return $jum;
}

function getOut($conn,$kat){
  $sql="select `id_kerusakan` from `tb_datalatih` where `id_kerusakan`='$kat'";
  $jum=getJum($conn,$sql);
  return $jum;
}


?>

Tidak ada komentar:

Posting Komentar

global_priv WARNING Selalu

 Jika muncul pesan kesalahan: Warning in .\libraries\classes\Dbal\DbiMysqli.php#209  mysqli::query(): (HY000/1034): Index for table 'glo...