|
| __construct (?float $totalVariance=null, ?int $numFeatures=null) |
| PCA (Principal Component Analysis) used to explain given data with lower number of dimensions.
|
|
| fit (array $data) |
| Takes a data and returns a lower dimensional version of this data while preserving $totalVariance or $numFeatures.
|
|
| transform (array $sample) |
| Transforms the given sample to a lower dimensional vector by using the eigenVectors obtained in the last run of fit .
|
|
|
int | $numFeatures = null |
| Number of features to be preserved after the reduction.
|
|
float | $totalVariance = 0.9 |
| Total variance to be conserved after the reduction.
|
|
|
| calculateMeans (array $data, int $n) |
|
| eigenDecomposition (array $matrix) |
| Calculates eigenValues and eigenVectors of the given matrix.
|
|
| normalize (array $data, int $n) |
| Normalization of the data includes subtracting mean from each dimension therefore dimensions will be centered to zero.
|
|
| reduce (array $data) |
| Returns the reduced data.
|
|
|
array | $eigValues = [] |
| Top eigenValues of the matrix.
|
|
array | $eigVectors = [] |
| Top eigenvectors of the matrix.
|
|
bool | $fit = false |
|
array | $means = [] |
|
◆ __construct()
Phpml\DimensionReduction\PCA::__construct |
( |
?float | $totalVariance = null, |
|
|
?int | $numFeatures = null ) |
PCA (Principal Component Analysis) used to explain given data with lower number of dimensions.
This analysis transforms the data to a lower dimensional version of it by conserving a proportion of total variance within the data. It is a lossy data compression technique.
- Parameters
-
float | $totalVariance | Total explained variance to be preserved |
int | $numFeatures | Number of features to be preserved |
- Exceptions
-
◆ eigenDecomposition()
Phpml\DimensionReduction\EigenTransformerBase::eigenDecomposition |
( |
array | $matrix | ) |
|
|
protectedinherited |
Calculates eigenValues and eigenVectors of the given matrix.
Returns top eigenVectors along with the largest eigenValues. The total explained variance of these eigenVectors will be no less than desired $totalVariance value
◆ fit()
Phpml\DimensionReduction\PCA::fit |
( |
array | $data | ) |
|
Takes a data and returns a lower dimensional version of this data while preserving $totalVariance or $numFeatures.
$data is an n-by-m matrix and returned array is n-by-k matrix where k <= m
Reimplemented in Phpml\DimensionReduction\KernelPCA.
◆ transform()
Phpml\DimensionReduction\PCA::transform |
( |
array | $sample | ) |
|
Transforms the given sample to a lower dimensional vector by using the eigenVectors obtained in the last run of fit
.
- Exceptions
-
InvalidOperationException | |
Reimplemented in Phpml\DimensionReduction\KernelPCA.
The documentation for this class was generated from the following file:
- lib/mlbackend/php/phpml/src/Phpml/DimensionReduction/PCA.php