private void btnProject_Click(object sender, EventArgs e)
{
if (lda == null)
{
MessageBox.Show("Please run the analysis first!");
return;
}
// Save any pending changes
dgvProjectionSource.EndEdit();
// Creates a matrix from the source data table
double[][] sourceMatrix = (dgvProjectionSource.DataSource as DataTable).ToArray(out columnNames);
// Gets only the X and Y
double[][] data = sourceMatrix.GetColumns(0, 1);
// Perform the transformation of the data using two components
double[][] result = lda.Transform(data);
// Create a new plot with the original Z column
double[][] graph = result.InsertColumn(sourceMatrix.GetColumn(2));
// Create output scatter plot
outputScatterplot.DataSource = graph;
// Create output table
dgvProjectionResult.DataSource = new ArrayDataView(graph, columnNames);
}