-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrangerPovlitz_CombinationAccuracy.py
More file actions
70 lines (55 loc) · 2.21 KB
/
GrangerPovlitz_CombinationAccuracy.py
File metadata and controls
70 lines (55 loc) · 2.21 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import pandas as pd
import itertools
import sys
from scipy import stats
#our functions from other files
import GrangerPovlitz_Combination as cmb
import Cognitive_Diversity as cogdiv
# sets up a pandas dataframe with the gaze data, based on command line inputs.
def setup_data():
# trys to take in the argument (names of gaze data file) from the command line
try:
gazeData = pd.read_csv("Gaze_DataFile.csv")
rankData = pd.read_csv("Gaze_DataRanks.csv")
gazeData = gazeData.iloc[:, 1:]
rankData = rankData.iloc[:, 1:]
return(gazeData, rankData)
#ends the program if the data is not input correctly.
except (ZeroDivisionError, IndexError):
print "Error with the input file"
quit()
# returns a list of lists, which includes all possible subsets of the original list. Takes in a list of items, which can be either numbers or strings
def combinations(data):
combos = []
for i in range(len(data)+1):
els = [list(x) for x in itertools.combinations(data, i)]
combos.extend(els)
#removes the empty list from our list of lists
if [] in combos:
combos.remove([])
return combos
def main():
#setup variables
precisionAt = [100,200,300]
gazeData, rankData = setup_data()
combos = combinations( range(gazeData.shape[1]-1))
singlecombos = [0,1,2,3,4]
for attr1 in combos:
diversity_sum = 0.0
for attr2 in combos:
if attr1 == attr2:
continue
#print "Score diversity between " + str(attr1) + " and " + str(attr2) + " is " + str(cogdiv.calculateDiversity(gazeData, attr1, attr2))
temp1 = cogdiv.calculateDiversity(gazeData, attr1, attr2)
diversity_sum += temp1[0]
print "Cog diversity single max diff between " + str(attr1) + " and " + str(attr2) + " is " + str(temp1[1])
print "\n\tScore diversity of " + str(attr1) + " against all other attribute combinations is " + str(round(diversity_sum, 2)) + "\n"
print ""
# runs score and rank total for each combinations, and neatly prints out the result.
for attrs in [[2]]:
print map(lambda x: chr(x+65), attrs)
print "\tScore combination accuracy percentages: " + str(cmb.accuracy(gazeData, attrs, precisionAt))
print "\tRank combination accuracy percentages: " + str(cmb.accuracy(rankData, attrs, precisionAt))
print
if __name__ == '__main__':
main()