<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
 <html xmlns="http://www.w3.org/1999/xhtml"> 
<?php
error_reporting(0);
?>  
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
	<meta http-equiv="Refresh" content="3; URL=HASIL KLASIFIKASI2.php"> 
    <meta name="description" content="" />
    <meta name="author" content="" />
    <!--[if IE]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <![endif]-->
    <title> KLASIFIKASI STATUS EKONOMI</title>
    <!-- BOOTSTRAP CORE STYLE CSS -->
    <link href="assets/css/bootstrap.css" rel="stylesheet" />
    <!-- FONTAWESOME STYLE CSS -->
    <link href="assets/css/font-awesome.min.css" rel="stylesheet" />
    <!-- PRETTYPHOTO STYLE CSS -->
    <link href="assets/css/prettyPhoto.css" rel="stylesheet" />
    <!-- CUSTOM STYLE CSS -->
    <link href="assets/css/style.css" rel="stylesheet" />    
    <!-- GOOGLE FONT -->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />

</head>
   
 <body> 
    <?php
			$nama=$_POST['nama'];
			$t1=$_POST['t1'];
			$t2=$_POST['t2'];
			$t3=$_POST['t3'];
			$t4=$_POST['t4'];
			 $sql9 = mysql_query("TRUNCATE TABLE databaru1");	
			$query = "INSERT INTO databaru1(nama,t1,t2,t3,t4) VALUES('$nama','$t1','$t2','$t3','$t4')";
			   $hasil = mysql_query($query);
			?>
    <div class="navbar navbar-inverse navbar-fixed-top" >
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">ZAMALUDIN ARSYAD</a>
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="admin.php">BERANDA</a></li>
                     <li><a href="DATASET.PHP">DATASET</a></li>
                    <li><a href="ANALISA.PHP">ANALISA</a></li>
                     <li><a href="nilai_k.PHP">HASIL KLASIFIKASI</a></li>
                      <li><a href="index.PHP">LOG OUT</a></li>
                </ul>
            </div>
           
        </div>
    </div>
   <!--/.NAVBAR END-->
        
       
	    <section id="BERANDA" class="text-center">
         
                <div id="carousel-example" class="carousel slide" data-ride="carousel">

                    <div class="carousel-inner">
                        <div class="item active">

                            <img src="assets/img/1.jpg" alt="" />
                            <div class="carousel-caption" >
                                <h2 class="back-light"><CENTER><table><tr><td><div class="col-md-120 col-sm-120" >
                         
                           <div class="skill-name">PROSES BERJALAN TUNGGU BEBERAPA MENIT</div> 
                            <div class="progress progress-striped active progress-adjust">
  <div class="progress-bar progress-bar-primary" role="progressbar" aria-valuenow="100" aria-valuemin="50" aria-valuemax="100" style="width: 100%">
    <span class="sr-only">100% Complete</span>


                        </td></tr></table> </CENTER>
 </section>
	   
	   
    <!--/.HEADING END-->

 <section id="port-sec">
       <div class="container">
           
           <div class="row pad-row" > 
                               <div class="col-md-12 col-sm-12" > 
                    <ul class="ANALISA-items col-3"> 
                        <li class="ANALISA-item">
                            <div class="item-main">
                                <div class="ANALISA-image">
                                    
                                    <div class="overlay">
                                         
                                    </div>
									 
 <?php
include 'koneksi.php'; 		

								
$sql2= mysql_query("SELECT AVG(ht)as jumlah FROM hasil");
  while ($dt2 = mysql_fetch_array($sql2)) {
	  $jumlah=$dt2['jumlah'];
	 
	  echo"<h1>";
	  //echo number_format($jumlah,0);
	  echo"</h1>";
		
 			
}
?>					
                             
						  
                                 
                            </div>
                        </li>
                       
                        <li class="ANALISA-item">
                            <div class="item-main">
                                <div class="ANALISA-image">
                                      
                                    <div class="overlay">
                                       
                                     
                                </div><center>
 <?php
