Manage Products - Initial
This commit is contained in:
@@ -1968,20 +1968,20 @@ function changeLogVisual($totals,$details){
|
||||
$totalcount += $total['total'];
|
||||
}
|
||||
|
||||
//GET SERIALNUMBERS
|
||||
$url_input = ''; //used to collect serialnumber for onclick event
|
||||
foreach ($details as $detail){
|
||||
$url_input .= $detail['serialnumber'].',';
|
||||
}
|
||||
|
||||
$view = '<div style="margin-bottom: 30px;" onclick="location.href=\'index.php?page=equipments&serialnumber='.substr($url_input,0,-1).'\'">
|
||||
$view = '<div style="margin-bottom: 30px;">
|
||||
<ul style="width: 100%;max-width:100%" class="chart">
|
||||
';
|
||||
foreach ($totals as $total){
|
||||
|
||||
$height = ($total['total'] / $totalcount) * 100;
|
||||
$title = $total['DoW'].'/'.$total['WoW'];
|
||||
$view .='<li style="text-align:center;">' . $total['total'] . '<span style="height:' . $height . '%" title="' . $title . '"></span></li>';
|
||||
foreach ($totals as $total){
|
||||
//GET SERIALNUMBERS
|
||||
$url_input = ''; //used to collect serialnumber for onclick event
|
||||
foreach ($details as $detail){
|
||||
if ($detail['WoW'] == $total['WoW'] && $detail['DoW'] == $total['DoW']){
|
||||
$url_input .= $detail['serialnumber'].',';
|
||||
}
|
||||
}
|
||||
$height = ($total['total'] / $totalcount) * 100;
|
||||
$title = $total['DoW'].'/'.$total['WoW'];
|
||||
$view .='<li style="text-align:center;" onclick="location.href=\'index.php?page=equipments&serialnumber='.substr($url_input,0,-1).'\'">' . $total['total'] . '<span style="height:' . $height . '%" title="' . $title . '"></span></li>';
|
||||
}
|
||||
$view .='</ul></div>';
|
||||
|
||||
@@ -2228,4 +2228,84 @@ $messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
//Excute Query
|
||||
$stmt->execute();
|
||||
}
|
||||
}
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ML data preparations
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
function traintotalMeasurement($messages){
|
||||
|
||||
//total measurement internal array
|
||||
$total_measurement = [];
|
||||
|
||||
foreach ($messages as $message){
|
||||
//Cleanup input array
|
||||
$dataset = json_decode($message['description'],true);
|
||||
$dataset = $dataset["doubletestvalues"];
|
||||
foreach ($dataset as $measure){
|
||||
//Filter out correct measurements
|
||||
if ($measure['pass'] === true){
|
||||
$measurementid = $message['equipmentid'].'-'.$message['rowID'];
|
||||
$total_measurement[$measure['name']][$measurementid] = $measure['measure'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $total_measurement;
|
||||
}
|
||||
|
||||
function statisticalAnalyses($total_measurement){
|
||||
|
||||
//result array
|
||||
$total_results = [];
|
||||
|
||||
//STATISTICAL ANALYSES INTERNAL ARRAY
|
||||
foreach ($total_measurement as $key => $value){
|
||||
$average = $total_results[$key]['average'] = average($value);
|
||||
$median = $total_results[$key]['median'] = calculateMedian($value);
|
||||
$stdev = $total_results[$key]['stdev'] = standDeviation($value);
|
||||
$total_results[$key]['n'] = count($value);
|
||||
|
||||
//GET STDEV -/+
|
||||
$total_results[$key]['stdev-1'] = $average - $stdev;
|
||||
$total_results[$key]['stdev+1'] = $average + $stdev;
|
||||
$total_results[$key]['stdev-2'] = $average - (2*$stdev);
|
||||
$total_results[$key]['stdev+2'] = $average + (2*$stdev);
|
||||
$total_results[$key]['stdev-3'] = $average - (3*$stdev);
|
||||
$total_results[$key]['stdev+3'] = $average + (3*$stdev);
|
||||
}
|
||||
|
||||
return $total_results;
|
||||
}
|
||||
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Main statiscal functions for ML
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
function standDeviation($arr)
|
||||
{
|
||||
$num_of_elements = count($arr);
|
||||
$variance = 0.0;
|
||||
// Calculate mean using array_sum() method
|
||||
$average = array_sum($arr) / $num_of_elements;
|
||||
foreach($arr as $i)
|
||||
{
|
||||
// Sum of squares of differences between all numbers and means.
|
||||
$variance += pow(($i - $average), 2);
|
||||
}
|
||||
return (float)sqrt($variance / $num_of_elements);
|
||||
}
|
||||
function average($arr)
|
||||
{
|
||||
$num_of_elements = count($arr);
|
||||
$average = array_sum($arr) / $num_of_elements;
|
||||
return $average;
|
||||
}
|
||||
function calculateMedian($array) {
|
||||
if (empty($array)) {
|
||||
return null;
|
||||
} else {
|
||||
sort($array);
|
||||
$lowMiddle = $array[floor((count($array) - 1) / 2)];
|
||||
$highMiddle = $array[ceil((count($array) - 1) / 2)];
|
||||
return ($lowMiddle + $highMiddle) / 2;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user