From 696a2f6ea9862b6ba68dd2353afc23230feef138 Mon Sep 17 00:00:00 2001 From: Dom Morgan Date: Thu, 23 May 2024 18:23:20 +0100 Subject: [PATCH] Do not allow zero local reachability density in LocalOutlierFactor (#335) See https://github.com/RubixML/ML/issues/334 --- src/AnomalyDetectors/LocalOutlierFactor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AnomalyDetectors/LocalOutlierFactor.php b/src/AnomalyDetectors/LocalOutlierFactor.php index 91e42869f..edb0638ae 100644 --- a/src/AnomalyDetectors/LocalOutlierFactor.php +++ b/src/AnomalyDetectors/LocalOutlierFactor.php @@ -287,7 +287,7 @@ protected function localOutlierFactor(array $sample) : float { [$samples, $indices, $distances] = $this->tree->nearest($sample, $this->k); - $lrd = $this->localReachabilityDensity($indices, $distances); + $lrd = $this->localReachabilityDensity($indices, $distances) ?: EPSILON; $ratios = [];