Completed
Pull Request — master (#317)
by Marcin
08:21
created
src/DimensionReduction/KernelPCA.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -174,20 +174,20 @@  discard block
 block discarded – undo
174 174
         switch ($this->kernel) {
175 175
             case self::KERNEL_LINEAR:
176 176
                 // k(x,y) = xT.y
177
-                return function ($x, $y) {
177
+                return function($x, $y) {
178 178
                     return Matrix::dot($x, $y)[0];
179 179
                 };
180 180
             case self::KERNEL_RBF:
181 181
                 // k(x,y)=exp(-γ.|x-y|) where |..| is Euclidean distance
182 182
                 $dist = new Euclidean();
183 183
 
184
-                return function ($x, $y) use ($dist) {
184
+                return function($x, $y) use ($dist) {
185 185
                     return exp(-$this->gamma * $dist->sqDistance($x, $y));
186 186
                 };
187 187
 
188 188
             case self::KERNEL_SIGMOID:
189 189
                 // k(x,y)=tanh(γ.xT.y+c0) where c0=1
190
-                return function ($x, $y) {
190
+                return function($x, $y) {
191 191
                     $res = Matrix::dot($x, $y)[0] + 1.0;
192 192
 
193 193
                     return tanh($this->gamma * $res);
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                 // k(x,y)=exp(-γ.|x-y|) where |..| is Manhattan distance
198 198
                 $dist = new Manhattan();
199 199
 
200
-                return function ($x, $y) use ($dist) {
200
+                return function($x, $y) use ($dist) {
201 201
                     return exp(-$this->gamma * $dist->distance($x, $y));
202 202
                 };
203 203
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     protected function projectSample(array $pairs): array
223 223
     {
224 224
         // Normalize eigenvectors by eig = eigVectors / eigValues
225
-        $func = function ($eigVal, $eigVect) {
225
+        $func = function($eigVal, $eigVect) {
226 226
             $m = new Matrix($eigVect, false);
227 227
             $a = $m->divideByScalar($eigVal)->toArray();
228 228
 
Please login to merge, or discard this patch.
src/DimensionReduction/LDA.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@
 block discarded – undo
157 157
 
158 158
         // Calculate overall mean of the dataset for each column
159 159
         $numElements = array_sum($counts);
160
-        $map = function ($el) use ($numElements) {
160
+        $map = function($el) use ($numElements) {
161 161
             return $el / $numElements;
162 162
         };
163 163
         $this->overallMean = array_map($map, $overallMean);
Please login to merge, or discard this patch.
src/Clustering/FuzzyCMeans.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
                 $total += $val;
144 144
             }
145 145
 
146
-            $this->membership[] = array_map(function ($val) use ($total) {
146
+            $this->membership[] = array_map(function($val) use ($total) {
147 147
                 return $val / $total;
148 148
             }, $row);
149 149
         }
Please login to merge, or discard this patch.
src/FeatureSelection/VarianceThreshold.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
 
38 38
     public function fit(array $samples, ?array $targets = null): void
39 39
     {
40
-        $this->variances = array_map(function (array $column) {
40
+        $this->variances = array_map(function(array $column) {
41 41
             return Variance::population($column);
42 42
         }, Matrix::transposeArray($samples));
43 43
 
Please login to merge, or discard this patch.
src/Helper/Optimizer/StochasticGD.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -241,7 +241,7 @@
 block discarded – undo
241 241
     {
242 242
         // Check for early stop: No change larger than threshold (default 1e-5)
243 243
         $diff = array_map(
244
-            function ($w1, $w2) {
244
+            function($w1, $w2) {
245 245
                 return abs($w1 - $w2) > $this->threshold ? 1 : 0;
246 246
             },
247 247
             $oldTheta,
Please login to merge, or discard this patch.
src/Classification/Linear/LogisticRegression.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                  * The gradient of the cost function to be used with gradient descent:
189 189
                  *		∇J(x) = -(y - h(x)) = (h(x) - y)
190 190
                  */
191
-                return function ($weights, $sample, $y) use ($penalty) {
191
+                return function($weights, $sample, $y) use ($penalty) {
192 192
                     $this->weights = $weights;
193 193
                     $hX = $this->output($sample);
194 194
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                  * The gradient of the cost function:
221 221
                  *		∇J(x) = -(h(x) - y) . h(x) . (1 - h(x))
222 222
                  */
223
-                return function ($weights, $sample, $y) use ($penalty) {
223
+                return function($weights, $sample, $y) use ($penalty) {
224 224
                     $this->weights = $weights;
225 225
                     $hX = $this->output($sample);
226 226
 
Please login to merge, or discard this patch.
src/Classification/Ensemble/RandomForest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
 
101 101
         // Normalize & sort the importance values
102 102
         $total = array_sum($sum);
103
-        array_walk($sum, function (&$importance) use ($total): void {
103
+        array_walk($sum, function(&$importance) use ($total): void {
104 104
             $importance /= $total;
105 105
         });
106 106
         arsort($sum);
Please login to merge, or discard this patch.
src/Classification/DecisionTree.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -220,7 +220,7 @@
 block discarded – undo
220 220
         // Normalize & sort the importances
221 221
         $total = array_sum($this->featureImportances);
222 222
         if ($total > 0) {
223
-            array_walk($this->featureImportances, function (&$importance) use ($total): void {
223
+            array_walk($this->featureImportances, function(&$importance) use ($total): void {
224 224
                 $importance /= $total;
225 225
             });
226 226
             arsort($this->featureImportances);
Please login to merge, or discard this patch.
src/Preprocessing/Normalizer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             $count = count($sample);
94 94
             $sample = array_fill(0, $count, 1.0 / $count);
95 95
         } else {
96
-            array_walk($sample, function (&$feature) use ($norm1): void {
96
+            array_walk($sample, function(&$feature) use ($norm1): void {
97 97
                 $feature /= $norm1;
98 98
             });
99 99
         }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         if ($norm2 == 0) {
112 112
             $sample = array_fill(0, count($sample), 1);
113 113
         } else {
114
-            array_walk($sample, function (&$feature) use ($norm2): void {
114
+            array_walk($sample, function(&$feature) use ($norm2): void {
115 115
                 $feature /= $norm2;
116 116
             });
117 117
         }
Please login to merge, or discard this patch.