Skip to content

Commit

Permalink
mods to Confusion Matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
kscottz committed Feb 20, 2013
1 parent 82eead5 commit d8610a4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions SimpleCV/MachineLearning/ConfusionMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ def addDataPoint(self,truth_name,test_name):
self.totalCount += 1

def getCorrectPercent(self):
return np.around(float(self.correctCount)/float(self.totalCount),4)
if( self.totalCount > 0 and self.correctCount ):
return np.around(float(self.correctCount)/float(self.totalCount),4)
else:
return 0.00

def getIncorrectPercent(self):
return np.around(float(self.incorrectCount)/float(self.totalCount),4)
if( self.totalCount > 0 and self.correctCount ):
return np.around(float(self.incorrectCount)/float(self.totalCount),4)
else:
return 0.00

def getClassCorrectPercent(self, className):
total = float(np.sum(self.confusionMatrix[:,self.nameMap[className]]))
Expand Down

0 comments on commit d8610a4

Please sign in to comment.