@@ -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\Clustering; |
6 | 6 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $total += $val; |
102 | 102 | } |
103 | 103 | |
104 | - $this->membership[] = array_map(function ($val) use ($total) { |
|
104 | + $this->membership[] = array_map(function($val) use ($total) { |
|
105 | 105 | return $val / $total; |
106 | 106 | }, $row); |
107 | 107 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | { |
219 | 219 | // Initialize variables, clusters and membership matrix |
220 | 220 | $this->sampleCount = count($samples); |
221 | - $this->samples =& $samples; |
|
221 | + $this->samples = & $samples; |
|
222 | 222 | $this->space = new Space(count($samples[0])); |
223 | 223 | $this->initClusters(); |
224 | 224 |
@@ -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\Helper\Optimizer; |
6 | 6 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @var array |
74 | 74 | */ |
75 | - protected $costValues= []; |
|
75 | + protected $costValues = []; |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Initializes the SGD optimizer for the given number of dimensions |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | { |
241 | 241 | // Check for early stop: No change larger than threshold (default 1e-5) |
242 | 242 | $diff = array_map( |
243 | - function ($w1, $w2) { |
|
243 | + function($w1, $w2) { |
|
244 | 244 | return abs($w1 - $w2) > $this->threshold ? 1 : 0; |
245 | 245 | }, |
246 | 246 | $oldTheta, $this->theta); |
@@ -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\Helper\Optimizer; |
6 | 6 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $this->updateWeightsWithUpdates($updates, $totalPenalty); |
44 | 44 | |
45 | - $this->costValues[] = array_sum($errors)/$this->sampleCount; |
|
45 | + $this->costValues[] = array_sum($errors) / $this->sampleCount; |
|
46 | 46 | |
47 | 47 | if ($this->earlyStop($theta)) { |
48 | 48 | break; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | protected function gradient(array $theta) |
66 | 66 | { |
67 | 67 | $costs = []; |
68 | - $gradient= []; |
|
68 | + $gradient = []; |
|
69 | 69 | $totalPenalty = 0; |
70 | 70 | |
71 | 71 | foreach ($this->samples as $index => $sample) { |
@@ -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\Optimizer; |
6 | 6 |
@@ -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\Optimizer; |
6 | 6 |