session_start();
require_once 'twitteroauth/twitteroauth.php';
require_once 'config/config.php';
require_once 'config/db.php';
require_once 'lib/following.php';
require_once 'lib/follower.php';
require_once 'lib/following.php';
require_once 'lib/follower2.php';
require_once 'lib/following2.php';
require_once 'lib/kmeans.php';
require_once 'lib/centroid.php';
$db = new db();
$following_dao = new following_dao();
$following = $following_dao->getAll();
$following_dao = new Following_dao();
$data = $following_dao->getAll();
$clos_id = array();
$clos_val = array();
foreach ($data as $datum) {
    $x = $datum->similarity_followers + $datum->similarity_friends;
    //nilai total similarity
    $y = $datum->id;
    //id following
    $clos_id[] = $y;
    $clos_val[] = $x;
}
$clos = array_combine($clos_id, $clos_val);
//combine id dan nilai similarity
//var_dump($clos);
$id = max_key($clos);
Esempio n. 2
0
require_once 'lib/follower.php';
require_once 'lib/following.php';
require_once 'lib/follower2.php';
require_once 'lib/following2.php';
require_once 'lib/kmeans.php';
require_once 'lib/centroid.php';
$db = new db();
/* $following_dao = new Following_dao;
$following_dao->countCommonFollowing(); //menghitung masing-masing common_friends dari following dan menyimpannya ke tabel following
$following_dao->countCommonFollower();  //menghitung masing-masing common_follower dari following dan menyimpannya ke tabel following
$following_dao->countSimilarity(); 
 */
$user_dao = new User_dao();
$user = $user_dao->getAll();
//mendapatkan data user
$following_dao = new Following_dao();
$datanya = $following_dao->getId();
//mendapatkan data id following
//var_dump($datanya);
// $column1 = "common_followers_count";
// $column2 = "common_friends_count";
$column1 = "similarity_followers";
$column2 = "similarity_friends";
$data = loadData($column1, $column2);
//mendapatkan data similarity dari tabel following
//var_dump($data);
//$data = array(array(0,0),array(0,2), array(2,0), array(2,2), array(5,0), array(5,2), array(7,0), array(7,2));
//$datanya = array("a","b","c","d","e","f","g","h");
$k = $_POST['k'];
//mendapatkan jumlah cluster yang telah diinput
//$k=2;
Esempio n. 3
0
 function ViewCommonFollowing($id)
 {
     $following2_dao = new Following2_dao();
     $following2 = $following2_dao->getById($id);
     $following_dao = new Following_dao();
     foreach ($following2 as $fol2) {
         $count = 0;
         $id2 = $fol2->id2;
         $following = $following_dao->getAll();
         foreach ($following as $fol) {
             $id = $fol->id;
             if ($id2 == $id) {
                 $following = $following_dao->getById($fol2->id2);
                 echo "<a href=\"https://twitter.com/{$following->screen_name}\" target=\"_BLANK\"><img src=\"{$following->profile_image_url}\" alt=\"{$following->name}\" title=\"{$following->name}\"></a>";
             }
         }
         //echo "<br/>";
         //echo $count;
     }
 }
Esempio n. 4
0
 function cluster($k)
 {
     $db = new db();
     $user_dao = new User_dao();
     $user = $user_dao->getAll();
     //get data user
     //create graph
     $graph = new Graph(700, 600);
     //set graph
     $graph->SetScale("linlin");
     $graph->img->SetMargin(70, 50, 50, 50);
     //$graph->SetShadow();
     $graph->title->Set("Friends Twitter Clustering");
     $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 14);
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->title->SetMargin(10);
     $userx = $user->name;
     $graph->subtitle->Set("User: "******" (" . $k . " Kluster)");
     $graph->subtitle->SetFont(FF_FONT1, FS_BOLD);
     //$graph->yaxis->scale->SetAutoMax(1);  //untuk seting max nilai y
     //$graph->xaxis->scale->SetAutoMax(1);  //untuk seting max nilai x
     //
     $following_dao = new Following_dao();
     /* 
     	$data = $following_dao->get();
     	$x = array();
     	$y = array();
     	for($i=0; $i<count($data); $i++){
     		$x[]=$data[$i][0];
     		$y[]=$data[$i][1];	
     	}
     	
     	//format scatterplots data
     	$scatterplots = new ScatterPlot($y, $x); // (Data)
     	$scatterplots->mark->SetType(MARK_FILLEDCIRCLE);
     	$scatterplots->mark->SetFillColor("blue");
     	$scatterplots->mark->SetWidth(4);
     */
     $warna = array("blue", "orange", "green", "purple", "maroon", "pink", "cyan", "violet", "lime", "fuchsia", "maroon", "olive", "navy", "purple", "chocolate", "coral", "lightblue", "orchid", "skyblue", "yellow", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
     //warna untuk cluster
     //data cluster
     for ($i = 0; $i < $k; $i++) {
         $x = array();
         $y = array();
         $data = $following_dao->getByCluster($i + 1);
         //var_dump($data);
         for ($j = 0; $j < count($data); $j++) {
             $x[] = $data[$j][0];
             $y[] = $data[$j][1];
         }
         //var_dump($x);
         $scatterplots[$i] = new ScatterPlot($y, $x);
         $scatterplots[$i]->mark->SetType(MARK_FILLEDCIRCLE);
         if ($warna[$i] == "") {
             $warna[$i] = "gold";
         }
         $scatterplots[$i]->mark->SetFillColor($warna[$i]);
         $scatterplots[$i]->mark->SetWidth(3);
         $graph->Add($scatterplots[$i]);
     }
     // data centroid
     $centroid_dao = new Centroid_dao();
     $data2 = $centroid_dao->get();
     $x2 = array();
     $y2 = array();
     for ($i = 0; $i < count($data2); $i++) {
         $x2[] = $data2[$i][0];
         $y2[] = $data2[$i][1];
     }
     $centroids = new ScatterPlot($y2, $x2);
     // (Centroids)
     $centroids->mark->SetType(MARK_CROSS);
     $centroids->mark->SetFillColor("red");
     $centroids->mark->SetColor("red");
     $centroids->mark->SetWeight(10);
     $centroids->mark->SetWidth(50);
     $centroids->value->SetColor("black");
     // Add plots to graph.
     $graph->Add($centroids);
     //$graph->Add($scatterplots);
     $graph->xaxis->title->Set('Followers Similarity');
     $graph->yaxis->title->Set('Followings Similarity');
     $graph->yaxis->title->SetMargin(10);
     // Display graph
     $graph->Stroke();
 }
Esempio n. 5
0
                $fol = $myfollowing2['followers_count'];
                $fri = $myfollowing2['friends_count'];
                $name = $myfollowing2['name'];
                $place = $myfollowing2['location'];
                $id = $myfollowing2['id'];
                $status = $myfollowing2['statuses_count'];
                $following2 = new Following2();
                $following2->id = $datum2->id;
                $following2->id2 = $id;
                $following2->name = $name;
                $following2->screen_name = $myname;
                $following2->followers_count = $fol;
                $following2->friends_count = $fri;
                $following2->statuses_count = $status;
                $following2->location = $place;
                $following2->profile_image_url = $thumb;
                $following2_dao->add($following2);
            }
        }
        $following2 = "";
        //menghapus objek following2
        $following_dao = new Following_dao();
        $following_dao->countCommonFollowing();
        //menghitung masing-masing common_friends dari following dan menyimpannya ke tabel following
        $following_dao->countCommonFollower();
        //menghitung masing-masing common_follower dari following dan menyimpannya ke tabel following
        $following_dao->countSimilarity();
        //menghitung nilai similarity dari masing-masing following dan menyimpannya ke tabel following
        header("Location:index.php");
    }
}