Principle component analysis (PCA) on a matrix
Code: "stat_pca_matrix.py". Programming language: Python DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/stat_pca_matrix_4347.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



from jhplot  import *
from jhplot.math.pca import *
from Jama import Matrix

train=Matrix([[1, 2, 3, 4, 5, 6],
                     [6, 5, 4, 3, 2, 1], 
                     [2, 2, 2, 2, 2, 2]]) 
pca=PCA(train)
test=Matrix( [[1, 2, 3, 4, 5, 6], 
                     [1, 2, 1, 2, 1, 2] ]) 
TYPE=PCA.TransformationType.WHITENING
tr=pca.transform(test, TYPE)
print "WHITENING=",tr
TYPE=PCA.TransformationType.ROTATION
tr=pca.transform(test, TYPE)
print "ROTATION=",tr

You see the box below because you did not login.