We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 822f6ac commit 83d426cCopy full SHA for 83d426c
ch08/norm.py
@@ -5,19 +5,19 @@ class NormalizePositive(object):
5
deffit(self, X, y=None):
6
# count features that are greater than zero in axis 0:
7
binary= (X>0)
8
-count0=binary.sum(0)
+count0=binary.sum(axis=0)
9
10
# to avoid division by zero, set zero counts to one:
11
count0+= (count0==0)
12
13
-self.mean=X.sum(0)/count0
+self.mean=X.sum(axis=0)/count0
14
15
# Compute variance by average squared difference to the mean, but only
16
# consider differences where binary is True (i.e., where there was a
17
# true rating):
18
diff= (X-self.mean) *binary
19
diff**=2
20
-self.std=np.sqrt(0.1+diff.sum(0)/count0)
+self.std=np.sqrt(0.1+diff.sum(axis=0)/count0)
21
returnself
22
23
deffit_transform(self, X):
0 commit comments