Skip to content

Instantly share code, notes, and snippets.

@Sg4Dylan
Created November 10, 2020 10:40
Show Gist options
  • Save Sg4Dylan/5edc57c0ec900a4dc8247184a3e7b93b to your computer and use it in GitHub Desktop.
Save Sg4Dylan/5edc57c0ec900a4dc8247184a3e7b93b to your computer and use it in GitHub Desktop.
OpenLORIS 指标计算
import csv
'''
suit for lifelong-robotic-vision/OpenLORIS-Object 's csv format result
every line of csv contains accuracy of every task on test set after training a single task
'''
raw_result = []
with open('openloris.csv', newline='') as csvfile:
spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
for row in spamreader:
if row == []:
continue
k = [float(i) for i in row[0].split(',')]
raw_result.append(k)
cls_cnt = 69
# Accuracy
sum_of = 0
cnt_of = 0
for idx in range(len(raw_result)):
cls = idx%cls_cnt
for i in range(len(raw_result[idx])):
if (i%cls_cnt) <= cls:
sum_of += raw_result[idx][i]
cnt_of += 1
print(f'Accuracy: {sum_of/cnt_of*100:.3f} %')
# Backward Transfer(BWT)
sum_of = 0
cnt_of = 0
for idx in range(len(raw_result)):
cls = idx%cls_cnt
for i in range(len(raw_result[idx])):
if (i%cls_cnt) < cls:
sum_of += raw_result[idx][i]
cnt_of += 1
print(f'BWT: {sum_of/cnt_of*100:.3f} %')
# Forward Transfer(FWT)
sum_of = 0
cnt_of = 0
for idx in range(len(raw_result)):
cls = idx%cls_cnt
for i in range(len(raw_result[idx])):
if (i%cls_cnt) > cls:
sum_of += raw_result[idx][i]
cnt_of += 1
print(f'FWT: {sum_of/cnt_of*100:.3f} %')
# Over-all accuracy
sum_of = 0
cnt_of = 0
for t in raw_result:
for i in t:
sum_of += i
cnt_of += 1
print(f'Over-all accuracy: {sum_of/cnt_of*100:.3f} %')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment