@Override public void select(PrincipalComponentAnalysis pca) { pca.selectSubset(n); } }
/** * Set the number of components of the PDM * * @param n * number of components */ public void setNumComponents(int n) { pc.selectSubset(n); numComponents = this.pc.getEigenValues().length; }
/** * Set the number of components of the PDM using a {@link ComponentSelector} * . * * @param selector * the {@link ComponentSelector} to apply. */ public void setNumComponents(ComponentSelector selector) { pc.selectSubset(selector); numComponents = this.pc.getEigenValues().length; }
/** * Select a subset of the principal components such that all remaining * components have a cumulative energy less than the given value. * * Calling this method throws away any extra basis vectors and eigenvalues. * * @param threshold * threshold on the cumulative energy. */ public void selectSubsetEnergyThreshold(double threshold) { final double[] energy = getCumulativeEnergies(); for (int i = 1; i < energy.length; i++) { if (energy[i] < threshold) { selectSubset(i - 1); return; } } }
/** * Select a subset of the principal components such that all remaining * components have a certain percentage cumulative energy of the total. The * percentage is calculated relative to the total energy of the eigenvalues. * Bear in mind that if not all the eigenvalues were calculated, or if some * have previously been removed through {@link #selectSubset(int)}, * {@link #selectSubsetEnergyThreshold(double)} or * {@link #selectSubsetPercentageEnergy(double)}, then the percentage * calculation only factors in the remaining eigenvalues that are available * to it. * * Calling this method throws away any extra basis vectors and eigenvalues. * * @param percentage * percentage of the total cumulative energy to retain [0..1]. */ public void selectSubsetPercentageEnergy(double percentage) { final double[] energy = getCumulativeEnergies(); final double total = energy[energy.length - 1]; for (int i = 1; i < energy.length; i++) { if (energy[i] / total > percentage) { selectSubset(i - 1); return; } } }