回答編集履歴
1
d
test
CHANGED
@@ -9,3 +9,53 @@
|
|
9
9
|
+ for i in range(data.shape[1]):
|
10
10
|
|
11
11
|
```
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
## 追記
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
```python
|
20
|
+
|
21
|
+
import numpy as np
|
22
|
+
|
23
|
+
import csv
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
def standardize(x):
|
30
|
+
|
31
|
+
mean = x.mean()
|
32
|
+
|
33
|
+
std = x.std()
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
return (x - mean) / std
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
data = np.loadtxt("sample.csv", delimiter=",", skiprows=1)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
normalized = np.empty_like(data)
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
for i in range(data.shape[1]):
|
54
|
+
|
55
|
+
normalized[:, i] = standardize(data[:, i])
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
np.savetxt("normalized.csv", normalized, delimiter=",")
|
60
|
+
|
61
|
+
```
|