-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathcmp.py
29 lines (20 loc) · 863 Bytes
/
cmp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pandas as pd
import numpy as np
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('input', nargs=2)
df1, df2 = parser.parse_args().input
df1 = pd.read_pickle(df1)
df2 = pd.read_pickle(df2)
df1 = df1.sort_values(by=['file_name', 'frame_number'])
#df2 = df1.sort_values(by=['file_name', 'frame_number'], ascending=False)
df2 = df2.sort_values(by=['file_name', 'frame_number'])
assert df1.shape == df2.shape
scores = []
for i in range(df1.shape[0]):
file_name1 = df1['file_name'].iloc[i].split('.')[0]
file_name2 = df2['file_name'].iloc[i].split('.')[0]
assert file_name1 == file_name2
assert df1['frame_number'].iloc[i] == df2['frame_number'].iloc[i]
scores.append(np.sum(np.abs(df1['value'].iloc[i] - df2['value'].iloc[i]).astype(float) ** 2))
print ("Average difference: %s" % np.mean(scores))