<?php
include_once('../config/koneksi-apriori.php');
$item1 = count($item) - 1;
$item2 = count($item);
// MENDAPATKAN JUMLAH BARANG
foreach ($item as $value) {
$total_per_item[$value] = 0;
foreach($belian as $item_belian) {
if(strpos($item_belian, $value) !== false) {
$total_per_item[$value]++;
}
}
}
// MENDAPAT JUMLAH GABUNGAN
for($i = 0; $i < $item1; $i++) {
for($j = $i+1; $j < $item2; $j++) {
$item_pair = $item[$i].'|'.$item[$j];
$item_array[$item_pair] = 0;
foreach($belian as $item_belian) {
if((strpos($item_belian, $item[$i]) !== false) && (strpos($item_belian, $item[$j]) !== false)) {
$item_array[$item_pair]++;
}
}
}
}
echo "<pre>";
foreach ($item_array as $ia_key => $ia_value) {
$theitems = explode('|',$ia_key);
for($x = 0; $x < count($theitems); $x++) {
$item_name = $theitems[$x];
$item_total = $total_per_item[$item_name];
if ($item_total == 0) {
$in_float = 0;
}else{
$in_float = $ia_value / $item_total;
}
$in_percent = round($in_float * 100, 2);
$alt_item = $theitems[ ($x + 1) % count($theitems)];
echo "[*] $ia_key --> $item_name "."\r\n";
echo "[*] Confidence --> ".$ia_value." / ".$item_total." = ".$in_float."\r\n" ;
echo "----> if buy $item_name then $alt_item with Confidence = ". $in_percent ."%\r\n";
echo "===============================================================\r\n";
}
}
echo "</pre>";
?>
i want to get variable $in_float more than 4.5%