@@ -91,7 +91,7 @@ |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | - * @param $column |
|
94 | + * @param integer $column |
|
95 | 95 | * |
96 | 96 | * @return array |
97 | 97 | * |
@@ -128,7 +128,7 @@ |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * @return mixed |
|
131 | + * @return integer |
|
132 | 132 | */ |
133 | 133 | public function count() |
134 | 134 | { |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | protected $dimension; |
18 | 18 | |
19 | 19 | /** |
20 | - * @param $dimension |
|
20 | + * @param integer $dimension |
|
21 | 21 | */ |
22 | 22 | public function __construct($dimension) |
23 | 23 | { |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | /** |
226 | 226 | * @param int $clustersNumber |
227 | 227 | * |
228 | - * @return array |
|
228 | + * @return Cluster[] |
|
229 | 229 | */ |
230 | 230 | protected function initializeKMPPClusters(int $clustersNumber) |
231 | 231 | { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | }, $db); |
68 | 68 | } else { |
69 | 69 | $this->mean[$label][$i] = Mean::arithmetic($values); |
70 | - // Add epsilon in order to avoid zero stdev |
|
70 | + // Add epsilon in order to avoid zero stdev |
|
71 | 71 | $this->std[$label][$i] = 1e-10 + StandardDeviation::population($values, false); |
72 | 72 | } |
73 | 73 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Calculates the probability P(label|sample_n) |
78 | - * |
|
78 | + * |
|
79 | 79 | * @param array $sample |
80 | 80 | * @param int $feature |
81 | 81 | * @param string $label |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | $mean= $this->mean[$label][$feature]; |
95 | 95 | // Calculate the probability density by use of normal/Gaussian distribution |
96 | 96 | // Ref: https://en.wikipedia.org/wiki/Normal_distribution |
97 | - // |
|
98 | - // In order to avoid numerical errors because of small or zero values, |
|
99 | - // some libraries adopt taking log of calculations such as |
|
100 | - // scikit-learn did. |
|
101 | - // (See : https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/naive_bayes.py) |
|
102 | - $pdf = -0.5 * log(2.0 * pi() * $std * $std); |
|
103 | - $pdf -= 0.5 * pow($value - $mean, 2) / ($std * $std); |
|
104 | - return $pdf; |
|
97 | + // |
|
98 | + // In order to avoid numerical errors because of small or zero values, |
|
99 | + // some libraries adopt taking log of calculations such as |
|
100 | + // scikit-learn did. |
|
101 | + // (See : https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/naive_bayes.py) |
|
102 | + $pdf = -0.5 * log(2.0 * pi() * $std * $std); |
|
103 | + $pdf -= 0.5 * pow($value - $mean, 2) / ($std * $std); |
|
104 | + return $pdf; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |