public void ApplyTest3()
{
// Suppose we have a data table relating the age of
// a person and its categorical classification, as
// in "child", "adult" or "elder".
// The Normalization filter is able to transform
// numerical data into Z-Scores, subtracting the
// mean for each variable and dividing by their
// standard deviation.
// Create the aforementioned sample table
DataTable table = new DataTable("Sample data");
table.Columns.Add("Age", typeof(double));
table.Columns.Add("Label", typeof(string));
// age label
table.Rows.Add(10, "child");
table.Rows.Add(07, "child");
table.Rows.Add(04, "child");
table.Rows.Add(21, "adult");
table.Rows.Add(27, "adult");
table.Rows.Add(12, "child");
table.Rows.Add(79, "elder");
table.Rows.Add(40, "adult");
table.Rows.Add(30, "adult");
// The filter will ignore non-real (continuous) data
Normalization normalization = new Normalization(table);
double mean = normalization["Age"].Mean; // 25.55
double sdev = normalization["Age"].StandardDeviation; // 23.29
// Now we can process another table at once:
DataTable result = normalization.Apply(table);
// The result will be a table with the same columns, but
// in which any column named "Age" will have been normalized
// using the previously detected mean and standard deviation:
// Accord.Controls.DataGridBox.Show(result);
Assert.AreEqual(25.555555555555557, mean);
Assert.AreEqual(23.297591673342072, sdev);
}