webmining u4 update
This commit is contained in:
parent
7c7759b248
commit
e65f1c2448
@ -54,6 +54,7 @@ def accuracy():
|
||||
accuracy = float(ok_recognized) / float(document_count)
|
||||
|
||||
def prec():
|
||||
#per class -> positive matches / alle matches auf class
|
||||
i = 0
|
||||
global precision
|
||||
for conf in conf_matr:
|
||||
@ -69,7 +70,7 @@ def prec():
|
||||
if not_ok_values +ok_values > 0:
|
||||
precision[i] = float(ok_values) / float(ok_values + not_ok_values)
|
||||
else:
|
||||
precision[i] = 0
|
||||
precision[i] = 0 #division by zero
|
||||
i += 1
|
||||
|
||||
def avg_prec():
|
||||
@ -81,26 +82,34 @@ def avg_prec():
|
||||
|
||||
|
||||
def pp_confusionmatrix():
|
||||
print "\tc1\tc2\tc3\tc4\tc5\tc6\tc7\tc8\tc9\tc10\tc11"
|
||||
lines = ["c1\t","c2\t","c3\t","c4\t","c5\t","c6\t","c7\t","c8\t","c9\t","c10\t","c11\t"]
|
||||
print "\t\t"+classes[0][0]+"\t"+classes[1][0]+"\t"+classes[2][0]+"\t"+classes[3][0]+"\t"+classes[4][0]+"\t"+classes[5][0]+"\t"+classes[6][0]+"\t"+classes[7][0]+"\t"+classes[8][0]+"\t"+classes[9][0]+"\t"+classes[10][0]
|
||||
lines = [""+classes[0][0]+"\t",classes[1][0]+"\t",""+classes[2][0]+"\t",classes[3][0]+"\t\t",classes[4][0]+"\t",classes[5][0]+"\t\t",classes[6][0]+"\t\t",classes[7][0]+"\t\t",classes[8][0]+"\t\t",classes[9][0]+"\t\t",classes[10][0]+"\t\t"]
|
||||
for column in conf_matr:
|
||||
lines[0] += str(column[0]) + "\t"
|
||||
lines[1] += str(column[1]) + "\t"
|
||||
lines[2] += str(column[2]) + "\t"
|
||||
lines[3] += str(column[3]) + "\t"
|
||||
lines[4] += str(column[4]) + "\t"
|
||||
lines[5] += str(column[5]) + "\t"
|
||||
lines[6] += str(column[6]) + "\t"
|
||||
lines[7] += str(column[7]) + "\t"
|
||||
lines[8] += str(column[8]) + "\t"
|
||||
lines[9] += str(column[9]) + "\t"
|
||||
lines[10] += str(column[10]) + "\t"
|
||||
lines[0] += str(column[0]) + "\t\t"
|
||||
lines[1] += str(column[1]) + "\t\t"
|
||||
lines[2] += str(column[2]) + "\t\t"
|
||||
lines[3] += str(column[3]) + "\t\t"
|
||||
lines[4] += str(column[4]) + "\t\t"
|
||||
lines[5] += str(column[5]) + "\t\t"
|
||||
lines[6] += str(column[6]) + "\t\t"
|
||||
lines[7] += str(column[7]) + "\t\t"
|
||||
lines[8] += str(column[8]) + "\t\t"
|
||||
lines[9] += str(column[9]) + "\t\t"
|
||||
lines[10] += str(column[10]) + "\t\t"
|
||||
|
||||
for l in lines:
|
||||
print l
|
||||
|
||||
def pp_accuracy():
|
||||
print "Accuracy: "+str(round(accuracy*100,4))+"%"
|
||||
|
||||
def pp_prec():
|
||||
line = "Precision per class: "
|
||||
i = 0
|
||||
for p in precision:
|
||||
line += classes[i][0]+":"+str(round(p*100,4))+" "
|
||||
i += 1
|
||||
print line
|
||||
|
||||
if __name__ == '__main__':
|
||||
load_predictionfile(predfile)
|
||||
@ -111,7 +120,7 @@ if __name__ == '__main__':
|
||||
accuracy()
|
||||
pp_accuracy()
|
||||
prec()
|
||||
print precision
|
||||
pp_prec()
|
||||
avg_prec()
|
||||
print precision_avg
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user