@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -<<<<<<< HEAD |
|
| 2 | +<< << <<< HEAD |
|
| 3 | 3 | ======= |
| 4 | 4 | |
| 5 | 5 | >>>>>>> refs/remotes/php-ai/master |
@@ -241,6 +241,4 @@ discard block |
||
| 241 | 241 | foreach ($this->clusters as $cluster) { |
| 242 | 242 | $grouped[] = $cluster->getPoints(); |
| 243 | 243 | } |
| 244 | - return $grouped; |
|
| 245 | - } |
|
| 246 | -} |
|
| 244 | + return $grouped |
|
| 247 | 245 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -<<<<<<< HEAD |
|
| 2 | +<< << <<< HEAD |
|
| 3 | 3 | ======= |
| 4 | 4 | |
| 5 | 5 | >>>>>>> refs/remotes/php-ai/master |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | public function evaluate($record) |
| 66 | 66 | { |
| 67 | - $recordField = $record[$this->columnIndex]; |
|
| 67 | + $recordField = $record[$this - >columnIndex]; |
|
| 68 | 68 | if (preg_match("/^([<>=]{1,2})\s*(.*)/", $this->value, $matches)) { |
| 69 | 69 | $op = $matches[1]; |
| 70 | 70 | $value= floatval($matches[2]); |
@@ -105,6 +105,4 @@ discard block |
||
| 105 | 105 | $str .= '</tr>'; |
| 106 | 106 | } |
| 107 | 107 | $str .= '</table>'; |
| 108 | - return $str; |
|
| 109 | - } |
|
| 110 | -} |
|
| 108 | + return $str |
|
| 111 | 109 | \ No newline at end of file |
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * @var array |
| 21 | 21 | */ |
| 22 | -<<<<<<< HEAD |
|
| 22 | +<< << <<< HEAD |
|
| 23 | 23 | private $samples = array(); |
| 24 | 24 | ======= |
| 25 | 25 | private $samples = []; |
@@ -306,7 +306,4 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | return $this->labels[0]; |
| 308 | 308 | ======= |
| 309 | - return $node->classValue; |
|
| 310 | ->>>>>>> refs/remotes/php-ai/master |
|
| 311 | - } |
|
| 312 | -} |
|
| 309 | + return $node->classValue |
|
| 313 | 310 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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]; |
@@ -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\Ensemble; |
| 6 | 6 | |
@@ -118,13 +118,13 @@ discard block |
||
| 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 |
||
| 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); |
@@ -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 | |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | use Trainable, Predictable; |
| 15 | 15 | |
| 16 | - const CONTINUOS = 1; |
|
| 17 | - const NOMINAL = 2; |
|
| 16 | + const CONTINUOS = 1; |
|
| 17 | + const NOMINAL = 2; |
|
| 18 | 18 | const EPSILON = 1e-10; |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @var array |
| 27 | 27 | */ |
| 28 | - private $mean= []; |
|
| 28 | + private $mean = []; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @var array |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $this->sampleCount = count($this->samples); |
| 69 | 69 | $this->featureCount = count($this->samples[0]); |
| 70 | 70 | |
| 71 | -<<<<<<< HEAD |
|
| 71 | +<< << <<< HEAD |
|
| 72 | 72 | $labelCounts = array_count_values($targets); |
| 73 | 73 | ======= |
| 74 | 74 | $labelCounts = array_count_values($this->targets); |
@@ -187,6 +187,4 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | arsort($predictions, SORT_NUMERIC); |
| 189 | 189 | reset($predictions); |
| 190 | - return key($predictions); |
|
| 191 | - } |
|
| 192 | -} |
|
| 190 | + return key($predictions |
|
| 193 | 191 | \ No newline at end of file |