public PCA setProjection ( int p ) { if ( p < 1 || p > n ) { throw new IllegalArgumentException ( "Invalid dimension of feature space: " + p ) ; } this . p = p ; projection = Matrix . zeros ( p , n ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < p ; j ++ ) { projection . set ( j , i , eigvectors . get ( i , j ) ) ; } } pmu = new double [ p ] ; projection . ax ( mu , pmu ) ; return this ; }
Set the projection matrix with given number of principal components .