Exemple #1
0
        private void ReduceDim(reduceDimantion rdForm)
        {
            //IF WE REDUCED DIMANTION
            if (rdForm.method_calced == true)
            {
                //SET VALUES FROM FORM
                eigenvalues             = rdForm.eigenvalues;
                traininglData_lower_dim = rdForm.finalData;
                method     = rdForm.method;
                dimSize    = rdForm.dimSize;
                Components = rdForm.Components;

                //set training data with lower dimantion
                SetDataLowerDim(training_data_low_dim_dt, traininglData_lower_dim, dimSize);
            }
        }
Exemple #2
0
        //DO PCA
        private void PCA_DATA()
        {
            //GET DATA MATRIX IN THE FORMATE ACCORD CAN USE (DOUBLE [,])
            double[,] training_matrix = new double[dt.Rows.Count, dt.Columns.Count];;
            SetMatrixFromDataTable(training_matrix, dt);

            //Create the Principal Component Analysis
            var pca = new PrincipalComponentAnalysis(training_matrix);

            //PCA COMPUTE
            pca.Compute();

            //SET DATA
            finalData   = pca.Transform(training_matrix);
            eigenvalues = pca.Eigenvalues;
            Components  = pca.Components;
        }
Exemple #3
0
        /// <summary>
        ///   Creates additional information about principal components.
        /// </summary>
        ///
        protected void CreateComponents()
        {
            int numComponents = singularValues.Length;

            componentProportions = new double[numComponents];
            componentCumulative  = new double[numComponents];

            // Calculate proportions
            double sum = 0.0;

            for (int i = 0; i < numComponents; i++)
            {
                sum += System.Math.Abs(eigenvalues[i]);
            }
            sum = (sum == 0) ? 0.0 : (1.0 / sum);

            for (int i = 0; i < numComponents; i++)
            {
                componentProportions[i] = System.Math.Abs(eigenvalues[i]) * sum;
            }

            // Calculate cumulative proportions
            this.componentCumulative[0] = this.componentProportions[0];
            for (int i = 1; i < this.componentCumulative.Length; i++)
            {
                this.componentCumulative[i] = this.componentCumulative[i - 1] + this.componentProportions[i];
            }

            // Creates the object-oriented structure to hold the principal components
            PrincipalComponent[] components = new PrincipalComponent[singularValues.Length];
            for (int i = 0; i < components.Length; i++)
            {
                components[i] = new PrincipalComponent(this, i);
            }
            this.componentCollection = new PrincipalComponentCollection(components);
        }