-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnippets
More file actions
49 lines (34 loc) · 1.1 KB
/
snippets
File metadata and controls
49 lines (34 loc) · 1.1 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
X = []
Y = []
for filename in glob.glob(directoryr + '/*.txt'):
with open(filename) as f
s = f.readline()
ss = s.split('" (')
X.append(danny(ss[0] + '"'))
y = [];
for i in ss[1]
if (i != ',' and i != ' ' and i != ')')
y.append(int(i))
Y.append(y)
numex = len(X)
errL = [] #make numpy array
for lam in range(0:1000:1)
err = 0;
for j in range(0:(numex - 1))
testX = X[j]
testY = Y[j]
trainX = X.pop(j)
trainY = Y.pop(j)
X.insert(j, testX)
Y.insert(j, testY)
#figure out how to use numpy
#M = trainXT*trainX + lam*I (I is size of feature space)
#Invert M try: except LinAlgError:
#W = Minv*trainXT*trainY
guessY = dot(testX, W)
if !(guessY == testY).all():
err += 1
err = err/num_x
errL.append(err)
L = errL.argmin()
#get W and return it