Orange Forum • View topic - trouble with precision

trouble with precision

A place to ask questions about methods in Orange and how they are used and other general support.

trouble with precision

Postby ghyan » Tue May 01, 2012 0:36

I tried to run the following code:

===================================
import Orange
from Orange.classification import svm
from Orange.evaluation import testing, scoring

data = Orange.data.Table(filename)
bayes_learner = Orange.classification.bayes.NaiveLearner()
results = testing.cross_validation([bayes_learner], data, folds = 5)

cm = scoring.confusion_matrices(results)[0]
print "Confusion matrix for naive Bayes:"
print "TP: %i, FP: %i, FN: %s, TN: %i" % (cm.TP, cm.FP, cm.FN, cm.TN)
===================================

Then I got the error: AttributeError: 'list' object has no attribute 'TP'. Seems that the returned type of scoring.confusion_matrices is the list of list, which doesn't have attributes like TP, FP, etc. Where did I do things wrongly? Many thanks.

Re: trouble with precision

Postby Ales » Thu May 03, 2012 9:48

scoring.confusion_matrices returns actual instances of ConfusionMatrix class only for binary class problems unless the 'class_index' parameter is specified.

This is (briefly) mentioned in the documentation for the scoring module (http://orange.biolab.si/doc/reference/Orange.evaluation.scoring/#calibration-scores), but not in the documentation of the actual function. This will be fixed.

Re: trouble with precision

Postby ghyan » Tue May 08, 2012 1:16

Thanks.


Return to Questions & Support