Test Setup Failed
Pull Request — master (#350)
by Pol
03:52 queued 01:31
created
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.
src/FeatureExtraction/TokenCountVectorizer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 
49 49
     public function transform(array &$samples): void
50 50
     {
51
-        array_walk($samples, function (string &$sample): void {
51
+        array_walk($samples, function(string &$sample): void {
52 52
             $this->transformSample($sample);
53 53
         });
54 54
 
Please login to merge, or discard this patch.
src/FeatureSelection/ScoringFunction/UnivariateLinearRegression.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
         $degreesOfFreedom = count($targets) - ($this->center ? 2 : 1);
54 54
 
55
-        return array_map(function (float $correlation) use ($degreesOfFreedom): float {
55
+        return array_map(function(float $correlation) use ($degreesOfFreedom): float {
56 56
             return $correlation ** 2 / (1 - $correlation ** 2) * $degreesOfFreedom;
57 57
         }, $correlations);
58 58
     }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     private function centerTargets(array &$targets): void
61 61
     {
62 62
         $mean = Mean::arithmetic($targets);
63
-        array_walk($targets, function (&$target) use ($mean): void {
63
+        array_walk($targets, function(&$target) use ($mean): void {
64 64
             $target -= $mean;
65 65
         });
66 66
     }
Please login to merge, or discard this patch.
src/Classification/Linear/Adaline.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
     protected function runTraining(array $samples, array $targets): void
59 59
     {
60 60
         // The cost function is the sum of squares
61
-        $callback = function ($weights, $sample, $target) {
61
+        $callback = function($weights, $sample, $target) {
62 62
             $this->weights = $weights;
63 63
 
64 64
             $output = $this->output($sample);
Please login to merge, or discard this patch.
src/Classification/Linear/Perceptron.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@
 block discarded – undo
154 154
     protected function runTraining(array $samples, array $targets): void
155 155
     {
156 156
         // The cost function is the sum of squares
157
-        $callback = function ($weights, $sample, $target) {
157
+        $callback = function($weights, $sample, $target) {
158 158
             $this->weights = $weights;
159 159
 
160 160
             $prediction = $this->outputClass($sample);
Please login to merge, or discard this patch.
src/DimensionReduction/KernelPCA.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -172,20 +172,20 @@  discard block
 block discarded – undo
172 172
         switch ($this->kernel) {
173 173
             case self::KERNEL_LINEAR:
174 174
                 // k(x,y) = xT.y
175
-                return function ($x, $y) {
175
+                return function($x, $y) {
176 176
                     return Matrix::dot($x, $y)[0];
177 177
                 };
178 178
             case self::KERNEL_RBF:
179 179
                 // k(x,y)=exp(-γ.|x-y|) where |..| is Euclidean distance
180 180
                 $dist = new Euclidean();
181 181
 
182
-                return function ($x, $y) use ($dist) {
182
+                return function($x, $y) use ($dist) {
183 183
                     return exp(-$this->gamma * $dist->sqDistance($x, $y));
184 184
                 };
185 185
 
186 186
             case self::KERNEL_SIGMOID:
187 187
                 // k(x,y)=tanh(γ.xT.y+c0) where c0=1
188
-                return function ($x, $y) {
188
+                return function($x, $y) {
189 189
                     $res = Matrix::dot($x, $y)[0] + 1.0;
190 190
 
191 191
                     return tanh((float) $this->gamma * $res);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                 // k(x,y)=exp(-γ.|x-y|) where |..| is Manhattan distance
196 196
                 $dist = new Manhattan();
197 197
 
198
-                return function ($x, $y) use ($dist) {
198
+                return function($x, $y) use ($dist) {
199 199
                     return exp(-$this->gamma * $dist->distance($x, $y));
200 200
                 };
201 201
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     protected function projectSample(array $pairs): array
221 221
     {
222 222
         // Normalize eigenvectors by eig = eigVectors / eigValues
223
-        $func = function ($eigVal, $eigVect) {
223
+        $func = function($eigVal, $eigVect) {
224 224
             $m = new Matrix($eigVect, false);
225 225
             $a = $m->divideByScalar($eigVal)->toArray();
226 226
 
Please login to merge, or discard this patch.
src/Math/Statistic/ANOVA.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
             throw new InvalidArgumentException('The array must have at least 2 elements');
29 29
         }
30 30
 
31
-        $samplesPerClass = array_map(function (array $class): int {
31
+        $samplesPerClass = array_map(function(array $class): int {
32 32
             return count($class);
33 33
         }, $samples);
34 34
         $allSamples = (int) array_sum($samplesPerClass);
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
         $dfbn = $classes - 1;
42 42
         $dfwn = $allSamples - $classes;
43 43
 
44
-        $msb = array_map(function ($s) use ($dfbn) {
44
+        $msb = array_map(function($s) use ($dfbn) {
45 45
             return $s / $dfbn;
46 46
         }, $ssbn);
47
-        $msw = array_map(function ($s) use ($dfwn) {
47
+        $msw = array_map(function($s) use ($dfwn) {
48 48
             return $s / $dfwn;
49 49
         }, $sswn);
50 50
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
     private static function sumOfFeaturesPerClass(array $samples): array
74 74
     {
75
-        return array_map(function (array $class) {
75
+        return array_map(function(array $class) {
76 76
             $sum = array_fill(0, count($class[0]), 0);
77 77
             foreach ($class as $sample) {
78 78
                 foreach ($sample as $index => $feature) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             }
94 94
         }
95 95
 
96
-        return array_map(function ($sum) {
96
+        return array_map(function($sum) {
97 97
             return $sum ** 2;
98 98
         }, $squares);
99 99
     }
Please login to merge, or discard this patch.