Min Value : 0.0
Max Value : 564.0

Distance1 data:

class 1:

SeedPoint(2)= [53, 72, 124, 189, 261, ]

SeedPoint(4)= [5, 6, 11, 12, 13, 15, 16, 19, 20, 22, 23, 24, 25, 26, 27, 28, 30, 32, 33, 39, 40, 42, 43, 44, 46, 52, 53, 54, 55, 56, 58, 61, 63, 64, 65, 67, 69, 72, 73, 74, 75, 77, 78, 79, 80, 84, 85, 86, 87, 88, 89, 91, 97, 99, 100, 101, 103, 107, 110, 112, 114, 115, 116, 119, 124, 125, 126, 128, 129, 133, 135, 136, 137, 139, 140, 142, 144, 150, 151, 152, 153, 154, 155, 156, 158, 159, 163, 165, 166, 167, 168, 169, 171, 174, 175, 180, 181, 184, 185, 186, 188, 189, 191, 193, 195, 196, 197, 198, 199, 201, 206, 207, 208, 210, 212, 213, 215, 216, 217, 218, 219, 220, 223, 225, 226, 229, 230, 233, 235, 237, 239, 240, 242, 243, 245, 248, 252, 254, 255, 256, 257, 260, 261, 264, 266, 267, 268, 269, ]

class 2:

SeedPoint(1)= [3, 7, 8, 9, 10, 14, 17, 18, 21, 29, 31, 34, 35, 36, 37, 38, 41, 45, 47, 48, 49, 50, 51, 57, 59, 60, 62, 66, 68, 70, 71, 76, 81, 82, 83, 90, 92, 93, 94, 95, 96, 98, 102, 104, 105, 106, 108, 109, 111, 113, 117, 118, 120, 121, 122, 123, 127, 130, 131, 132, 134, 138, 141, 143, 145, 146, 147, 148, 149, 157, 160, 161, 162, 164, 170, 172, 173, 176, 177, 178, 179, 182, 183, 187, 190, 192, 194, 200, 202, 203, 204, 205, 209, 211, 214, 221, 222, 224, 227, 228, 231, 232, 234, 236, 238, 241, 244, 246, 247, 249, 250, 251, 253, 258, 259, 262, 263, 265, 270, ]

سورس کد

<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Data1 extends CI_Controller {

    public 
$min_data=null;
    public 
$max_data=null;

    public 
$data_normal=null;
    public 
$data=null;

    public 
$threshold=0.4,$eps=0.4;
    public 
$minPoint=3;

    
    public function 
index()
    {
        
$data= array(
            
"site_title" =>"مجموعه داده بیماران قلبی",
            
"mnu_workshop" =>"active",
            
        );
        
        
//$this->load->view('header');
        
$this->load->view('header',$data);
        
$this->load->view('datamining/data1');
        
$this->load->view('footer');
    }
    
    public function 
execute()
    {
        echo 
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
        echo 
'<body dir="rtl" style= "font-family:tahoma;">';


            
        
$myfile fopen(base_url()."assets/datamining/heart.txt""r") or die("Unable to open file!");
        
$i=0;
        while(!
feof($myfile))
        {
            
$linetrim(fgets($myfile)) ;

            
$data[$i]=explode(" ",$line);

            
$min_datamin($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],$data[$i][4],$data[$i][5],$data[$i][6],$data[$i][7],$data[$i][8],$data[$i][9],$data[$i][10],$data[$i][11],$data[$i][12]);

            
$max_datamax($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],$data[$i][4],$data[$i][5],$data[$i][6],$data[$i][7],$data[$i][8],$data[$i][9],$data[$i][10],$data[$i][11],$data[$i][12]);

            if(
$i==0)
            {
                
$this->min_data =$min_data;
                
$this->max_data $max_data;
            }
            else
            {
               if(
$min_data$this->min_data)
               {
                   
$this->min_data =$min_data;
               }

                if(
$max_data$this->max_data)
                {
                    
$this->max_data =$max_data;
                }

            }
            
$i++;
        }
        
fclose($myfile);

        
$this->data=$data;

        echo 
"<div dir='ltr'><b>Min Value : </b>"$this->min_data;
        echo 
