Skip to content

Commit 83d426c

Browse files
committed
MIN Add axis= for explicitness
1 parent 822f6ac commit 83d426c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ch08/norm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ class NormalizePositive(object):
55
def fit(self, X, y=None):
66
# count features that are greater than zero in axis 0:
77
binary = (X > 0)
8-
count0 = binary.sum(0)
8+
count0 = binary.sum(axis=0)
99

1010
# to avoid division by zero, set zero counts to one:
1111
count0 += (count0 == 0)
1212

13-
self.mean = X.sum(0)/count0
13+
self.mean = X.sum(axis=0)/count0
1414

1515
# Compute variance by average squared difference to the mean, but only
1616
# consider differences where binary is True (i.e., where there was a
1717
# true rating):
1818
diff = (X - self.mean) * binary
1919
diff **= 2
20-
self.std = np.sqrt(0.1 + diff.sum(0)/count0)
20+
self.std = np.sqrt(0.1 + diff.sum(axis=0)/count0)
2121
return self
2222

2323
def fit_transform(self, X):

0 commit comments

Comments
 (0)