1
Q
找到秧雞
A
回答
1
既然你提到MATLAB,我假設你正在使用Weka庫的Java API以編程方式構建分類器。
在這種情況下,您可以使用weka.classifiers.Evaluation類來評估模型,該類提供各種統計信息。
假設你已經有了Java類路徑上weka.jar
文件(見javaaddpath
功能),這裏是在MATLAB一個例子:
%# data
fName = 'C:\Program Files\Weka-3-7\data\iris.arff';
loader = weka.core.converters.ArffLoader();
loader.setFile(java.io.File(fName));
data = loader.getDataSet();
data.setClassIndex(data.numAttributes()-1);
%# classifier
classifier = weka.classifiers.trees.J48();
classifier.setOptions(weka.core.Utils.splitOptions('-C 0.25 -M 2'));
classifier.buildClassifier(data);
%# evaluation
evl = weka.classifiers.Evaluation(data);
pred = evl.evaluateModel(classifier, data, {''});
%# display
disp(classifier.toString())
disp(evl.toSummaryString())
disp(evl.toClassDetailsString())
disp(evl.toMatrixString())
%# confusion matrix and other stats
cm = evl.confusionMatrix();
%# number of TP/TN/FP/FN with respect to class=1 (Iris-versicolor)
tp = evl.numTruePositives(1);
tn = evl.numTrueNegatives(1);
fp = evl.numFalsePositives(1);
fn = evl.numFalseNegatives(1);
%# class=XX is a zero-based index which maps to the following class values
classValues = arrayfun(@(k)char(data.classAttribute.value(k-1)), ...
1:data.classAttribute.numValues, 'Uniform',false);
輸出:
J48 pruned tree
------------------
petalwidth <= 0.6: Iris-setosa (50.0)
petalwidth > 0.6
| petalwidth <= 1.7
| | petallength <= 4.9: Iris-versicolor (48.0/1.0)
| | petallength > 4.9
| | | petalwidth <= 1.5: Iris-virginica (3.0)
| | | petalwidth > 1.5: Iris-versicolor (3.0/1.0)
| petalwidth > 1.7: Iris-virginica (46.0/1.0)
Number of Leaves : 5
Size of the tree : 9
Correctly Classified Instances 147 98 %
Incorrectly Classified Instances 3 2 %
Kappa statistic 0.97
Mean absolute error 0.0233
Root mean squared error 0.108
Relative absolute error 5.2482 %
Root relative squared error 22.9089 %
Coverage of cases (0.95 level) 98.6667 %
Mean rel. region size (0.95 level) 34 %
Total Number of Instances 150
=== Detailed Accuracy By Class ===
TP Rate FP Rate Precision Recall F-Measure MCC ROC Area PRC Area Class
1.000 0.000 1.000 1.000 1.000 1.000 1.000 1.000 Iris-setosa
0.980 0.020 0.961 0.961 0.961 0.955 0.990 0.969 Iris-versicolor
0.960 0.010 0.980 0.980 0.980 0.955 0.990 0.970 Iris-virginica
Weighted Avg. 0.980 0.010 0.980 0.980 0.980 0.970 0.993 0.980
=== Confusion Matrix ===
a b c <-- classified as
50 0 0 | a = Iris-setosa
0 49 1 | b = Iris-versicolor
0 2 48 | c = Iris-virginica
相關問題
- 1. 如何使用與秧雞
- 2. 創造秧雞的Java API
- 3. Liblinear不CLASSPARH,與秧雞
- 4. java的幫助,秧雞:UnsupportedAttributeTypeException
- 5. 。例如秧雞網站無法找到ARFF文件類標籤
- 6. 從命令行運行秧雞 - 找不到類NaiveBayes
- 7. 培訓和測試集不是秧雞
- 8. 秧雞和MongoDB連接失敗
- 9. 秧雞的Java API stringtovector例外
- 10. 我怎麼編譯在NetBeans秧雞,scr.jar
- 11. 秧雞無主類中發現錯誤
- 12. 秧雞:自動應用屬性選擇
- 13. 秧雞StringToWordVector過濾器逆轉(JAVA)
- 14. 不能在秧雞3.7.10使用libsvm的之後,從秧雞包管理器進行安裝,在Windows
- 15. 秧雞:如何從測試單個實例
- 16. 的Java秧雞stringtowordvector不計字OCCURENCES正確
- 17. 秧雞不C4.5格式文件加載由於缺少值
- 18. K均值聚類使用秧雞蟒蛇
- 19. 處理%符號的字符串屬性在秧雞
- 20. Weka中嘗試使用AdaBostM1秧雞分類與配置修剪
- 21. 如何搭配屬性兩個實例的順序秧雞
- 22. 從秧雞培訓和java培訓發散結果
- 23. 如何分割秧雞分類器的比例在MATLAB
- 24. 解釋屬性選擇的輸出秧雞
- 25. 如何.arff文件中的「ID」添加到每個列的k-means在秧雞
- 26. 無法使用artff文件秧雞字符串屬性,並建立分級
- 27. 秧雞:列車和不同的格式(ARFF和文本格式)測試集
- 28. JQ比較元素的列表,找到鶴立雞羣
- 29. Java中的雞或雞蛋難題
- 30. 循環依賴,雞和雞蛋