Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

(no description)

File Size: 131 lines (4 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

PCA:: (5 methods):
  __construct()
  fit()
  transform()
  calculateMeans()
  normalize()


Class: PCA  - X-Ref

__construct(?float $totalVariance = null, ?int $numFeatures = null)   X-Ref
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.<br>

param: float $totalVariance Total explained variance to be preserved
param: int   $numFeatures   Number of features to be preserved

fit(array $data)   X-Ref
Takes a data and returns a lower dimensional version
of this data while preserving $totalVariance or $numFeatures. <br>
$data is an n-by-m matrix and returned array is
n-by-k matrix where k <= m


transform(array $sample)   X-Ref
Transforms the given sample to a lower dimensional vector by using
the eigenVectors obtained in the last run of <code>fit</code>.


calculateMeans(array $data, int $n)   X-Ref
No description

normalize(array $data, int $n)   X-Ref
Normalization of the data includes subtracting mean from
each dimension therefore dimensions will be centered to zero