Sei sulla pagina 1di 18

SOURCE CODE UNTUK PENERAPAN ALGORITMA APRIORI

DALAM MENEMUKAN HUBUNGAN DATA AWAL MASUK DENGAN

DATA KELULUSAN MAHASISWA

KONGIF :

$myHost = "localhost";
$myUser = "root";
$myPass = "";
$myDb ="db_apriori";

$tbadmin="admin";
$tbcalonmhs="tb_calon_mhs";
$tbhasil="tb_hasil";
$tbmhs="ac_mahasiswa";

INPUT DATA MAHASISWA

<form action="" method="post" enctype="multipart/form-data">


<table width="40%" border="50" cellpadding=0 cellspacing="2" class="table" >
<tr class="th">
<th width="66"><label for="kode_calon_mhs">kode_calon_mhs</label>
<th width="9">:
<th colspan="2"><b><?php echo $kode_calon_mhs;?></b></tr>

<tr>
<td height="24">nama_calon_mhs
<td>:<td colspan="2"><input name="nama_calon_mhs" type="text"
id="nama_calon_mhs" value="<?php echo $nama_calon_mhs;?>" size="25" />
</td>
</tr>

<tr>
<td height="24">jenis_kelamin
<td>:<td colspan="2"><label>
<input name="jenis_kelamin" type="radio" id="radio" value="Pria" />
Pria
<input name="jenis_kelamin" type="radio" id="radio2" value="Wanita"
checked="checked" /> Wanita</label></td>
</tr>

<tr>
<td height="24">nilai_sttb
<td>:<td colspan="2"><input name="nilai_sttb" type="text" id="nilai_sttb"
value="<?php echo $nilai_sttb;?>" size="15" onChange="showGrade(this.value)" />
</td>
</tr>

<tr>
<td height="24">grade
<td>:<td colspan="2">
<div id="mgrade"> <input name="grade" type="text" id="grade" value="<?php echo
$grade;?>" size="15"></div>
</td>
</tr>

