All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hex.pca.jama.PCAJama Maven / Gradle / Ivy

There is a newer version: 3.46.0.6
Show newest version
package hex.pca.jama;

import Jama.Matrix;
import Jama.SingularValueDecomposition;
import hex.pca.PCAInterface;

public class PCAJama implements PCAInterface {
  private Matrix gramMatrix;
  private SingularValueDecomposition svd;
  private double[][] rightEigenvectors;

  public PCAJama(double[][] gramMatrix) {
    this.gramMatrix = new Matrix(gramMatrix);
    runSVD();
  }

  @Override
  public double[] getVariances() {
    return svd.getSingularValues();
  }

  @Override
  public double[][] getPrincipalComponents() {
    return rightEigenvectors;
  }

  private void runSVD() {
    svd = gramMatrix.svd();
    rightEigenvectors = svd.getV().getArray();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy