Analysis.PCA.MainForm.btnProject_Click C# (CSharp) Method

btnProject_Click() private method

Launched when the user clicks the "Compute projection" button.
private btnProject_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void btnProject_Click(object sender, EventArgs e)
        {
            if (pca == null || dgvProjectionSource.DataSource == null)
            {
                MessageBox.Show("Please compute the analysis first.");
                return;
            }

            // Save any pending changes 
            dgvProjectionSource.EndEdit();

            string[] colNames;
            int components = (int)numComponents.Value;
            double[,] projectionSource = (dgvProjectionSource.DataSource as DataTable).ToMatrix(out colNames);

            // Compute the projection
            double[,] projection = pca.Transform(projectionSource, components);

            dgvProjectionResult.DataSource = new ArrayDataView(projection, GenerateComponentNames(components));
            dgvReversionSource.DataSource = dgvProjectionResult.DataSource;
        }