@@ -18,10 +18,10 @@ |
||
18 | 18 | |
19 | 19 | public function __construct(array $datasetColumns, array $filterColumns) |
20 | 20 | { |
21 | - $this->datasetColumns = array_map(static function (string $column): string { |
|
21 | + $this->datasetColumns = array_map(static function(string $column): string { |
|
22 | 22 | return $column; |
23 | 23 | }, $datasetColumns); |
24 | - $this->filterColumns = array_map(static function (string $column): string { |
|
24 | + $this->filterColumns = array_map(static function(string $column): string { |
|
25 | 25 | return $column; |
26 | 26 | }, $filterColumns); |
27 | 27 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | throw new InvalidArgumentException('At least one pipeline is required'); |
23 | 23 | } |
24 | 24 | |
25 | - $this->pipelines = array_map(static function (Pipeline $pipeline): Pipeline { |
|
25 | + $this->pipelines = array_map(static function(Pipeline $pipeline): Pipeline { |
|
26 | 26 | return $pipeline; |
27 | 27 | }, $pipelines); |
28 | 28 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function __construct(array $transformers, ?Estimator $estimator = null) |
25 | 25 | { |
26 | - $this->transformers = array_map(static function (Transformer $transformer): Transformer { |
|
26 | + $this->transformers = array_map(static function(Transformer $transformer): Transformer { |
|
27 | 27 | return $transformer; |
28 | 28 | }, $transformers); |
29 | 29 | $this->estimator = $estimator; |
@@ -126,7 +126,7 @@ |
||
126 | 126 | public function transpose(): self |
127 | 127 | { |
128 | 128 | if ($this->rows === 1) { |
129 | - $matrix = array_map(static function ($el): array { |
|
129 | + $matrix = array_map(static function($el): array { |
|
130 | 130 | return [$el]; |
131 | 131 | }, $this->matrix[0]); |
132 | 132 | } else { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | throw new InvalidArgumentException('The array must have at least 2 elements'); |
29 | 29 | } |
30 | 30 | |
31 | - $samplesPerClass = array_map(static function (array $class): int { |
|
31 | + $samplesPerClass = array_map(static 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 |
||
41 | 41 | $dfbn = $classes - 1; |
42 | 42 | $dfwn = $allSamples - $classes; |
43 | 43 | |
44 | - $msb = array_map(static function ($s) use ($dfbn) { |
|
44 | + $msb = array_map(static function($s) use ($dfbn) { |
|
45 | 45 | return $s / $dfbn; |
46 | 46 | }, $ssbn); |
47 | - $msw = array_map(static function ($s) use ($dfwn) { |
|
47 | + $msw = array_map(static function($s) use ($dfwn) { |
|
48 | 48 | if ($dfwn === 0) { |
49 | 49 | return 1; |
50 | 50 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | private static function sumOfFeaturesPerClass(array $samples): array |
78 | 78 | { |
79 | - return array_map(static function (array $class): array { |
|
79 | + return array_map(static function(array $class): array { |
|
80 | 80 | $sum = array_fill(0, count($class[0]), 0); |
81 | 81 | foreach ($class as $sample) { |
82 | 82 | foreach ($sample as $index => $feature) { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - return array_map(static function ($sum) { |
|
100 | + return array_map(static function($sum) { |
|
101 | 101 | return $sum ** 2; |
102 | 102 | }, $squares); |
103 | 103 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | $mean = Mean::arithmetic($numbers); |
51 | 51 | |
52 | 52 | return array_sum(array_map( |
53 | - static function ($val) use ($mean): float { |
|
53 | + static function($val) use ($mean): float { |
|
54 | 54 | return ($val - $mean) ** 2; |
55 | 55 | }, |
56 | 56 | $numbers |
@@ -37,7 +37,7 @@ |
||
37 | 37 | |
38 | 38 | public function fit(array $samples, ?array $targets = null): void |
39 | 39 | { |
40 | - $this->variances = array_map(static function (array $column): float { |
|
40 | + $this->variances = array_map(static function(array $column): float { |
|
41 | 41 | return Variance::population($column); |
42 | 42 | }, Matrix::transposeArray($samples)); |
43 | 43 |
@@ -50,7 +50,7 @@ |
||
50 | 50 | $this->value = $value; |
51 | 51 | $this->groups = $groups; |
52 | 52 | $this->impurity = $impurity; |
53 | - $this->samplesCount = (int) array_sum(array_map(static function (array $group): int { |
|
53 | + $this->samplesCount = (int) array_sum(array_map(static function(array $group): int { |
|
54 | 54 | return count($group[0]); |
55 | 55 | }, $groups)); |
56 | 56 | } |
@@ -139,7 +139,7 @@ |
||
139 | 139 | $total += $val; |
140 | 140 | } |
141 | 141 | |
142 | - $this->membership[] = array_map(static function ($val) use ($total): float { |
|
142 | + $this->membership[] = array_map(static function($val) use ($total): float { |
|
143 | 143 | return $val / $total; |
144 | 144 | }, $row); |
145 | 145 | } |