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;
}