public void ClassifyTest1()
{
// Create some sample input data
// This is the same data used in the example by Gutierrez-Osuna
// http://research.cs.tamu.edu/prism/lectures/pr/pr_l10.pdf
double[,] inputs =
{
{ 4, 1 }, // Class 1
{ 2, 4 },
{ 2, 3 },
{ 3, 6 },
{ 4, 4 },
{ 9, 10 }, // Class 2
{ 6, 8 },
{ 9, 5 },
{ 8, 7 },
{ 10, 8 }
};
int[] output =
{
1, 1, 1, 1, 1, // Class labels for the input vectors
2, 2, 2, 2, 2
};
// Create a new Linear Discriminant Analysis object
var lda = new KernelDiscriminantAnalysis(inputs, output, new Linear());
// Compute the analysis
lda.Compute();
// Test the classify method
for (int i = 0; i < 5; i++)
{
int expected = 1;
int actual = lda.Classify(inputs.GetRow(i));
Assert.AreEqual(expected, actual);
}
for (int i = 5; i < 10; i++)
{
int expected = 2;
int actual = lda.Classify(inputs.GetRow(i));
Assert.AreEqual(expected, actual);
}
}