@@ -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\DimensionReduction; |
| 6 | 6 | |
@@ -161,20 +161,20 @@ discard block |
||
| 161 | 161 | switch ($this->kernel) { |
| 162 | 162 | case self::KERNEL_LINEAR: |
| 163 | 163 | // k(x,y) = xT.y |
| 164 | - return function ($x, $y) { |
|
| 164 | + return function($x, $y) { |
|
| 165 | 165 | return Matrix::dot($x, $y)[0]; |
| 166 | 166 | }; |
| 167 | 167 | case self::KERNEL_RBF: |
| 168 | 168 | // k(x,y)=exp(-γ.|x-y|) where |..| is Euclidean distance |
| 169 | 169 | $dist = new Euclidean(); |
| 170 | 170 | |
| 171 | - return function ($x, $y) use ($dist) { |
|
| 171 | + return function($x, $y) use ($dist) { |
|
| 172 | 172 | return exp(-$this->gamma * $dist->sqDistance($x, $y)); |
| 173 | 173 | }; |
| 174 | 174 | |
| 175 | 175 | case self::KERNEL_SIGMOID: |
| 176 | 176 | // k(x,y)=tanh(γ.xT.y+c0) where c0=1 |
| 177 | - return function ($x, $y) { |
|
| 177 | + return function($x, $y) { |
|
| 178 | 178 | $res = Matrix::dot($x, $y)[0] + 1.0; |
| 179 | 179 | |
| 180 | 180 | return tanh($this->gamma * $res); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | // k(x,y)=exp(-γ.|x-y|) where |..| is Manhattan distance |
| 185 | 185 | $dist = new Manhattan(); |
| 186 | 186 | |
| 187 | - return function ($x, $y) use ($dist) { |
|
| 187 | + return function($x, $y) use ($dist) { |
|
| 188 | 188 | return exp(-$this->gamma * $dist->distance($x, $y)); |
| 189 | 189 | }; |
| 190 | 190 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | protected function projectSample(array $pairs): array |
| 219 | 219 | { |
| 220 | 220 | // Normalize eigenvectors by eig = eigVectors / eigValues |
| 221 | - $func = function ($eigVal, $eigVect) { |
|
| 221 | + $func = function($eigVal, $eigVect) { |
|
| 222 | 222 | $m = new Matrix($eigVect, false); |
| 223 | 223 | $a = $m->divideByScalar($eigVal)->toArray(); |
| 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\CrossValidation; |
| 6 | 6 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | abstract protected function splitDataset(Dataset $dataset, float $testSize); |
| 64 | 64 | |
| 65 | - protected function seedGenerator(?int $seed = null): void |
|
| 65 | + protected function seedGenerator(?int $seed = null) : void |
|
| 66 | 66 | { |
| 67 | 67 | if ($seed === null) { |
| 68 | 68 | mt_srand(); |
@@ -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\FeatureExtraction; |
| 6 | 6 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | private $idf = []; |
| 15 | 15 | |
| 16 | - public function __construct(?array $samples = null) |
|
| 16 | + public function __construct(? array $samples = null) |
|
| 17 | 17 | { |
| 18 | 18 | if ($samples) { |
| 19 | 19 | $this->fit($samples); |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Phpml\Metric; |
| 6 | 6 | |
| 7 | 7 | class ConfusionMatrix |
| 8 | 8 | { |
| 9 | - public static function compute(array $actualLabels, array $predictedLabels, ?array $labels = null): array |
|
| 9 | + public static function compute(array $actualLabels, array $predictedLabels, ? array $labels = null) : array |
|
| 10 | 10 | { |
| 11 | 11 | $labels = $labels ? array_flip($labels) : self::getUniqueLabels($actualLabels); |
| 12 | 12 | $matrix = self::generateMatrixWithZeros($labels); |
@@ -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; |
| 6 | 6 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | public function transpose(): self |
| 127 | 127 | { |
| 128 | 128 | if ($this->rows == 1) { |
| 129 | - $matrix = array_map(function ($el) { |
|
| 129 | + $matrix = array_map(function($el) { |
|
| 130 | 130 | return [$el]; |
| 131 | 131 | }, $this->matrix[0]); |
| 132 | 132 | } else { |
@@ -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 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @throws InvalidArgumentException |
| 16 | 16 | */ |
| 17 | - public static function fromXYArrays(array $x, array $y, bool $sample = true, ?float $meanX = null, ?float $meanY = null): float |
|
| 17 | + public static function fromXYArrays(array $x, array $y, bool $sample = true, ?float $meanX = null, ?float $meanY = null) : float |
|
| 18 | 18 | { |
| 19 | 19 | if (empty($x) || empty($y)) { |
| 20 | 20 | throw InvalidArgumentException::arrayCantBeEmpty(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @throws InvalidArgumentException |
| 53 | 53 | * @throws \Exception |
| 54 | 54 | */ |
| 55 | - public static function fromDataset(array $data, int $i, int $k, bool $sample = true, ?float $meanX = null, ?float $meanY = null): float |
|
| 55 | + public static function fromDataset(array $data, int $i, int $k, bool $sample = true, ?float $meanX = null, ?float $meanY = null) : float |
|
| 56 | 56 | { |
| 57 | 57 | if (empty($data)) { |
| 58 | 58 | throw InvalidArgumentException::arrayCantBeEmpty(); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @param array|null $means |
| 117 | 117 | */ |
| 118 | - public static function covarianceMatrix(array $data, ?array $means = null): array |
|
| 118 | + public static function covarianceMatrix(array $data, ? array $means = null) : array |
|
| 119 | 119 | { |
| 120 | 120 | $n = count($data[0]); |
| 121 | 121 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * @package JAMA |
@@ -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 | /** |
| 6 | 6 | * Class to obtain eigenvalues and eigenvectors of a real matrix. |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | // Always return the eigenvectors of length 1.0 |
| 130 | 130 | $vectors = new Matrix($vectors); |
| 131 | - $vectors = array_map(function ($vect) { |
|
| 131 | + $vectors = array_map(function($vect) { |
|
| 132 | 132 | $sum = 0; |
| 133 | 133 | for ($i = 0; $i < count($vect); ++$i) { |
| 134 | 134 | $sum += $vect[$i] ** 2; |
@@ -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\NeuralNetwork; |
| 6 | 6 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * @return Neuron |
| 46 | 46 | */ |
| 47 | - private function createNode(string $nodeClass, ?ActivationFunction $activationFunction = null): Node |
|
| 47 | + private function createNode(string $nodeClass, ?ActivationFunction $activationFunction = null) : Node |
|
| 48 | 48 | { |
| 49 | 49 | if ($nodeClass === Neuron::class) { |
| 50 | 50 | return new Neuron($activationFunction); |