Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 6b2cef5f rédigé par Harold MOUCHERE's avatar Harold MOUCHERE
Parcourir les fichiers

Add computation and print of error histogramm

	modified:   sumMetric.py
parent 34df7abf
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
*.pyc
*.py~
*~
.#*
......@@ -72,7 +72,32 @@ def printTable( field_width, entries):
else:
labelFormat += '{0[' + str(i) + ']:>{width}}'
print labelFormat.format( entries, width=field_width)
def histogramm(values):
"""Compute the histogramm of all values: a dictionnary dict[v]=count"""
hist = {}
for v in values:
if v in hist:
hist[v]+=1
else:
hist[v]=1
return hist
def printHist(hist,N,field_width):
vals = []
cumulVals = []
cum = 0
for i in range(0,N):
if i in hist:
vals.append(hist[i])
else:
vals.append(0)
cum += vals[-1]
cumulVals.append(cum)
printTable(field_width, range(0,N))
printTable(field_width, vals)
printTable(field_width, cumulVals)
def main():
if len(sys.argv) < 2:
......@@ -104,9 +129,10 @@ def main():
fileList = fileList + [row[1]]
continue
for i in range(0,len(row),2):
if row[i].strip() not in allValues:
allValues[row[i].strip()] = []
allValues[row[i].strip()] = allValues[row[i].strip()] \
vName = row[i].strip()
if vName not in allValues:
allValues[vName] = []
allValues[vName] = allValues[vName] \
+ [float(row[i+1].strip())]
nbEM+=1
......@@ -114,9 +140,11 @@ def main():
allSum = {}
allZeroCount = {}
zeroFileList = {}
allHist = {}
for v in allValues.keys():
allSum[v] = sum(allValues[v])
#print(str(v) + " = " + str(allSum[v]))
allHist[v] = histogramm(allValues[v])
allZeroCount[v] = 0
for s in range(len(allValues[v])):
if allValues[v][s] == 0:
......@@ -298,5 +326,8 @@ def main():
#printTable(fieldWidth,['*Segs-CL', classRate, correctSegments, correctClass, correctSegments - correctClass])
print("")
print ("ERROR HISTOGRAMM AT PRIMITIVE LEVEL")
printHist(allHist['D_B'],5,fieldWidth)
main()
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter