首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >基于分布Accord.net对数字数组进行分类

基于分布Accord.net对数字数组进行分类
EN

Stack Overflow用户
提问于 2016-06-04 22:34:06
回答 1查看 276关注 0票数 2

我在c#中使用Accord.net,这个库中有很多分类器算法,我想知道哪种算法对我的情况最好,我正在尝试使用监督学习对双类型数组进行分类,根据它们的分布情况,例如:

学习集:

代码语言:javascript
运行
复制
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

在学习训练集之后,分类器将需要识别不在学习集中的数组:例如:

代码语言:javascript
运行
复制
classify(new int[]{1,1,1,0}) ---> returns label b
EN

回答 1

Stack Overflow用户

发布于 2016-06-05 19:19:43

你的数组有固定的大小吗?例如,它们是否总是像您的示例中那样包含4个条目?

如果是,使用Accord.NET的MulticlassSupportVectorMachine。documentation page for MulticlassSupportVectorMachine现在有一个简单的示例,如何对大小为3的数组进行分类,但您可以根据需要进行更改:

代码语言:javascript
运行
复制
// 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 });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37631410

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档