Skip to content

Commit 857cbf0

Browse files
committed
MIN Avoid naming variable x1
In certain fonts, it resembles xl too much
1 parent 9916ae4 commit 857cbf0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎ch07/usermodel.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
defmovie_norm(xc):
2525
'''Normalize per movie'''
2626
xc=xc.copy().toarray()
27-
# x1 is the mean of the positive items
28-
x1=np.array([xi[xi>0].mean() forxiinxc])
29-
x1=np.nan_to_num(x1)
27+
# xpos is the mean of the positive items
28+
xpos=np.array([xi[xi>0].mean() forxiinxc])
29+
xpos=np.nan_to_num(xpos)
3030

3131
foriinrange(xc.shape[0]):
32-
xc[i] -= (xc[i] >0) *x1[i]
33-
returnxc, x1
32+
xc[i] -= (xc[i] >0) *xpos[i]
33+
returnxc, xpos
3434

3535

3636
deflearn_for(i):
@@ -43,12 +43,12 @@ def learn_for(i):
4343
eb=0
4444
kf=KFold(len(y), n_folds=4)
4545
fortrain, testinkf:
46-
xc, x1=movie_norm(x[train])
47-
reg.fit(xc, y[train] -x1)
46+
xc, xpos=movie_norm(x[train])
47+
reg.fit(xc, y[train] -xpos)
4848

49-
xc, x1=movie_norm(x[test])
49+
xc, xpos=movie_norm(x[test])
5050
p=reg.predict(xc).ravel()
51-
e= (p+x1) -y[test]
51+
e= (p+xpos) -y[test]
5252
err+=np.sum(e*e)
5353
eb+=np.sum((y[train].mean() -y[test]) **2)
5454
returnnp.sqrt(err/float(len(y))), np.sqrt(eb/float(len(y)))

0 commit comments

Comments
(0)