diff --git a/ss2013/1_Web Mining/Uebungen/4_Uebung/code/confusion_matrix.py b/ss2013/1_Web Mining/Uebungen/4_Uebung/code/confusion_matrix.py index 52f7fb8c..1213b4d3 100644 --- a/ss2013/1_Web Mining/Uebungen/4_Uebung/code/confusion_matrix.py +++ b/ss2013/1_Web Mining/Uebungen/4_Uebung/code/confusion_matrix.py @@ -48,13 +48,21 @@ def accuracy(): global document_count i = 0 ok_recognized = 0 + wrong_recognized = 0 for conf in conf_matr: - ok_recognized += conf[i] + j = 0 + for c in conf: + if i == j: + ok_recognized += c + else: + wrong_recognized += c + j += 1 + i += 1 #print ok_recognized #print document_count - accuracy = float(ok_recognized) / float(document_count) + accuracy = float(ok_recognized) / float(wrong_recognized) def prec(): #per class -> positive matches / alle matches auf class