diff --git a/composer.json b/composer.json index b2edf58..5554c1d 100755 --- a/composer.json +++ b/composer.json @@ -24,9 +24,9 @@ "php": "^7.4|^8.0|^8.1" }, "require-dev": { - "squizlabs/php_codesniffer": "^3.4", - "phpstan/phpstan": "^0.12", - "pestphp/pest": "^1.18" + "phpstan/phpstan": "^1.10", + "pestphp/pest": "^1.23", + "friendsofphp/php-cs-fixer": "^3.34" }, "autoload": { "psr-4": { diff --git a/src/Algorithms/Slopeone/Predictor.php b/src/Algorithms/Slopeone/Predictor.php index 720545a..e024491 100755 --- a/src/Algorithms/Slopeone/Predictor.php +++ b/src/Algorithms/Slopeone/Predictor.php @@ -35,7 +35,8 @@ public function getPrediction(array $evaluation, string $target): float $sum += ($value + $vectors[1][$key]) * $card; $freq += $card; } - $predValue = $sum / $freq; + + $predValue = $sum / ($freq !== 0 ? $freq : 1); return round($predValue, $this->vector->getScale()); }