我是 accord.net
的新手,我正在尝试逐步应用此 page 中的以下代码转换为 Visual Studio C#
“标准分类问题”部分的代码已毫无问题地应用,但是当我尝试在运行时应用“朴素贝叶斯”部分的代码时,我遇到了该描述的异常
mscorlib.dll 中发生 System.AggregateException 类型的未处理异常
不再赘述。
这发生在以下命令中
var nb = learner.Learn(输入,输出)
我的代码如下
DataTable table = new celReader("examples.xls").GetWorksheet("Classification - Yin Yang");
// Convert the DataTable to input and output vectors
double[][] inputs = table.ToArray<double>("X", "Y");
int[] outputs = table.Columns["G"].ToArray<int>();
// Plot the data
ScatterplotBox.Show("Yin-Yang", inputs, outputs).Hold();
var learner = new NaiveBayesLearning<NormalDistribution>();
// Estimate the Naive Bayes
var nb = learner.Learn(inputs, outputs); // this is where exception is thrown
// Classify the samples using the model
int[] answers = nb.Decide(inputs);
// Plot the results
ScatterplotBox.Show("Expected results", inputs, outputs);
ScatterplotBox.Show("Naive Bayes results", inputs, answers).Hold();
我的程序的堆栈跟踪
最佳答案
从您在帖子中指出的同一页面下载的examples.xls似乎包含错误/不兼容/过时的数据。在 G 列中,使用 Accord v3.4.2- 将所有 -1 替换为 0(第 2 至 51 行)即可解决问题阿尔法。
关于c# - 示例 Accord.NET 朴素贝叶斯,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42299201/