public void UseClassProportionsTest()
{
var dataset = KernelSupportVectorMachineTest.training;
var inputs = dataset.Submatrix(null, 0, 3);
var labels = Accord.Math.Tools.Scale(0, 1, -1, 1, dataset.GetColumn(4)).ToInt32();
Gaussian kernel = Gaussian.Estimate(inputs);
var machine = new KernelSupportVectorMachine(kernel, inputs[0].Length);
var smo = new SequentialMinimalOptimization(machine, inputs, labels);
smo.Complexity = 1.0;
smo.UseClassProportions = true;
double error = smo.Run();
Assert.AreEqual(1, smo.Complexity);
Assert.AreEqual(0.4, smo.PositiveWeight);
Assert.AreEqual(1.0, smo.NegativeWeight);
Assert.AreEqual(0.4, smo.WeightRatio, 1e-10);
Assert.AreEqual(0.2857142857142857, error);
Assert.AreEqual(265.78327637381551, ((Gaussian)machine.Kernel).Sigma);
Assert.AreEqual(26, machine.SupportVectors.Length);
int[] actual = new int[labels.Length];
for (int i = 0; i < actual.Length; i++)
actual[i] = Math.Sign(machine.Compute(inputs[i]));
ConfusionMatrix matrix = new ConfusionMatrix(actual, labels);
Assert.AreEqual(12, matrix.FalseNegatives);
Assert.AreEqual(0, matrix.FalsePositives);
Assert.AreEqual(0, matrix.TruePositives);
Assert.AreEqual(30, matrix.TrueNegatives);
}