include 'koneksi.php'; 
$queryTR = mysql_query("SELECT * FROM spek_data");
if(!$queryTR){
	die( mysql_error() );
}$i=1;
while($rowsTR = mysql_fetch_array($queryTR)){
	$tr=$rowsTR['tr'];
}
$sql2 = mysql_query("SELECT sum(error) as jumlah FROM data1");
	  while ($dt2 = mysql_fetch_array($sql2)) {
	  $jumlah=$dt2['jumlah'];
	  $rmse=SQRT($jumlah/$tr);
	  echo"<h1>";
	  //echo number_format($rmse,0);
	  echo"</h1>";
		}
 							
?>


								
                                 
                            </div>
                        </li>
                        <li class="ANALISA-item">
                            <div class="item-main">
                                <div class="ANALISA-image">
                                    
                                    <div class="overlay">
                                       </div>
                             


 <?php
include'koneksi.php';
$sql2 = mysql_query("SELECT AVG( op ) as jumlah FROM training");
	  while ($dt2 = mysql_fetch_array($sql2)) {
	  $jumlah=$dt2['jumlah'];
	  $acr=$jumlah-$rmse;
	  $hasil=$acr*100;
	  $hasil2=$hasil/$jumlah;
	  echo"<h1>";
	  //echo number_format($hasil2,2);echo "%";
	  echo"</h1>";
		}
 							
?>									   
                                    
                                </div>
                                
                            </div>
                        </li>
                        
                    </ul>
                </div>
           </div>
       </div>
   </section>
     <!--/. END ANALISA SECTION-->
      <section  class="note-sec" >
         
               <div class="container">
           <div class="row text-center pad-row" >
            <div class="col-md-8 col-md-offset-2 col-sm-8 col-sm-offset-2 ">
                 
               <p>
                             <MARQUEE> <H2> KLASIFIKASI STATUS EKONOMI MASYARAKAT DENGAN METODE K-NEAREST NEIGHBOR</H2> </MARQUEE>
                            </p>
                </div>
               </div>
            </div>   
           
       </section>
    <!--/.NOTE END-->
     <section id="clients"  >
        
                
            <div class="container">
           <div class="row text-RIGHT pad-bottom" >
            <div class="col-md-12">
                <P  ><h5> <strong>&copy; 2017 UNISAN FIKOM @Zamaludin Arsyad</strong> </h5></P>
            </div>
               
               </div>
        </div>
        </section>
     <!--/.CLIENTS END-->
    <section id="footer-sec" >
             
            
               <div class="col-md-4">
                   
                            <p>
                                
                            </p>
                   
            </div>
    </section>         
    <!--/.FOOTER END-->
 
 <center> 
	<table border="1"><tr><td colspan="7"><center>Nilai keetanggaan</center></td></tr>
	<tr>
	<th><center>no</th>
	<th><center>k</th>
	<th><center>yt</th>
        <th><center>x1</th>
        <th><center>x2</th>
		<th><center>x3</th>
		<th><center>x4</th></tr>
	 
<?php							
include"koneksi.php";	
	//menghitung ketetanggan dan simpan di data1

$queryT = mysql_query("SELECT * FROM testing");
if(!$queryT){
	die( mysql_error() );
}$i=1;
	while($rows = mysql_fetch_array($queryT)){
	
	$yt=$rows['yt'];
	$t1=$rows['t1'];
	$t2=$rows['t2'];
	$t3=$rows['t3'];
	$t4=$rows['t4'];
	
	
		}
		?>								
								
