Completed
Push — master ( 8f122f...858d13 )
by Arkadiusz
04:26
created
src/Phpml/Classification/DecisionTree.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
     /**
133 133
      * @param array $records
134
-     * @return DecisionTreeLeaf[]
134
+     * @return null|DecisionTreeLeaf
135 135
      */
136 136
     protected function getBestSplit($records)
137 137
     {
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 
255 255
     /**
256 256
      * @param array $sample
257
-     * @return mixed
257
+     * @return string
258 258
      */
259 259
     protected function predictSample(array $sample)
260 260
     {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 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;
6 6
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     protected function getColumnTypes(array $samples)
76 76
     {
77 77
         $types = [];
78
-        for ($i=0; $i<$this->featureCount; $i++) {
78
+        for ($i = 0; $i < $this->featureCount; $i++) {
79 79
             $values = array_column($samples, $i);
80 80
             $isCategorical = $this->isCategoricalColumn($values);
81 81
             $types[] = $isCategorical ? self::NOMINAL : self::CONTINUOS;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             $this->actualDepth = $depth;
96 96
         }
97 97
         $leftRecords = [];
98
-        $rightRecords= [];
98
+        $rightRecords = [];
99 99
         $remainingTargets = [];
100 100
         $prevRecord = null;
101 101
         $allSame = true;
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
             if ($split->evaluate($record)) {
109 109
                 $leftRecords[] = $recordNo;
110 110
             } else {
111
-                $rightRecords[]= $recordNo;
111
+                $rightRecords[] = $recordNo;
112 112
             }
113 113
             $target = $this->targets[$recordNo];
114
-            if (! in_array($target, $remainingTargets)) {
114
+            if (!in_array($target, $remainingTargets)) {
115 115
                 $remainingTargets[] = $target;
116 116
             }
117 117
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                 $split->leftLeaf = $this->getSplitLeaf($leftRecords, $depth + 1);
127 127
             }
128 128
             if ($rightRecords) {
129
-                $split->rightLeaf= $this->getSplitLeaf($rightRecords, $depth + 1);
129
+                $split->rightLeaf = $this->getSplitLeaf($rightRecords, $depth + 1);
130 130
             }
131 131
         }
132 132
         return $split;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         $samples = array_combine($records, $this->preprocess($samples));
144 144
         $bestGiniVal = 1;
145 145
         $bestSplit = null;
146
-        for ($i=0; $i<$this->featureCount; $i++) {
146
+        for ($i = 0; $i < $this->featureCount; $i++) {
147 147
             $colValues = [];
148 148
             $baseValue = null;
149 149
             foreach ($samples as $index => $row) {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             $countMatrix[$label][$rowIndex]++;
184 184
         }
185 185
         $giniParts = [0, 0];
186
-        for ($i=0; $i<=1; $i++) {
186
+        for ($i = 0; $i <= 1; $i++) {
187 187
             $part = 0;
188 188
             $sum = array_sum(array_column($countMatrix, $i));
189 189
             if ($sum > 0) {
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         // Detect and convert continuous data column values into
206 206
         // discrete values by using the median as a threshold value
207 207
         $columns = [];
208
-        for ($i=0; $i<$this->featureCount; $i++) {
208
+        for ($i = 0; $i < $this->featureCount; $i++) {
209 209
             $values = array_column($samples, $i);
210 210
             if ($this->columnTypes[$i] == self::CONTINUOS) {
211 211
                 $median = Mean::median($values);
Please login to merge, or discard this patch.
src/Phpml/Classification/DecisionTree/DecisionTreeLeaf.php 1 patch
Spacing   +11 added lines, -11 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\DecisionTree;
5 5
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * @var DecisionTreeLeaf
26 26
      */
27
-    public $rightLeaf= null;
27
+    public $rightLeaf = null;
28 28
 
29 29
     /**
30 30
      * @var array
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $recordField = $record[$this->columnIndex];
64 64
         if (preg_match("/^([<>=]{1,2})\s*(.*)/", $this->value, $matches)) {
65 65
             $op = $matches[1];
66
-            $value= floatval($matches[2]);
66
+            $value = floatval($matches[2]);
67 67
             $recordField = strval($recordField);
68 68
             eval("\$result = $recordField $op $value;");
69 69
             return $result;
@@ -78,25 +78,25 @@  discard block
 block discarded – undo
78 78
         } else {
79 79
             $value = $this->value;
80 80
             $col = "col_$this->columnIndex";
81
-            if (! preg_match("/^[<>=]{1,2}/", $value)) {
81
+            if (!preg_match("/^[<>=]{1,2}/", $value)) {
82 82
                 $value = "=$value";
83 83
             }
84
-            $value = "<b>$col $value</b><br>Gini: ". number_format($this->giniIndex, 2);
84
+            $value = "<b>$col $value</b><br>Gini: ".number_format($this->giniIndex, 2);
85 85
         }
86 86
         $str = "<table ><tr><td colspan=3 align=center style='border:1px solid;'>
87 87
 				$value</td></tr>";
88 88
         if ($this->leftLeaf || $this->rightLeaf) {
89
-            $str .='<tr>';
89
+            $str .= '<tr>';
90 90
             if ($this->leftLeaf) {
91
-                $str .="<td valign=top><b>| Yes</b><br>$this->leftLeaf</td>";
91
+                $str .= "<td valign=top><b>| Yes</b><br>$this->leftLeaf</td>";
92 92
             } else {
93
-                $str .='<td></td>';
93
+                $str .= '<td></td>';
94 94
             }
95
-            $str .='<td>&nbsp;</td>';
95
+            $str .= '<td>&nbsp;</td>';
96 96
             if ($this->rightLeaf) {
97
-                $str .="<td valign=top align=right><b>No |</b><br>$this->rightLeaf</td>";
97
+                $str .= "<td valign=top align=right><b>No |</b><br>$this->rightLeaf</td>";
98 98
             } else {
99
-                $str .='<td></td>';
99
+                $str .= '<td></td>';
100 100
             }
101 101
             $str .= '</tr>';
102 102
         }
Please login to merge, or discard this patch.
src/Phpml/Transformer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Phpml;
6 6
 
Please login to merge, or discard this patch.
src/Phpml/CrossValidation/RandomSplit.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Phpml\CrossValidation;
6 6
 
Please login to merge, or discard this patch.
src/Phpml/CrossValidation/StratifiedRandomSplit.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Phpml\CrossValidation;
6 6
 
Please login to merge, or discard this patch.
src/Phpml/SupportVectorMachine/Kernel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Phpml\SupportVectorMachine;
6 6
 
Please login to merge, or discard this patch.
src/Phpml/SupportVectorMachine/Type.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Phpml\SupportVectorMachine;
6 6
 
Please login to merge, or discard this patch.
src/Phpml/SupportVectorMachine/DataTransformer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Phpml\SupportVectorMachine;
6 6
 
Please login to merge, or discard this patch.
src/Phpml/Tokenization/Tokenizer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Phpml\Tokenization;
6 6
 
Please login to merge, or discard this patch.