@@ -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\Math\Statistic; |
6 | 6 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | // Ref: https://en.wikipedia.org/wiki/Normal_distribution |
40 | 40 | $std2 = $this->std ** 2; |
41 | 41 | $mean = $this->mean; |
42 | - return exp(- (($value - $mean) ** 2) / (2 * $std2)) / sqrt(2 * $std2 * pi()); |
|
42 | + return exp(-(($value - $mean) ** 2) / (2 * $std2)) / sqrt(2 * $std2 * pi()); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -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\Linear; |
6 | 6 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | // Try other possible points one by one |
202 | - for ($step = $minValue; $step <= $maxValue; $step+= $stepSize) { |
|
203 | - $threshold = (float)$step; |
|
202 | + for ($step = $minValue; $step <= $maxValue; $step += $stepSize) { |
|
203 | + $threshold = (float) $step; |
|
204 | 204 | list($errorRate, $prob) = $this->calculateErrorRate($threshold, $operator, $values); |
205 | 205 | if ($errorRate < $split['trainingErrorRate']) { |
206 | 206 | $split = ['value' => $threshold, 'operator' => $operator, |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | { |
224 | 224 | $values = array_column($this->samples, $col); |
225 | 225 | $valueCounts = array_count_values($values); |
226 | - $distinctVals= array_keys($valueCounts); |
|
226 | + $distinctVals = array_keys($valueCounts); |
|
227 | 227 | |
228 | 228 | $split = null; |
229 | 229 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $wrong = 0.0; |
282 | 282 | $prob = []; |
283 | 283 | $leftLabel = $this->binaryLabels[0]; |
284 | - $rightLabel= $this->binaryLabels[1]; |
|
284 | + $rightLabel = $this->binaryLabels[1]; |
|
285 | 285 | |
286 | 286 | foreach ($values as $index => $value) { |
287 | 287 | if ($this->evaluate($value, $operator, $threshold)) { |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $wrong += $this->weights[$index]; |
296 | 296 | } |
297 | 297 | |
298 | - if (! isset($prob[$predicted][$target])) { |
|
298 | + if (!isset($prob[$predicted][$target])) { |
|
299 | 299 | $prob[$predicted][$target] = 0; |
300 | 300 | } |
301 | 301 | $prob[$predicted][$target]++; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | // Calculate probabilities: Proportion of labels in each leaf |
305 | 305 | $dist = array_combine($this->binaryLabels, array_fill(0, 2, 0.0)); |
306 | 306 | foreach ($prob as $leaf => $counts) { |
307 | - $leafTotal = (float)array_sum($prob[$leaf]); |
|
307 | + $leafTotal = (float) array_sum($prob[$leaf]); |
|
308 | 308 | foreach ($counts as $label => $count) { |
309 | 309 | if (strval($leaf) == strval($label)) { |
310 | 310 | $dist[$leaf] = $count / $leafTotal; |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function __toString() |
357 | 357 | { |
358 | - return "IF $this->column $this->operator $this->value " . |
|
359 | - "THEN " . $this->binaryLabels[0] . " ". |
|
360 | - "ELSE " . $this->binaryLabels[1]; |
|
358 | + return "IF $this->column $this->operator $this->value ". |
|
359 | + "THEN ".$this->binaryLabels[0]." ". |
|
360 | + "ELSE ".$this->binaryLabels[1]; |
|
361 | 361 | } |
362 | 362 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Phpml\Helper; |
6 | 6 |