-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanalyze
More file actions
executable file
·93 lines (73 loc) · 2.52 KB
/
analyze
File metadata and controls
executable file
·93 lines (73 loc) · 2.52 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
import sys
import numpy as np
import pandas as ps
import seaborn as sns
import matplotlib.pyplot as plt
from read import read
from collections import OrderedDict
from pprint import pprint
from copy import deepcopy
def subject_indices(d, subject):
for i, s in enumerate(d['subjects'].values()):
if s == subject:
yield i
def add_percent_stat(d, k):
pdict = dict()
for subject in ['human', 'phaeaco']:
m = max(d[k][i] for i in subject_indices(d, subject))
for i in subject_indices(d, subject):
pdict[i] = d[k][i] / max(m, 1)
d['p' + k] = pdict
def extend(df):
d = df.to_dict()
for t in ['ctime', 'itime', 'ntime']:
add_percent_stat(d, t)
for a in ['correct', 'incorrect', 'no answer']:
add_percent_stat(d, a)
return ps.DataFrame(d)
def subject(df, s):
return df[(df.subjects == s)]
grid_vars = ['bongard problems', 'pctime', 'pcorrect', 'sdev']
def plot_grid(df):
# Compare too many things using phaeaco's sparse data
pal = dict(human="#41dff4", phaeaco="#f4aa42")
g = sns.pairplot(df, hue='subjects', palette=pal, vars=grid_vars,
kind='reg', diag_kind='kde')
for i, ax in enumerate(g.axes.flat): # set every-other axis for testing purposes
if i < 4:
ax.set_ylim(0, 200)
elif i < 12:
ax.set_ylim(0, 1)
def plot_subject_grids(df):
for subject in ['human', 'phaeaco']:
g = sns.pairplot(df, vars=grid_vars, kind='reg', diag_kind='kde')
for i, ax in enumerate(g.axes.flat): # set every-other axis for testing purposes
if i < 4:
ax.set_ylim(0, 200)
elif i < 12:
ax.set_ylim(0, 1)
g.fig.suptitle(subject)
def plot_pcorrect(df):
# Compare pcorrect in a bar graph
sns.barplot(x='bongard problems', y='pcorrect', hue='subjects', data=df)
def plot_kde(df):
# Show shorter problems take less time
sns.jointplot(x='pcorrect', y='pctime', data=df, kind='kde', xlim=(0,1), ylim=(0,1))
#sns.jointplot(x='pcorrect', y='pctime', data=df, kind='reg', xlim=(0,1), ylim=(0,1))
#g.set(ylim=(0, 1), xlim=(0, 1))
def plot_all(df):
#plt.style.use("dark_background")
df = extend(df)
print(df)
#plot_pcorrect(df)
#plot_grid(df)
#plot_kde(df)
plot_subject_grids(df)
plt.show()
def main(args):
data = read(includeNone=False)
plot_all(data)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))