Search in sources :

Example 1 with EigenPair

use of de.lmu.ifi.dbs.elki.math.linearalgebra.pca.EigenPair in project elki by elki-project.

the class GlobalPrincipalComponentAnalysisTransform method prepareComplete.

@Override
protected void prepareComplete() {
    mean = covmat.getMeanVector();
    PCAResult pcares = (new PCARunner(null)).processCovarMatrix(covmat.destroyToPopulationMatrix());
    SortedEigenPairs eps = pcares.getEigenPairs();
    covmat = null;
    if (filter == null) {
        proj = new double[dim][dim];
        for (int d = 0; d < dim; d++) {
            EigenPair ep = eps.getEigenPair(d);
            double[] ev = ep.getEigenvector();
            double mult = 1. / FastMath.sqrt(ep.getEigenvalue());
            // Fill weighted and transposed:
            for (int i = 0; i < dim; i++) {
                proj[d][i] = ev[i] * mult;
            }
        }
    } else {
        final int pdim = filter.filter(eps.eigenValues());
        if (LOG.isVerbose()) {
            LOG.verbose("Reducing dimensionality from " + dim + " to " + pdim + " via PCA.");
        }
        proj = new double[pdim][dim];
        for (int d = 0; d < pdim; d++) {
            EigenPair ep = eps.getEigenPair(d);
            double[] ev = ep.getEigenvector();
            double mult = 1. / FastMath.sqrt(ep.getEigenvalue());
            // Fill weighted and transposed:
            for (int i = 0; i < dim; i++) {
                proj[d][i] = ev[i] * mult;
            }
        }
    }
    buf = new double[dim];
}
Also used : PCAResult(de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PCAResult) PCARunner(de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PCARunner) SortedEigenPairs(de.lmu.ifi.dbs.elki.math.linearalgebra.pca.SortedEigenPairs) EigenPair(de.lmu.ifi.dbs.elki.math.linearalgebra.pca.EigenPair)

Aggregations

EigenPair (de.lmu.ifi.dbs.elki.math.linearalgebra.pca.EigenPair)1 PCAResult (de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PCAResult)1 PCARunner (de.lmu.ifi.dbs.elki.math.linearalgebra.pca.PCARunner)1 SortedEigenPairs (de.lmu.ifi.dbs.elki.math.linearalgebra.pca.SortedEigenPairs)1