@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Phpml\NeuralNetwork; |
6 | 6 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * @return Neuron |
46 | 46 | */ |
47 | - private function createNode(string $nodeClass, ?ActivationFunction $activationFunction = null): Node |
|
47 | + private function createNode(string $nodeClass, ?ActivationFunction $activationFunction = null) : Node |
|
48 | 48 | { |
49 | 49 | if ($nodeClass == Neuron::class) { |
50 | 50 | return new Neuron($activationFunction); |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Phpml\Metric; |
6 | 6 | |
7 | 7 | class ConfusionMatrix |
8 | 8 | { |
9 | - public static function compute(array $actualLabels, array $predictedLabels, ?array $labels = null): array |
|
9 | + public static function compute(array $actualLabels, array $predictedLabels, ? array $labels = null) : array |
|
10 | 10 | { |
11 | 11 | $labels = $labels ? array_flip($labels) : self::getUniqueLabels($actualLabels); |
12 | 12 | $matrix = self::generateMatrixWithZeros($labels); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Phpml\Association; |
6 | 6 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function predictSample(array $sample): array |
106 | 106 | { |
107 | - $predicts = array_values(array_filter($this->getRules(), function ($rule) use ($sample) { |
|
107 | + $predicts = array_values(array_filter($this->getRules(), function($rule) use ($sample) { |
|
108 | 108 | return $this->equals($rule[self::ARRAY_KEY_ANTECEDENT], $sample); |
109 | 109 | })); |
110 | 110 | |
111 | - return array_map(function ($rule) { |
|
111 | + return array_map(function($rule) { |
|
112 | 112 | return $rule[self::ARRAY_KEY_CONSEQUENT]; |
113 | 113 | }, $predicts); |
114 | 114 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $cardinality = count($sample); |
178 | 178 | $antecedents = $this->powerSet($sample); |
179 | 179 | |
180 | - return array_filter($antecedents, function ($antecedent) use ($cardinality) { |
|
180 | + return array_filter($antecedents, function($antecedent) use ($cardinality) { |
|
181 | 181 | return (count($antecedent) != $cardinality) && ($antecedent != []); |
182 | 182 | }); |
183 | 183 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - return array_map(function ($entry) { |
|
202 | + return array_map(function($entry) { |
|
203 | 203 | return [$entry]; |
204 | 204 | }, $items); |
205 | 205 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | private function frequent(array $samples): array |
215 | 215 | { |
216 | - return array_filter($samples, function ($entry) { |
|
216 | + return array_filter($samples, function($entry) { |
|
217 | 217 | return $this->support($entry) >= $this->support; |
218 | 218 | }); |
219 | 219 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | private function frequency(array $sample): int |
289 | 289 | { |
290 | - return count(array_filter($this->samples, function ($entry) use ($sample) { |
|
290 | + return count(array_filter($this->samples, function($entry) use ($sample) { |
|
291 | 291 | return $this->subset($entry, $sample); |
292 | 292 | })); |
293 | 293 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | private function contains(array $system, array $set): bool |
304 | 304 | { |
305 | - return (bool) array_filter($system, function ($entry) use ($set) { |
|
305 | + return (bool) array_filter($system, function($entry) use ($set) { |
|
306 | 306 | return $this->equals($entry, $set); |
307 | 307 | }); |
308 | 308 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Phpml\Math; |
6 | 6 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | public function transpose(): self |
127 | 127 | { |
128 | 128 | if ($this->rows == 1) { |
129 | - $matrix = array_map(function ($el) { |
|
129 | + $matrix = array_map(function($el) { |
|
130 | 130 | return [$el]; |
131 | 131 | }, $this->matrix[0]); |
132 | 132 | } else { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Phpml\Math\Statistic; |
6 | 6 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @throws InvalidArgumentException |
16 | 16 | */ |
17 | - public static function fromXYArrays(array $x, array $y, bool $sample = true, ?float $meanX = null, ?float $meanY = null): float |
|
17 | + public static function fromXYArrays(array $x, array $y, bool $sample = true, ?float $meanX = null, ?float $meanY = null) : float |
|
18 | 18 | { |
19 | 19 | if (empty($x) || empty($y)) { |
20 | 20 | throw InvalidArgumentException::arrayCantBeEmpty(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @throws InvalidArgumentException |
53 | 53 | * @throws \Exception |
54 | 54 | */ |
55 | - public static function fromDataset(array $data, int $i, int $k, bool $sample = true, ?float $meanX = null, ?float $meanY = null): float |
|
55 | + public static function fromDataset(array $data, int $i, int $k, bool $sample = true, ?float $meanX = null, ?float $meanY = null) : float |
|
56 | 56 | { |
57 | 57 | if (empty($data)) { |
58 | 58 | throw InvalidArgumentException::arrayCantBeEmpty(); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @param array|null $means |
117 | 117 | */ |
118 | - public static function covarianceMatrix(array $data, ?array $means = null): array |
|
118 | + public static function covarianceMatrix(array $data, ? array $means = null) : array |
|
119 | 119 | { |
120 | 120 | $n = count($data[0]); |
121 | 121 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * @package JAMA |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Class to obtain eigenvalues and eigenvectors of a real matrix. |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | // Always return the eigenvectors of length 1.0 |
130 | 130 | $vectors = new Matrix($vectors); |
131 | - $vectors = array_map(function ($vect) { |
|
131 | + $vectors = array_map(function($vect) { |
|
132 | 132 | $sum = 0; |
133 | 133 | for ($i = 0; $i < count($vect); ++$i) { |
134 | 134 | $sum += $vect[$i] ** 2; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Phpml\Math\Distance; |
6 | 6 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | throw InvalidArgumentException::arraySizeNotMatch(); |
19 | 19 | } |
20 | 20 | |
21 | - return array_sum(array_map(function ($m, $n) { |
|
21 | + return array_sum(array_map(function($m, $n) { |
|
22 | 22 | return abs($m - $n); |
23 | 23 | }, $a, $b)); |
24 | 24 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Phpml\Helper\Optimizer; |
6 | 6 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * The cost function to minimize and the gradient of the function are to be |
145 | 145 | * handled by the callback function provided as the third parameter of the method. |
146 | 146 | */ |
147 | - public function runOptimization(array $samples, array $targets, Closure $gradientCb): ?array |
|
147 | + public function runOptimization(array $samples, array $targets, Closure $gradientCb): ? array |
|
148 | 148 | { |
149 | 149 | $this->samples = $samples; |
150 | 150 | $this->targets = $targets; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | { |
230 | 230 | // Check for early stop: No change larger than threshold (default 1e-5) |
231 | 231 | $diff = array_map( |
232 | - function ($w1, $w2) { |
|
232 | + function($w1, $w2) { |
|
233 | 233 | return abs($w1 - $w2) > $this->threshold ? 1 : 0; |
234 | 234 | }, |
235 | 235 | $oldTheta, |