<?php
include"koneksi.php";
//INPUT DATA TRAINING
$sql9 = mysql_query("TRUNCATE TABLE nilai_k");
$queryTR = mysql_query("SELECT * FROM training");
if(!$queryTR){
	die( mysql_error() );
}$i=1;
	while($rowsTR = mysql_fetch_array($queryTR)){
	$no=$rowsTR['no'];
	$op=$rowsTR['op'];
	$c1=$rowsTR['c1'];
	$c2=$rowsTR['c2'];
	$c3=$rowsTR['c3'];
	$c4=$rowsTR['c4'];
	
$a1=($c1-$t1);$ha1=($a1*$a1);
$a2=($c2-$t2);$ha2=($a2*$a2);
$a3=($c3-$t3);$ha3=($a3*$a3);
$a4=($c4-$t4);$ha4=($a4*$a4);
$tetangga=($ha1+$ha2+$ha3+$ha4);
$t=sqrt($tetangga);

echo"<tr><td><center>";
echo ($no);
echo"</center></td><td><center>";
echo number_format($t,0);
echo"</center></td><td><center>";
echo ($op);
echo"</center></td><td><center>";
echo ($c1);
echo"</td><td><center>";
echo ($c2);
echo"</center></td><td><center>";
echo ($c3);
echo"</td><td><center>";
echo ($c4);
echo"</td></tr>";

 $query = "INSERT INTO nilai_k(k,rt,r1,r2,r3,r4) VALUES('$t','$op','$c1','$c2','$c3','$c4')";
$data4= mysql_query($query);

 }
  
?>


	
	
	
	<?php
//$sql9 = mysql_query("TRUNCATE TABLE data2");	
$queryTR = mysql_query("SELECT * FROM spek_data");

if(!$queryTR){
	die( mysql_error() );
}$i=1;
	while($rowsTR = mysql_fetch_array($queryTR)){
	$k=$rowsTR['k'];
	$v=$rowsTR['v'];
	$jd=$rowsTR['jd'];
	$tr=$rowsTR['tr'];
	$ts=$rowsTR['ts'];

 
 }

?>
</table>
	<table border="1"><tr><td colspan="7"><center><?php echo " $k Nilai keetanggaan";?></center></td></tr>
	<tr>
	
	<th><center>k</th>
	<th><center>yt</th>
        <th><center>x1</th>
        <th><center>x2</th>
		<th><center>x3</th>
		<th><center>x4</th></tr>
	<?php
$sql9 = mysql_query("TRUNCATE TABLE rmse");	
$queryTR = mysql_query("SELECT * FROM nilai_k ORDER BY k ASC LIMIT 0,$k ");

if(!$queryTR){
	die( mysql_error() );
}$i=1;
	while($rowsTR = mysql_fetch_array($queryTR)){
	$k=$rowsTR['k'];
	$rt=$rowsTR['rt'];
	$r1=$rowsTR['r1'];
	$r2=$rowsTR['r2'];
	$r3=$rowsTR['r3'];
	$r4=$rowsTR['r4'];
	
	

echo"<tr><td colspan='5'><center>";

echo "</center></td></tr><tr><td><center>";
echo number_format($k,0);
echo "</center></td><td><center>";
echo ($rt);
echo"</center></td><td><center>";
echo ($r1);
echo"</td><td><center>";
echo ($r2);
echo"</center></td><td><center>";
echo ($r3);
echo"</td><td><center>";
echo ($r4);
echo"</td></tr>";
 
  $query = "INSERT INTO rmse(k,rt,r1,r2,r3,r4) VALUES('$k','$rt','$r1','$r2','$r3','$r4')";
$data4= mysql_query($query);
 
 }
 

 $sql9 = mysql_query("TRUNCATE TABLE data1");	
 $queryTR = mysql_query("SELECT * FROM rmse ");

if(!$queryTR){
	die( mysql_error() );
}$i=1;
	while($rowsTR = mysql_fetch_array($queryTR)){
	$k=$rowsTR['k'];
	$rt=$rowsTR['rt'];
	 }
 $queryTR = mysql_query("SELECT * FROM training order by no asc limit 0,1000");
if(!$queryTR){
	die( mysql_error() );
}$i=1;
	while($rowsTR = mysql_fetch_array($queryTR)){
	
	$op=$rowsTR['op'];
	 //echo $op;
	// echo $rt;
	 $a=$op-$rt; $b=$a*$a;
	echo "<br>$b";
	
	
	
	$query = "INSERT INTO data1(error) VALUES('$b')";
$data4= mysql_query($query);
	}