"<br /><b>Max Value : </b>"$this->max_data;
        echo 
"</div>";

        
$this->data_normal$this->normalize($data);


        
$distance1$this->distance($this->data_normal,1);






echo 
"<br/><div dir='ltr'>Distance1 data:<br/><textarea style='width:100%; height:350px;'>";
foreach(
$distance1 as $indexRow=> $row ){
$vals$indexRow +;

foreach(
$row as $indexCol=> $col ){
$vals2$indexCol +1;
$val=round($col,3);
echo 
"[$vals,$vals2]=$val\t";
}
echo 
"\n\n";
}
echo
"</textarea></div>";





        
$distance2$this->distance($this->data_normal,2);

        
$seed1=$this->seedPoint($distance1$this->threshold$this->minPoint);
        
$seed2=$this->seedPoint($distance2$this->threshold$this->minPoint);


        echo 
"<h4 dir='ltr' >class 1:</h4>";
        foreach (
$seed1 as $indexRow =>$rows)
        {
$inx=$indexRow+1;
            echo 
"<div dir='ltr'>SeedPoint($inx)= [";
            foreach (
$rows as $indexCol => $cols)
            {
$cols2=$cols+1;
                echo 
"$cols2, ";
            }
            echo 
"]</div><br/>";
        }

        echo 
"<h4 dir='ltr' >class 2:</h4>";
        foreach (
$seed2 as $indexRow =>$rows)
        {
$inx=$indexRow+1;
            echo 
"<div dir='ltr' >SeedPoint($inx)= [";
            foreach (
$rows as $indexCol => $cols)
            {
$cols2=$cols+1;
                echo 
"$cols2, ";
            }
            echo 
"]</div></br>";
        }
        


        echo 
'<div dir="ltr">';
        echo 
'<h4>سورس کد</h4>';
        echo 
show_source(__FILE__);
        
    }

    private function 
normalize($data)
    {
        foreach(
$data as $rowcell =>$row)
        {
            foreach(
$row as $colcell=>$col)
            {
               if( 
$colcell==13)
                    continue;

                @
$normal =  ( $col $this-> min_data )/ ($this-> max_data $this-> min_data ) ;
                
$normal round($normal ,3);
                
$data_normal[$rowcell][$colcell] = $normal;
            }
        }
        return 
$data_normal;
    }

    private function 
distance($data,$class)
    {
        
$cnt=count($data);

        for(
$i=0$i<$cnt$i++)
        {
            if(
$this->data[$i][13] !=$class)
                continue;

            for(
$j=0$j<$cnt$j++)
            {
                if(
$i==$j)
                    continue;
                if(
$this->data[$j][13] !=$class)
                    continue;
                
$dte=0;
                for(
$k=0$k<=count($data[$i]); $k++)
                {
                    if( 
$k==13 )
                        continue;

                    
$dte += ($data[$i][$k] - $data[$j][$k]) *  ($data[$i][$k] - $data[$j][$k]) ;
                }

                
$dte=sqrt($dte);
                
$dist[$i][$j]=$dte;
            }
        }

       
// var_dump($dist);
        
return $dist;
    }

    private function 
seedPoint($data$threshold$minPoint)
    {
        
$seed=null;

        foreach (
$data as $indexRow => $rows)
        {
            
$i=0;
            
$temp=array();

            foreach (
$rows as $indexCol=> $val)
            {
                if( 
$val <= $threshold )
                {
                    
$temp[$i]= $indexCol;
                    
$i++;
                }
            }

            if (
$this->seedCheck($seed$indexRow)==true)
                continue;

            if(
$i >= $minPoint-1)
            {
                foreach(
$temp as $indexTemp => $rowTemp)
                {
                    
$seed[$indexRow][$indexTemp]=$rowTemp;
                }
            }
        }

        return 
$seed;
    }

    private function 
seedCheck($seed$point)
    {


        if(!empty(
$seed))
        {
            foreach (
$seed as $indexRowSeed => $rowSeed)
            {
                foreach (
$rowSeed as $indexColSeed => $colSeed)
                {
                    
/*if ($point == $indexRowSeed)
                       return true;*/
                    
if ($point == $colSeed)
                        return 
true;
                }
            }
        }
    }
}
1