@@ -143,7 +143,7 @@ |
||
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 | } |
@@ -37,7 +37,7 @@ |
||
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 |
@@ -241,7 +241,7 @@ |
||
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, |
@@ -188,7 +188,7 @@ discard block |
||
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 |
||
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 |
@@ -100,7 +100,7 @@ |
||
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); |
@@ -220,7 +220,7 @@ |
||
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); |
@@ -93,7 +93,7 @@ discard block |
||
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 |
||
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 | } |
@@ -48,7 +48,7 @@ |
||
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 |
@@ -52,7 +52,7 @@ discard block |
||
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 |
||
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 | } |