@@ -48,7 +48,7 @@ |
||
| 48 | 48 | |
| 49 | 49 | public function transform(array &$samples, ?array &$targets = null): 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 | |
@@ -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; |
@@ -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(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 |
||
| 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 | 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(function (array $class) { |
|
| 79 | + return array_map(function(array $class) { |
|
| 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(function ($sum) { |
|
| 100 | + return array_map(function($sum) { |
|
| 101 | 101 | return $sum ** 2; |
| 102 | 102 | }, $squares); |
| 103 | 103 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | $count = count($samples); |
| 59 | 59 | $this->idf = array_map( |
| 60 | - function (float $value) use ($count): float { |
|
| 60 | + function(float $value) use ($count): float { |
|
| 61 | 61 | return $value > 0.0 |
| 62 | 62 | ? log($count / $value, 10) |
| 63 | 63 | : 0; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | public function transform(array &$samples, ?array &$targets = null): void |
| 70 | 70 | { |
| 71 | - array_walk($samples, function (array &$sample): void { |
|
| 71 | + array_walk($samples, function(array &$sample): void { |
|
| 72 | 72 | foreach ($sample as $index => &$feature) { |
| 73 | 73 | if ($this->termCounts[$index] < $this->minTf || $this->idf[$index] < $this->minIdf) { |
| 74 | 74 | unset($sample[$index]); |