mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-21 20:45:10 +00:00
Change floatvar to float casting (up to 6 times faster)
This commit is contained in:
parent
d00b7e5668
commit
9764890ccb
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user