from IPython import display
Percepts and Concepts Lab, Spring 2014
for
loop with bugfuncall
- function call with different spacinginitvar
- summation and factorialorder
- 3 functions called (in order/shuffled)overload
- overloaded + operator (number/strings)partition
- partition list of numberswhitespace
- linear equations[ most errors ] • [ fewer errors ] • [ no errors ]
[1, 2] [3, 4]
[1, 2] [3, 4]
1 2 3,4
[1, 3]
[3, 4]
import pandas, scipy.stats, numpy
# Numpy and pandas work together to create R-like data frames
data = numpy.random.uniform(size=25).reshape((5, 5))
frame = pandas.DataFrame(data, columns=["A", "B", "C", "D", "E"])
# Non-numeric columns are supported
frame["F"] = ["x", "x", "o", "o", "o"]
frame
A | B | C | D | E | F | |
---|---|---|---|---|---|---|
0 | 0.988141 | 0.601001 | 0.313569 | 0.493887 | 0.702926 | x |
1 | 0.256549 | 0.802963 | 0.632752 | 0.250193 | 0.152852 | x |
2 | 0.875510 | 0.354493 | 0.665779 | 0.787402 | 0.279158 | o |
3 | 0.473622 | 0.000874 | 0.153416 | 0.064031 | 0.127221 | o |
4 | 0.255761 | 0.794496 | 0.568220 | 0.868812 | 0.488199 | o |
5 rows Ă— 6 columns
# Statistics are available in scipy.stats
r, p = scipy.stats.spearmanr(frame.A, frame.B)
print "Spearman: r={0}, p={1}".format(r, p)
# Pandas lets you sort, group, and slice data frames
for f_val, sub_frame in frame.groupby("F"):
# Underneath, they are accessible as standard numpy arrays
s_vals = sub_frame[["A", "B", "C", "D", "E"]].values.flatten()
print "When F={0}, sum is {1}, std is {2}".format(f_val, s_vals.sum(), s_vals.std())
Spearman: r=-0.5, p=0.391002218956 When F=o, sum is 6.75699318412, std is 0.291021433612 When F=x, sum is 5.19483392306, std is 0.259278513253
statsmodels
packageType | Dep. Var | Useful | Not Useful |
---|---|---|---|
Line | First fixation | Line # | Other text/content |
Line | Fixation duration | Line length, whitespace prop | Experience level |
Element | Fixation duration | Category, line # |
counting
programs only) 1 intercept = 1
2 slope = 5
3
4 x_base = 0
5 x_other = x_base + 1
6 x_end = x_base + x_other + 1
7
8 y_base = slope * x_base + intercept
9 y_other = slope * x_other + intercept
10 y_end = slope * x_end + intercept
11
12 print x_base, y_base
13 print x_other, y_other
14 print x_end, y_end
1 def area(xy_1, xy_2):
2 width = xy_2[0] - xy_1[0]
3 height = xy_2[1] - xy_1[1]
4 return width * height
5
6 r1_xy_1 = (0, 0)
7 r1_xy_2 = (10, 10)
8 r1_area = area(r1_xy_1, r1_xy_2)
9 print r1_area
10
11 r2_xy_1 = (5, 5)
12 r2_xy_2 = (10, 10)
13 r2_area = area(r2_xy_1, r2_xy_2)
14 print r2_area
[8, 7, 9] [1, 0, 8, 1] [8, 9, 0]
[8, 7, 9]
[1, 0, 8, 1]
[8]
(p encode-letter
=goal>
isa read-letters
state attend
=visual>
isa text
value =letter1
?imaginal>
buffer empty
==>
=goal>
state wait
+imaginal>
isa array
letter1 =letter1
)