Updates chi2 code for final comparison
This commit is contained in:
@ -5,7 +5,7 @@ import pickle
|
||||
from pprint import pprint
|
||||
|
||||
from copycat import Problem
|
||||
from copycat.statistics import cross_chi_squared
|
||||
from copycat.statistics import cross_chi_squared, cross_chi_squared_table
|
||||
|
||||
def compare_sets():
|
||||
pass
|
||||
@ -18,7 +18,30 @@ def main(args):
|
||||
pSet = pickle.load(infile)
|
||||
branchProblemSets[filename] = pSet
|
||||
problemSets.append((filename, pSet))
|
||||
pprint(cross_chi_squared(problemSets))
|
||||
#pprint(problemSets)
|
||||
#pprint(cross_chi_squared(problemSets))
|
||||
crossTable = cross_chi_squared_table(problemSets)
|
||||
key_sorted_items = lambda d : sorted(d.items(), key=lambda t:t[0])
|
||||
|
||||
tableItems = key_sorted_items(crossTable)
|
||||
assert len(tableItems) > 0, 'Empty table'
|
||||
|
||||
with open('output/cross_compare.csv', 'w') as outfile:
|
||||
headKey, headSubDict = tableItems[0]
|
||||
cells = ['problems x variants']
|
||||
for subkey, subsubdict in key_sorted_items(headSubDict):
|
||||
for subsubkey, result in key_sorted_items(subsubdict):
|
||||
cells.append('{} x {} for {} x {}'.format(*subkey, *subsubkey))
|
||||
outfile.write(','.join(cells) + '\n')
|
||||
|
||||
for key, subdict in tableItems:
|
||||
cells = []
|
||||
problem = '{}:{}::{}:_'.format(*key)
|
||||
cells.append(problem)
|
||||
for subkey, subsubdict in key_sorted_items(subdict):
|
||||
for subsubkey, result in key_sorted_items(subsubdict):
|
||||
cells.append(str(result))
|
||||
outfile.write(','.join(cells) + '\n')
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user