Completed
Pull Request — master (#36)
by
unknown
05:04
created
src/Phpml/Classification/Ensemble/RandomForest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Phpml\Classification\Ensemble;
5 5
 
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
         list($subset, $targets) = parent::getRandomSubset($index);
37 37
 
38 38
         $features = [];
39
-        $featureCount = (int)ceil($this->featureSubsetRatio * $this->featureCount);
39
+        $featureCount = (int) ceil($this->featureSubsetRatio * $this->featureCount);
40 40
         while (count($features) < $featureCount) {
41 41
             $rand = rand(0, $this->featureCount - 1);
42
-            if (! in_array($rand, $features)) {
42
+            if (!in_array($rand, $features)) {
43 43
                 $features[] = $rand;
44 44
             }
45 45
         }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         foreach ($features as $colIndex) {
51 51
             $columns[] = array_column($subset, $colIndex);
52 52
         }
53
-        $subset= array_map(null, ...$columns);
53
+        $subset = array_map(null, ...$columns);
54 54
 
55 55
         return [$subset, $targets];
56 56
     }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     protected function predictSample(array $sample)
63 63
     {
64 64
         $predictions = [];
65
-        for ($i=0; $i<count($this->classifiers); $i++) {
65
+        for ($i = 0; $i < count($this->classifiers); $i++) {
66 66
             $samplePiece = [];
67 67
             foreach ($this->classifierColumns[$i] as $colIndex) {
68 68
                 $samplePiece[] = $sample[$colIndex];
Please login to merge, or discard this patch.
src/Phpml/Classification/Ensemble/Bagging.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Phpml\Classification\Ensemble;
6 6
 
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
      */
119 119
     protected function getRandomSubset($index)
120 120
     {
121
-        $subsetLength = (int)ceil(sqrt($this->numSamples));
121
+        $subsetLength = (int) ceil(sqrt($this->numSamples));
122 122
         $denom = $this->subsetRatio / 2;
123 123
         $subsetLength = $this->numSamples / (1 / $denom);
124 124
         $index = $index * $subsetLength % $this->numSamples;
125 125
         $samples = [];
126 126
         $targets = [];
127
-        for ($i=0; $i<$subsetLength * 2; $i++) {
127
+        for ($i = 0; $i < $subsetLength * 2; $i++) {
128 128
             $rand = rand($index, $this->numSamples - 1);
129 129
             $samples[] = $this->samples[$rand];
130 130
             $targets[] = $this->targets[$rand];
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     protected function initClassifiers()
139 139
     {
140 140
         $classifiers = [];
141
-        for ($i=0; $i<$this->numClassifier; $i++) {
141
+        for ($i = 0; $i < $this->numClassifier; $i++) {
142 142
             $ref = new \ReflectionClass($this->classifier);
143 143
             if ($this->classifierOptions) {
144 144
                 $obj = $ref->newInstanceArgs($this->classifierOptions);
Please login to merge, or discard this patch.