看了https://github.com/accord-net/framework/wiki/Classification 教程,按照上面写的代码输入:
DataTable table = new ExcelReader("D:\\FinalProject\\examples.xls").GetWorksheet("Classification - Yin Yang");
double[][] inputs = table.ToArray<double>("X", "Y");
int[] outputs = table.Columns["G"].ToArray<int>();
var learner = new NaiveBayesLearning<NormalDistribution>();
var nb = learner.Learn(inputs, outputs);
int[] answers = nb.Decide(inputs);
ScatterplotBox.Show("Expected results", inputs, outputs);
ScatterplotBox.Show("Naive Bayes results", inputs, answers)
.Hold();
发现问题是variance is zero, try to specify a constant value,? 这该怎么解决?代码就是按照网页上的,难道有什么错误么?求大神解答 谢谢! 这给example文档在这给教程上可以下载,还有这个教程上好多代码貌似都不对啊?
DataTable table = new ExcelReader("D:\\FinalProject\\examples.xls").GetWorksheet("Classification - Yin Yang");
double[][] inputs = table.ToArray<double>("X", "Y");
int[] outputs = table.Columns["G"].ToArray<int>();
var learner = new NaiveBayesLearning<NormalDistribution>();
var nb = learner.Learn(inputs, outputs);
int[] answers = nb.Decide(inputs);
ScatterplotBox.Show("Expected results", inputs, outputs);
ScatterplotBox.Show("Naive Bayes results", inputs, answers)
.Hold();
发现问题是variance is zero, try to specify a constant value,? 这该怎么解决?代码就是按照网页上的,难道有什么错误么?求大神解答 谢谢! 这给example文档在这给教程上可以下载,还有这个教程上好多代码貌似都不对啊?
你看看inputs的长度 是不是和outputs的长度一致
nputs =new double[][] {
new double []{1,0},
new []{1,1},
new []{0,0},
new []{0,1}
}
outputs= new int[]
{
0,1,0,0
}试一试,与操作