本文整理汇总了C#中Accord.MachineLearning.VectorMachines.KernelSupportVectorMachine.ToMulticlass方法的典型用法代码示例。如果您正苦于以下问题:C# KernelSupportVectorMachine.ToMulticlass方法的具体用法?C# KernelSupportVectorMachine.ToMulticlass怎么用?C# KernelSupportVectorMachine.ToMulticlass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Accord.MachineLearning.VectorMachines.KernelSupportVectorMachine
的用法示例。
在下文中一共展示了KernelSupportVectorMachine.ToMulticlass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTest1
public void RunTest1()
{
double[][] inputs =
{
new double[] { -1, -1 },
new double[] { -1, 1 },
new double[] { 1, -1 },
new double[] { 1, 1 }
};
int[] outputs =
{
-1,
1,
1,
-1
};
KernelSupportVectorMachine svm = new KernelSupportVectorMachine(new Gaussian(3.6), 2);
var smo = new SequentialMinimalOptimization(svm, inputs, outputs);
double error1 = smo.Run();
Assert.AreEqual(0, error1);
double[] distances = new double[outputs.Length];
for (int i = 0; i < outputs.Length; i++)
{
int y = svm.Compute(inputs[i], out distances[i]);
Assert.AreEqual(outputs[i], y);
}
var target = new ProbabilisticOutputCalibration(svm, inputs, outputs);
double ll0 = target.LogLikelihood(inputs, outputs);
double ll1 = target.Run();
double ll2 = target.LogLikelihood(inputs, outputs);
Assert.AreEqual(5.5451735748694571, ll1);
Assert.AreEqual(ll1, ll2);
Assert.IsTrue(ll1 > ll0);
double[] newdistances = new double[outputs.Length];
for (int i = 0; i < outputs.Length; i++)
{
int y = svm.Compute(inputs[i], out newdistances[i]);
Assert.AreEqual(outputs[i], y);
}
double[] probs = new double[outputs.Length];
for (int i = 0; i < outputs.Length; i++)
{
int y;
probs[i] = svm.ToMulticlass().Probability(inputs[i], out y);
Assert.AreEqual(outputs[i], y == 1 ? 1 : -1);
}
Assert.AreEqual(0.25, probs[0], 1e-5);
Assert.AreEqual(0.75, probs[1], 1e-5);
Assert.AreEqual(0.75, probs[2], 1e-5);
Assert.AreEqual(0.25, probs[3], 1e-5);
foreach (var p in probs)
Assert.IsFalse(Double.IsNaN(p));
}