Beispiel #1
0
 public DimReduction(double[][] trainingMatrix)
 {
     //Create the Principal Component Analysis
     _pca = new ModifedPca(trainingMatrix);
     _pca.Compute();
     PrintEngine.printList(_pca.Eigenvalues.ToList(), Form1.MainFolderName + "eigvalues.txt");
 }
Beispiel #2
0
        /// <summary>
        ///   Constructs a new Principal Component Analysis from a Covariance matrix.
        /// </summary>
        ///
        /// <remarks>
        ///   This method may be more suitable to high dimensional problems in which
        ///   the original data matrix may not fit in memory but the covariance matrix
        ///   will.</remarks>
        ///
        /// <param name="mean">The mean vector for the source data.</param>
        /// <param name="covariance">The covariance matrix of the data.</param>
        ///
        public static ModifedPca FromCovarianceMatrix(double[] mean, double[,] covariance)
        {
            if (mean == null)
            {
                throw new ArgumentNullException("mean");
            }
            if (covariance == null)
            {
                throw new ArgumentNullException("covariance");
            }

            if (covariance.GetLength(0) != covariance.GetLength(1))
            {
                throw new NonSymmetricMatrixException("Covariance matrix must be symmetric");
            }

            ModifedPca pca = new ModifedPca();

            pca.columnMeans      = mean;
            pca.covarianceMatrix = covariance;
            pca.analysisMethod   = AnalysisMethod.Center;
            pca.onlyCovarianceMatrixAvailable = true;
            pca.sourceDimensions = covariance.GetLength(0);

            return(pca);
        }
Beispiel #3
0
        /// <summary>
        ///   Constructs a new Principal Component Analysis from a Correlation matrix.
        /// </summary>
        ///
        /// <remarks>
        ///   This method may be more suitable to high dimensional problems in which
        ///   the original data matrix may not fit in memory but the covariance matrix
        ///   will.</remarks>
        ///
        /// <param name="mean">The mean vector for the source data.</param>
        /// <param name="stdDev">The standard deviation vectors for the source data.</param>
        /// <param name="correlation">The correlation matrix of the data.</param>
        ///
        public static ModifedPca FromCorrelationMatrix(double[] mean, double[] stdDev, double[,] correlation)
        {
            if (mean == null)
            {
                throw new ArgumentNullException("mean");
            }
            if (stdDev == null)
            {
                throw new ArgumentNullException("stdDev");
            }
            if (correlation == null)
            {
                throw new ArgumentNullException("correlation");
            }

            if (correlation.GetLength(0) != correlation.GetLength(1))
            {
                throw new NonSymmetricMatrixException("Correlation matrix must be symmetric");
            }

            ModifedPca pca = new ModifedPca();

            pca.columnMeans      = mean;
            pca.columnStdDev     = stdDev;
            pca.covarianceMatrix = correlation;
            pca.analysisMethod   = AnalysisMethod.Standardize;
            pca.onlyCovarianceMatrixAvailable = true;
            pca.sourceDimensions = correlation.GetLength(0);

            return(pca);
        }
Beispiel #4
0
 /// <summary>
 ///   Creates a principal component representation.
 /// </summary>
 ///
 /// <param name="analysis">The analysis to which this component belongs.</param>
 /// <param name="index">The component index.</param>
 ///
 internal PrincipalComponent(ModifedPca analysis, int index)
 {
     this.index       = index;
     this._modifedPca = analysis;
 }
 public static void originalFeatureRole(ModifedPca nodePca)
 {
     //TO DO: baced on http://venom.cs.utsa.edu/dmz/techrep/2007/CS-TR-2007-011.pdf
 }