<tr>
<td height="24">jurusan_kuliah
<td>:<td colspan="2"><label>
<select name="jurusan_kuliah" id="jurusan_kuliah"
onChange="showFakultas(this.value)">
<option value="-">-</option>
<option value="Sastra Jepang" <?php if($jurusan_kuliah=="Sastra
Jepang"){echo"selected";}?>>Sastra Jepang</option>
<option value="Sastra Cina" <?php if($jurusan_kuliah=="Sastra
Cina"){echo"selected";}?>>Sastra Cina</option>
<option value="Sastra Mandarin" <?php if($jurusan_kuliah=="Sastra
Mandarin"){echo"selected";}?>>Sastra Mandarin</option>
<option value="Sastra Inggris" <?php if($jurusan_kuliah=="Sastra
Inggris"){echo"selected";}?>>Sastra Inggris</option>
<option value="Ekonomi" <?php
if($jurusan_kuliah=="Ekonomi"){echo"selected";}?>>Ekonomi</option>
<option value="Akuntansi" <?php
if($jurusan_kuliah=="Akuntansi"){echo"selected";}?>>Akuntansi</option>
<option value="Teknik Informatika" <?php if($jurusan_kuliah=="Teknik
Informatika"){echo"selected";}?>>Teknik Informatika</option>
<option value="Teknik Mesin" <?php if($jurusan_kuliah=="Teknik
Mesin"){echo"selected";}?>>Teknik Mesin</option>
<option value="Teknik Industri" <?php if($jurusan_kuliah=="Teknik
Industri"){echo"selected";}?>>Teknik Industri</option>
<option value="Teknik Elektronika" <?php if($jurusan_kuliah=="Teknik
Elektronika"){echo"selected";}?>>Teknik Elektronika</option>
<option value="Teknik Perkapalan" <?php if($jurusan_kuliah=="Teknik
Perkapalan"){echo"selected";}?>>Teknik Perkapalan</option>
<option value="Sistem Perkapalan" <?php if($jurusan_kuliah=="Sistem
Perkapalan"){echo"selected";}?>>Sistem Perkapalan</option>
<option value="Sistem Informasi" <?php if($jurusan_kuliah=="Sistem
Informasi"){echo"selected";}?>>Sistem Informasi</option> </select> </label></td>
</tr>

<tr>
<td height="24">fakultas
<td>:<td colspan="2">
<div id="fakultas">
<input name="fakultas" type="text" id="fakultas" value="<?php echo $fakultas;?>"
size="15" />
</div>
</td>
</tr>

<tr>
<td height="24">penjurusan
<td>:<td colspan="2"><label>
<select name="penjurusan" id="penjurusan" onChange="showJurusan(this.value)">
<option value="-">-</option>
<option value="IPA" <?php if($penjurusan=="IPA"){echo"selected";}?>>IPA</option>
<option value="IPS" <?php if($penjurusan=="IPS"){echo"selected";}?>>IPS</option>
<option value="Teknik Otomotif" <?php if($penjurusan=="Teknik
Otomotif"){echo"selected";}?>>Teknik Otomotif</option>
<option value="Permesinan" <?php
if($penjurusan=="Permesinan"){echo"selected";}?>>Permesinan</option>
<option value="Administrasi Perkantoran" <?php if($penjurusan=="Administrasi
Perkantoran"){echo"selected";}?>>Administrasi Perkantoran</option>
<option value="Akuntansi" <?php
if($penjurusan=="Akuntansi"){echo"selected";}?>>Akuntansi</option>
<option value="Ekomomi" <?php
if($penjurusan=="Ekomomi"){echo"selected";}?>>Ekomomi</option>
<option value="Analis Kesehatan" <?php if($penjurusan=="Analis
Kesehatan"){echo"selected";}?>>Analis Kesehatan</option>
<option value="Multimedia" <?php
if($penjurusan=="Multimedia"){echo"selected";}?>>Multimedia</option>
<option value="Audio Video" <?php if($penjurusan=="Audio
Video"){echo"selected";}?>>Audio Video</option>
<option value="Bahasa" <?php
if($penjurusan=="Bahasa"){echo"selected";}?>>Bahasa</option>
<option value="Broadcasting" <?php
if($penjurusan=="Broadcasting"){echo"selected";}?>>Broadcasting</option>
<option value="Elektronika" <?php
if($penjurusan=="Elektronika"){echo"selected";}?>>Elektronika</option>
<option value="Farmasi" <?php
if($penjurusan=="Farmasi"){echo"selected";}?>>Farmasi</option>
<option value="Tata Boga" <?php if($penjurusan=="Tata
Boga"){echo"selected";}?>>Tata Boga</option>
<option value="Tata Busana" <?php if($penjurusan=="Tata
Busana"){echo"selected";}?>>Tata Busana</option>
<option value="Tata Niaga" <?php if($penjurusan=="Tata
Niaga"){echo"selected";}?>>Tata Niaga</option>
<option value="Komputer dan Jaringan" <?php if($penjurusan=="Komputer dan
Jaringan"){echo"selected";}?>>Komputer dan Jaringan</option>
<option value="Manajemen" <?php
if($penjurusan=="Manajemen"){echo"selected";}?>>Manajemen</option>
<option value="Nautika" <?php
if($penjurusan=="Nautika"){echo"selected";}?>>Nautika</option>
<option value="Pariwisata" <?php
if($penjurusan=="Pariwisata"){echo"selected";}?>>Pariwisata</option>
<option value="Pemasaran" <?php
if($penjurusan=="Pemasaran"){echo"selected";}?>>Pemasaran</option>
<option value="Penjualan" <?php
if($penjurusan=="Penjualan"){echo"selected";}?>>Penjualan</option>
<option value="Perawat" <?php
if($penjurusan=="Perawat"){echo"selected";}?>>Perawat</option>
<option value="Perdagangan" <?php
if($penjurusan=="Perdagangan"){echo"selected";}?>>Perdagangan</option>
<option value="Perhotelan" <?php
if($penjurusan=="Perhotelan"){echo"selected";}?>>Perhotelan</option>
<option value="RPL" <?php
if($penjurusan=="RPL"){echo"selected";}?>>RPL</option>
<option value="Saintek" <?php
if($penjurusan=="Saintek"){echo"selected";}?>>Saintek</option>
<option value="Sekretaris" <?php
if($penjurusan=="Sekretaris"){echo"selected";}?>>Sekretaris</option>
<option value="Travel" <?php
if($penjurusan=="Travel"){echo"selected";}?>>Travel</option>
<option value="Elektronika" <?php
if($penjurusan=="Elektronika"){echo"selected";}?>>Elektronika</option>
</select>
</label></td></tr>

<tr>
<td height="24">jurusan_sma<?php echo $_POST['jurusan_sma']; ?>
<td>:<td colspan="2">
<div id="jurusan_sma">
<input name="jurusan_sma" type="text" id="jurusan_sma" value="<?php echo
$jurusan_sma ;?>" size="15" />
</div>
</td>
</tr>

<tr>
<td><label for="status">status_kelulusan</label>
<td>:<td colspan="2">
<input type="radio" name="status_kelulusan" id="status_kelulusan"
checked="checked" value="1" <?php
if($status_kelulusan=="1"){echo"checked";}?>/>Cepat
<input type="radio" name="status_kelulusan" id="status_kelulusan" value="2" <?php
if($status_kelulusan=="2"){echo"checked";}?>/>Terlambat

</td></tr>
<td height="24">keterangan
<td>:<td colspan="2"><textarea name="keterangan" cols="25"
id="keterangan"><?php echo $keterangan;?></textarea>
</td>
</tr>

<tr>
<td><label for="status">status</label>
<td>:<td colspan="2">
<input type="radio" name="status" id="statusya" checked="checked" value="Aktif"
<?php if($status=="Aktif"){echo"checked";}?>/>Aktif
<input type="radio" name="status" id="statustidak" value="Tidak Aktif" <?php
if($status=="Tidak Aktif"){echo"checked";}?>/>Tidak Aktif
</td></tr>
<tr>
<td>
<td>
<td colspan="2"> <input name="Simpan" type="submit" id="Simpan"
onClick="MM_validateForm('nama_calon_mhs','','R','nilai_sttb','','RinRange0:100');ret
urn document.MM_returnValue" value="Simpan" />
<input name="pro" type="hidden" id="pro" value="<?php echo $pro;?>" />
<input name="jurusan_kuliah0" type="hidden" id="jurusan_kuliah0" value="<?php
echo $jurusan_kuliah0;?>" />
<input name="kode_calon_mhs" type="hidden" id="kode_calon_mhs" value="<?php
echo $kode_calon_mhs;?>" />
<a class="orange" href="?mnu=calonmhs"><img src="ypathicon/button-
cancel.png">Batal</a>
</td></tr>
</table>
</form>
SOURCE CODE IMPLEMENTASI ALGORITMA APRIORI

$NI[0]="1";
$NI[1]="2";
$NI[2]="3";
$NI[3]="4";
$NI[4]="5";

$JK[0]="1";
$JK[1]="2";

$JS[0]="1";
$JS[1]="2";
$JS[2]="3";
$JS[3]="4";

$DK[0]="1";
$DK[1]="2";
$DK[2]="3";
$DK[3]="4";

$GL[0]="1";
$GL[1]="2";

//echo"<hr><h1>Data 1AN </h1>";


//echo"Data Nilai :Param0<br>";
for($k=0;$k<count($NI);$k++){
$nilai=getSatu($M,0,$NI[$k]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$k+1;
$arAttr[$idx]="A".$n;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;
}
}

//echo"<hr>";
//echo"Data JK :Param1<br>";
for($k=0;$k<count($JK);$k++){
$nilai=getSatu($M,1,$JK[$k]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$k+1;
$arAttr[$idx]="B".$n;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;
}
}

//echo"<hr>";
//echo"Data Jur SMA:Param2<br>";
for($k=0;$k<count($JS);$k++){
$nilai=getSatu($M,2,$JS[$k]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$k+1;
$arAttr[$idx]="C".$n;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;
}
}

//echo"<hr>";
//echo"Data Kuliah:Param3<br>";
for($k=0;$k<count($DK);$k++){
$nilai=getSatu($M,3,$DK[$k]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$k+1;
$arAttr[$idx]="D".$n;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;
//echo"<hr>";
//echo"Data Gel:Param4<br>";
for($k=0;$k<count($GL);$k++){
$nilai=getSatu($M,4,$GL[$k]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$k+1;
$arAttr[$idx]="E".$n;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;

//echo"<hr><h1>Data 2AN </h1>";


//echo"Kombinasi A dan B<br>";
for($j=0;$j<count($NI);$j++){
for($k=0;$k<count($JK);$k++){
$nilai=getDua($M,0,1,$NI[$j],$JK[$k]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$j+1;
$m=$k+1;
$arAttr[$idx]="A".$n."B".$m;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;
}
}
}
//echo"<hr>";
//echo"Kombinasi A dan C<br>";
for($j=0;$j<count($NI);$j++){
for($k=0;$k<count($JS);$k++){
$nilai=getDua($M,0,2,$NI[$j],$JS[$k]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$j+1;
$m=$k+1;
$arAttr[$idx]="A".$n."C".$m;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;

//echo"<hr>";
//echo"Kombinasi A dan D<br>";
for($j=0;$j<count($NI);$j++){
for($k=0;$k<count($DK);$k++){
$nilai=getDua($M,0,3,$NI[$j],$DK[$k]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$j+1;
$m=$k+1;
$arAttr[$idx]="A".$n."D".$m;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;

//echo"<hr>";
//echo"Kombinasi A dan E<br>";
for($j=0;$j<count($NI);$j++){
for($k=0;$k<count($GL);$k++){
$nilai=getDua($M,0,4,$NI[$j],$GL[$k]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$j+1;
$m=$k+1;
$arAttr[$idx]="A".$n."E".$m;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;
}
//echo"<hr>";

echo"<hr><h1>Data 3AN</h1>";
for($j=0;$j<count($NI);$j++){
for($k=0;$k<count($JK);$k++){
for($l=0;$l<count($JS);$l++){
$nilai=getTiga($M,0,1,2,$NI[$j],$JK[$k],$JS[$l]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$j+1;
$m=$k+1;
$x=$l+1;
$arAttr[$idx]="A".$n."B".$m."C".$x;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;

//echo"<hr><h1>Data 4AN</h1>";
//echo"Kombinasi C, D dan E<br>";
for($j=0;$j<count($JS);$j++){
for($k=0;$k<count($DK);$k++){
for($l=0;$l<count($GL);$l++){
$nilai=getTiga($M,2,3,4,$JS[$j],$DK[$k],$GL[$l]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$j+1;
$m=$k+1;
$x=$l+1;
$arAttr[$idx]="C".$n."D".$m."E".$x;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;

for($j=0;$j<count($NI);$j++){
for($k=0;$k<count($JK);$k++){
for($l=0;$l<count($JS);$l++){
for($t=0;$t<count($DK);$t++){
$nilai=getEmpat($M,0,1,2,3,$NI[$j],$JK[$k],$JS[$l],$DK[$t]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$j+1;
$m=$k+1;
$x=$l+1;
$y=$t+1;
$arAttr[$idx]="A".$n."B".$m."C".$x."D".$y;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;

//echo"Kombinasi B, C, D DAN E<br>";


for($j=0;$j<count($JK);$j++){
for($k=0;$k<count($JS);$k++){
for($l=0;$l<count($DK);$l++){
for($t=0;$t<count($GL);$t++){
$nilai=getEmpat($M,1,2,3,4,$JK[$j],$JS[$k],$DK[$l],$GL[$t]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$n=$j+1;
$m=$k+1;
$x=$l+1;
$y=$t+1;
$arAttr[$idx]="B".$n."C".$m."D".$x."E".$y;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;

////echo"<hr><h1>Data 5AN</h1>";
//echo"Kombinasi A, B, C, D DAN E<br>";
for($i=0;$i<count($NI);$i++){
for($j=0;$j<count($JK);$j++){
for($k=0;$k<count($JS);$k++){
for($l=0;$l<count($DK);$l++){
for($t=0;$t<count($GL);$t++){
$nilai=getLima($M,0,1,2,3,4,$NI[$i],$JK[$j],$JS[$k],$DK[$l],$GL[$t]);
$v= ($nilai/$jumdata)* 100;
if($v>=$_SESSION["cvalue"]){
$h=$i+1;
$n=$j+1;
$m=$k+1;
$x=$l+1;
$y=$t+1;
$arAttr[$idx]="A".$h."B".$n."C".$m."D".$x."E".$y;
$arJum[$idx]=$nilai;
$arSupp[$idx]=$v;
$idx++;

echo"<h2><a href='#'>Data Perhitungan Support</a></h2>


<div>";
$m6=0;
$m8=0;
$m10=0;
$sql="delete from tb_perhitungan ";
mysql_query($sql);
echo"<table width='40%' border='1'>";
$nom=0;
echo "<tr><td>No.<td>Atribut<td>Jumlah<td>Support</td></tr>";
for($i=0;$i<$idx;$i++){
$nom++;
echo
"<tr><td>$nom<td>".$arAttr[$i]."<td>".$arJum[$i]."<td>".$arSupp[$i]."</td></tr>";
$sql="INSERT INTO `tb_perhitungan` (`id`, `attribut`, `jumlah`, `support`) VALUES ('',
'".$arAttr[$i]."', '".$arJum[$i]."', '".$arSupp[$i]."')";
mysql_query($sql);

if(strlen($arAttr[$i])==6){
$Hatribut[$m6]=$arAttr[$i];
$Hjum[$m6]=$arJum[$i];
$Hsup[$m6]=$arSupp[$i];
$m6++;
}
if(strlen($arAttr[$i])==8){
$Hatribut[$m8]=$arAttr[$i];
$Hjum[$m8]=$arJum[$i];
$Hsup[$m8]=$arSupp[$i];
$m8++;
}
if(strlen($arAttr[$i])==10){
$Hatribut[$m10]=$arAttr[$i];
$Hjum[$m10]=$arJum[$i];
$Hsup[$m10]=$arSupp[$i];
$m10++;
}
}
echo"</table><br>";
echo"</div>";
echo"<h2><a href='#'>Data Perhitungan Confidence</a></h2>
<div>";

$sql="delete from tb_kombinasi ";


mysql_query($sql);
if(count($Hatribut)>0){

echo"<table border='1' width='40%'><tr><td>No<td>Aturan (X->Y) <td> Support (X


U Y) <td>Support (X) <td> Confidence</tr>";
$nomor=0;
for($i=0;$i<count($Hatribut);$i++){
$k1=substr($Hatribut[$i],0,2);
$k2=substr($Hatribut[$i],2,2);
$k3=substr($Hatribut[$i],4,2);

$kombine1=$k1.$k2;
$kombine2=$k1.$k3;
$kombine3=$k2.$k3;

$BC=getValues($kombine1,$arAttr,$arSupp);
$BE=getValues($kombine2,$arAttr,$arSupp);
$CE=getValues($kombine3,$arAttr,$arSupp);
$B=getValues($k1,$arAttr,$arSupp);
$C=getValues($k2,$arAttr,$arSupp);
$E=getValues($k3,$arAttr,$arSupp);

$minE=$E;
if($E>$BC){$minE=$BC;}

$minC=$C;
if($C>$BE){$minC=$BE;}

$minB=$B;
if($B>$CE){$minB=$CE;}

$V1=$minE+$BC;
if($V1>=$_SESSION["ccon"]){
$nomor++;
echo "<tr><td>$nomor<td>".$kombine1."-> $k3 <td> ".$minE."<td> ".$BC."
<td> ". ($V1)." </td></tr>";
$sql="INSERT INTO `tb_kombinasi` (`id`, `attribut1`, `attribut2`, `supportxy`,
`supportx`, `confidence`) VALUES ('', '$kombine1', '$k3', '$minE', '$BC', '$V1')";
mysql_query($sql);
//insert
}
$V2=$minC+$BE;
if($V2>=$_SESSION["ccon"]){
$nomor++;
echo "<tr><td>$nomor<td>".$kombine2."-> $k2 <td> ".$minC."<td> ".$BE."
<td> ". ($V2)." </td></tr>";
//echo $kombine2."-> $k2 | ".$minC." | ".$BE." | ". ($V2)." <br>";
$sql="INSERT INTO `tb_kombinasi` (`id`, `attribut1`, `attribut2`, `supportxy`,
`supportx`, `confidence`) VALUES ('', '$kombine2', '$k2', '$minC', '$BE', '$V2')";