@@ -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): bool { |
|
| 107 | + $predicts = array_values(array_filter($this->getRules(), function($rule) use ($sample): bool { |
|
| 108 | 108 | return $this->equals($rule[self::ARRAY_KEY_ANTECEDENT], $sample); |
| 109 | 109 | })); |
| 110 | 110 | |
| 111 | - return array_map(static function ($rule) { |
|
| 111 | + return array_map(static 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, static function ($antecedent) use ($cardinality): bool { |
|
| 180 | + return array_filter($antecedents, static function($antecedent) use ($cardinality): bool { |
|
| 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(static function ($entry): array { |
|
| 202 | + return array_map(static function($entry): array { |
|
| 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_values(array_filter($samples, function ($entry): bool { |
|
| 216 | + return array_values(array_filter($samples, function($entry): bool { |
|
| 217 | 217 | return $this->support($entry) >= $this->support; |
| 218 | 218 | })); |
| 219 | 219 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | private function frequency(array $sample): int |
| 290 | 290 | { |
| 291 | - return count(array_filter($this->samples, function ($entry) use ($sample): bool { |
|
| 291 | + return count(array_filter($this->samples, function($entry) use ($sample): bool { |
|
| 292 | 292 | return $this->subset($entry, $sample); |
| 293 | 293 | })); |
| 294 | 294 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | private function contains(array $system, array $set): bool |
| 305 | 305 | { |
| 306 | - return (bool) array_filter($system, function ($entry) use ($set): bool { |
|
| 306 | + return (bool) array_filter($system, function($entry) use ($set): bool { |
|
| 307 | 307 | return $this->equals($entry, $set); |
| 308 | 308 | }); |
| 309 | 309 | } |
@@ -58,7 +58,7 @@ |
||
| 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): array { |
|
| 61 | + $callback = function($weights, $sample, $target): array { |
|
| 62 | 62 | $this->weights = $weights; |
| 63 | 63 | |
| 64 | 64 | $output = $this->output($sample); |
@@ -154,7 +154,7 @@ |
||
| 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): array { |
|
| 157 | + $callback = function($weights, $sample, $target): array { |
|
| 158 | 158 | $this->weights = $weights; |
| 159 | 159 | |
| 160 | 160 | $prediction = $this->outputClass($sample); |
@@ -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): array { |
|
| 191 | + return function($weights, $sample, $y) use ($penalty): array { |
|
| 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): array { |
|
| 223 | + return function($weights, $sample, $y) use ($penalty): array { |
|
| 224 | 224 | $this->weights = $weights; |
| 225 | 225 | $hX = $this->output($sample); |
| 226 | 226 | |
@@ -121,7 +121,7 @@ |
||
| 121 | 121 | |
| 122 | 122 | protected function splitImpurity(array $groups): float |
| 123 | 123 | { |
| 124 | - $samplesCount = (int) array_sum(array_map(static function (array $group): int { |
|
| 124 | + $samplesCount = (int) array_sum(array_map(static function(array $group): int { |
|
| 125 | 125 | return count($group[0]); |
| 126 | 126 | }, $groups)); |
| 127 | 127 | |