Change floatvar to float casting (up to 6 times faster)

This commit is contained in:
Arkadiusz Kondas 2016-12-06 08:52:33 +01:00
parent d00b7e5668
commit 9764890ccb
2 changed files with 2 additions and 2 deletions

View File

@ -32,7 +32,7 @@ class TfIdfTransformer implements Transformer
$count = count($samples);
foreach ($this->idf as &$value) {
$value = log(floatval($count / $value), 10.0);
$value = log((float)($count / $value), 10.0);
}
}

View File

@ -78,7 +78,7 @@ class Normalizer implements Preprocessor
foreach ($sample as $feature) {
$norm2 += $feature * $feature;
}
$norm2 = sqrt(floatval($norm2));
$norm2 = sqrt((float)$norm2);
if (0 == $norm2) {
$sample = array_fill(0, count($sample), 1);