?>


<?php
//hitung prediksi
include'koneksi.php';
$queryTR = mysql_query("SELECT * FROM databaru1");
if(!$queryTR){
	die( mysql_error() );
}$i=1;
	while($rowsTR = mysql_fetch_array($queryTR)){
	
	
	$t1=$rowsTR['t1'];
	$t2=$rowsTR['t2'];
	$t3=$rowsTR['t3'];
	$t4=$rowsTR['t4'];
	}
include'koneksi.php';	
$sql9 = mysql_query("TRUNCATE TABLE databaru");								
$queryTR = mysql_query("SELECT * FROM training");
if(!$queryTR){
	die( mysql_error() );
}$i=1;
	while($rowsTR = mysql_fetch_array($queryTR)){
	$no=$rowsTR['no'];
	$op=$rowsTR['op'];
	$c1=$rowsTR['c1'];
	$c2=$rowsTR['c2'];
	$c3=$rowsTR['c3'];
	$c4=$rowsTR['c4'];
	
	
$a1=($c1-$t1);$ha1=($a1*$a1);
$a2=($c2-$t2);$ha2=($a2*$a2);
$a3=($c3-$t3);$ha3=($a3*$a3);
$a4=($c4-$t4);$ha4=($a4*$a4);
$tetangga=($ha1+$ha2+$ha3+$ha4);
$t=sqrt($tetangga);
	
	
$query = "INSERT INTO databaru(no,prediksi,hasil,x1t,x2t,x3t,x4t) VALUES('$no','$t','$op','$c1','$c2','$c3','$c4')";
$data4= mysql_query($query);
}
?>	





<center><table border="1">
<tr><td colspan="5"> <center> KETETANGGAAN :
<?php
include 'koneksi.php'; 		
$queryTR = mysql_query("SELECT * FROM spek_data");
if(!$queryTR){
	die( mysql_error() );
}$i=1;
while($rowsTR = mysql_fetch_array($queryTR)){
	$k=$rowsTR['k'];
	echo $k;
	}
	?></td></tr>

<tr>
<th><center>Prediksi</center></th>
        <th><center>x1</center></th>
        <th><center>x2</center></th>
		<th><center>x3</center></th>
		<th><center>x4</center></th></tr>
 <?php
include 'koneksi.php'; 		
$queryTR = mysql_query("SELECT * FROM spek_data");
if(!$queryTR){
	die( mysql_error() );
}$i=1;
while($rowsTR = mysql_fetch_array($queryTR)){
	$k=$rowsTR['k'];
	}
	?>
	<?php
	$sql9 = mysql_query("TRUNCATE TABLE hasil");							
$queryTR = mysql_query("SELECT * FROM databaru ORDER BY prediksi ASC LIMIT 1,$k");
if(!$queryTR){
	die( mysql_error() );
}$i=1;
	while($rowsTR = mysql_fetch_array($queryTR)){
	$no=$rowsTR['no'];
	$prediksi=$rowsTR['prediksi'];
	$hasil=$rowsTR['hasil'];
	$x1t=$rowsTR['x1t'];
	$x2t=$rowsTR['x2t'];
	$x3t=$rowsTR['x3t'];
	$x4t=$rowsTR['x4t'];
						
echo"<tr><td><center>";
echo ($prediksi);
echo"</center></td><td><center>";
echo ($x1t);
echo"</td><td><center>";
echo ($x2t);
echo"</center></td><td><center>";
echo ($x3t);
echo"</td><td><center>";
echo ($x4t);
echo"</td><center></tr>";

$query = "INSERT INTO hasil(no,ht,h1,h2,h3,h4) VALUES('$no','$hasil','$x1t','$x2t','$x3t','$x4t')";
$data4= mysql_query($query);

}
 
?>	
 </table> </center> 
</body></html>

				
                        

 