MTX_PCA - Principal Component Analysis - simplified version
This procedure performs a Principal Component Analysis (PCA) using data stored in a matrix.
Usage
The MTX_PCA stored procedure has the following syntax:
- MTX_PCA(modelName,dataMatrixName)
- Parameters
- modelName
- The name of the created model.
- dataMatrixName
- The name of the matrix containing the data.
Details
This procedure directly calls the BOOLEAN = nzm..mtx_PCA(NVARCHAR(ANY) modelName, NVARCHAR(ANY) dataMatrixName, BOOLEAN forceSufficientStats, BOOLEAN centerData, BOOLEAN scaleData, BOOLEAN saveScores) PCA variant with input parameters set to: forceSufficientStats = FALSE, centerData = TRUE, scaleData = TRUE, saveScores = FALSE.
Examples
call nzm..shape('1,10',1,3,'PCA_TEST');
call nzm..shape('10,20',10,1,'PCA_TEST_SOURCE_PRE');
---expected value is 0.0
callnzm..SCALAR_OPERATION('PCA_TEST_SOURCE_PRE',
'PCA_TEST_SOU RCE', '-', 0.5);
call nzm..gemm('PCA_TEST_SOURCE','PCA_TEST','PCA_TEST_VALS');
call nzm..mtx_pca('PCA_TEST_MOD','PCA_TEST_VALS');
std dev in each direction (in this example real value of all
components other than the first one should be 0)
call nzm..print('PCA_TEST_MOD_PCA_SDEV');
---projecting on the original value (first column)
call nzm..gemm_large('PCA_TEST_VALS',FALSE,'PCA_TEST_MOD_PCA',
FALSE, 'PCA_TEST_PROJ');
resulting value (first column of PCA_TEST_PROJ) is
proportional to original one (PCA_TEST_VALS): PCA_TEST_PROJ[
1,] ~~PCA_TEST_SOURCE * sqrt(nzm..red_ssq('PCA_TEST'))
call nzm..delete_all_matrices();
SHAPE
-------
t
(1 row)
SHAPE
-------
t
(1 row)
SCALAR_OPERATION
------------------
t
(1 row)
GEMM
------
t
(1 row)
MTX_PCA
---------
t
(1 row)
PRINT
----------------------------------------------------------------
-- matrix: PCA_TEST_MOD_PCA_SDEV --
1.7320508075689
3.6259732146947e-160
(1 row)
GEMM_LARGE
------------
t
(1 row)
DELETE_ALL_MATRICES
---------------------
t
(1 row)