我在c#中使用Accord.net,这个库中有很多分类器算法,我想知道哪种算法对我的情况最好,我正在尝试使用监督学习对双类型数组进行分类,根据它们的分布情况,例如:
学习集:
a1 = new int[]{1,2,3,4} label a
a2 = new int[]{1,2,5,6} label a
a3= new int[]{1,1,0,0} label b
a4=new int[]{1,0,0,0} label b
a5 =new int[]{-10,0,-10,0} label c
a6=new int[]{-20,1,-20,1} label c在学习训练集之后,分类器将需要识别不在学习集中的数组:例如:
classify(new int[]{1,1,1,0}) ---> returns label b发布于 2016-06-05 19:19:43
你的数组有固定的大小吗?例如,它们是否总是像您的示例中那样包含4个条目?
如果是,使用Accord.NET的MulticlassSupportVectorMachine。documentation page for MulticlassSupportVectorMachine现在有一个简单的示例,如何对大小为3的数组进行分类,但您可以根据需要进行更改:
// Sample input data
double[][] inputs =
{
new double[] { -1, 3, 2 },
new double[] { -1, 3, 2 },
new double[] { -1, 3, 2 },
new double[] { 10, 82, 4 },
new double[] { 10, 15, 4 },
new double[] { 0, 0, 1 },
new double[] { 0, 0, 2 },
};
// Output for each of the inputs
int[] outputs = { 0, 3, 1, 2 };
// Create a new polynomial kernel
IKernel kernel = new Polynomial(2);
// Create a new Multi-class Support Vector Machine with one input,
// using the linear kernel and for four disjoint classes.
var machine = new MulticlassSupportVectorMachine(inputs: 3, kernel: kernel, classes: 4);
// Create the Multi-class learning algorithm for the machine
var teacher = new MulticlassSupportVectorLearning(machine, inputs, outputs);
// Configure the learning algorithm to use SMO to train the
// underlying SVMs in each of the binary class subproblems.
teacher.Algorithm = (svm, classInputs, classOutputs, i, j) =>
new SequentialMinimalOptimization(svm, classInputs, classOutputs);
// Run the learning algorithm
double error = teacher.Run(); // output should be 0
// Compute the decision output for one of the input vectors
int decision = machine.Compute( new double[] { -1, 3, 2 });https://stackoverflow.com/questions/37631410
复制相似问题