new things
This commit is contained in:
@@ -184,23 +184,47 @@ class FightTrainingController extends ControllerBase {
|
||||
* This needs to be between 0-1
|
||||
*/
|
||||
private function normalizeData(array $data): array {
|
||||
// @todo - this creates an issue where duration of fight is the largest number which isnt really correct
|
||||
// and smaller duration would be better
|
||||
//
|
||||
$min = min(array_values($data));
|
||||
$max = max(array_values($data));
|
||||
$normalized = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$norm_val = 0;
|
||||
if ($max - $min == 0) {
|
||||
$normalized[$key] = $norm_val;
|
||||
}
|
||||
else {
|
||||
$norm_val = ($value - $min) / ($max - $min);
|
||||
$normalized[$key] = $norm_val;
|
||||
}
|
||||
|
||||
$value = (float) $value;
|
||||
$normalized[$key] = $this->convertToDecimal($value);
|
||||
/* $norm_val = 0; */
|
||||
/* if ($max - $min == 0) { */
|
||||
/* $normalized[$key] = $norm_val; */
|
||||
/* } */
|
||||
/* else { */
|
||||
/* $norm_val = ($value - $min) / ($max - $min); */
|
||||
/* $normalized[$key] = $norm_val; */
|
||||
/* } */
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
public function convertToDecimal(float $input) {
|
||||
$output = 0;
|
||||
if ($input > 0 && $input <= 1) {
|
||||
$output = $input / 100;
|
||||
}
|
||||
elseif ($input > 1 && $input < 10) {
|
||||
$output = $input / 100;
|
||||
}
|
||||
elseif ($input > 10 && $input < 100) {
|
||||
$output = $input / 1000;
|
||||
}
|
||||
elseif ($input > 100 && $input < 1000) {
|
||||
$output = $input / 10000;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the trained neural network.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user