@@ -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\Classification; |
6 | 6 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | { |
115 | 115 | $types = []; |
116 | 116 | $featureCount = count($samples[0]); |
117 | - for ($i=0; $i < $featureCount; $i++) { |
|
117 | + for ($i = 0; $i < $featureCount; $i++) { |
|
118 | 118 | $values = array_column($samples, $i); |
119 | 119 | $isCategorical = self::isCategoricalColumn($values); |
120 | 120 | $types[] = $isCategorical ? self::NOMINAL : self::CONTINUOUS; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | // otherwise group the records so that we can classify the leaf |
141 | 141 | // in case maximum depth is reached |
142 | 142 | $leftRecords = []; |
143 | - $rightRecords= []; |
|
143 | + $rightRecords = []; |
|
144 | 144 | $remainingTargets = []; |
145 | 145 | $prevRecord = null; |
146 | 146 | $allSame = true; |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | if ($split->evaluate($record)) { |
159 | 159 | $leftRecords[] = $recordNo; |
160 | 160 | } else { |
161 | - $rightRecords[]= $recordNo; |
|
161 | + $rightRecords[] = $recordNo; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Group remaining targets |
165 | 165 | $target = $this->targets[$recordNo]; |
166 | - if (! array_key_exists($target, $remainingTargets)) { |
|
166 | + if (!array_key_exists($target, $remainingTargets)) { |
|
167 | 167 | $remainingTargets[$target] = 1; |
168 | 168 | } else { |
169 | 169 | $remainingTargets[$target]++; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $split->leftLeaf = $this->getSplitLeaf($leftRecords, $depth + 1); |
180 | 180 | } |
181 | 181 | if ($rightRecords) { |
182 | - $split->rightLeaf= $this->getSplitLeaf($rightRecords, $depth + 1); |
|
182 | + $split->rightLeaf = $this->getSplitLeaf($rightRecords, $depth + 1); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | protected function getSelectedFeatures() : array |
252 | 252 | { |
253 | 253 | $allFeatures = range(0, $this->featureCount - 1); |
254 | - if ($this->numUsableFeatures === 0 && ! $this->selectedFeatures) { |
|
254 | + if ($this->numUsableFeatures === 0 && !$this->selectedFeatures) { |
|
255 | 255 | return $allFeatures; |
256 | 256 | } |
257 | 257 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $countMatrix[$label][$rowIndex]++; |
289 | 289 | } |
290 | 290 | $giniParts = [0, 0]; |
291 | - for ($i=0; $i<=1; $i++) { |
|
291 | + for ($i = 0; $i <= 1; $i++) { |
|
292 | 292 | $part = 0; |
293 | 293 | $sum = array_sum(array_column($countMatrix, $i)); |
294 | 294 | if ($sum > 0) { |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | // Detect and convert continuous data column values into |
312 | 312 | // discrete values by using the median as a threshold value |
313 | 313 | $columns = []; |
314 | - for ($i=0; $i<$this->featureCount; $i++) { |
|
314 | + for ($i = 0; $i < $this->featureCount; $i++) { |
|
315 | 315 | $values = array_column($samples, $i); |
316 | 316 | if ($this->columnTypes[$i] == self::CONTINUOUS) { |
317 | 317 | $median = Mean::median($values); |