2017-02-17 131 views
1

我在accord.net是新的,我想一步從這個page下面的代碼適用走進Visual Studio C#樣品Accord.NET樸素貝葉斯

部分的代碼的簡單應用「標準分類問題」已被應用沒有問題,但是當我嘗試運行時應用段「樸素貝葉斯」的代碼我得到了一個異常與該說明

unhandled exception of type System.AggregateException occurred in mscorlib.dll 沒有進一步desciption。

這發生在以下命令

var nb = learner.Learn(inputs, outputs)

我的代碼是我的程序以下

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(); 

堆棧跟蹤

enter image description here

+0

你能後的異常堆棧跟蹤?檢查了哪些行中斷? – tchrikch

+0

@tchrikch已更新 –

回答

1

examples.xls從您在帖子中指出的同一頁面下載的內容似乎具有不良/不兼容/過時的數據。在G列,與(行2至51)更換所有-1是卓有成效的,使用雅閣v3.4.2-α

enter image description here

enter image description here

enter image description here

+0

感謝您的回答。但是有什麼想法,我爲什麼要在.xls中做你建議的改變? –

+0

我的理解是,** G **列(G組)是一個確定一個特定點是否屬於一個或另一個組(陰或陽)的公約。在某些時候,這個約定可能已經在源代碼中被改變了,但是在** xls **的數據中沒有改變。如果你從他們的樣本下載源代碼,你會得到正確的** xls **,這就是我發現它的原因。 – jsanalytics

+0

畢竟這個變化對你有用嗎? – jsanalytics