質問編集履歴
1
ソースコードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -23,6 +23,82 @@
|
|
23
23
|
|
24
24
|
|
25
25
|
### 該当のソースコード
|
26
|
+
|
27
|
+
```python
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
import numpy as np
|
32
|
+
|
33
|
+
import pandas as pd
|
34
|
+
|
35
|
+
import matplotlib.pyplot as plt
|
36
|
+
|
37
|
+
from matplotlib import rcParams
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
rcParams['font.family'] = 'sans-serif'
|
42
|
+
|
43
|
+
rcParams['font.sans-serif'] = ['Hiragino Maru Gothic Pro', 'Yu Gothic', 'Meirio', 'Takao', 'IPAexGothic', 'IPAPGothic', 'VL PGothic', 'Noto Sans CJK JP']
|
44
|
+
|
45
|
+
plt.rcParams['figure.figsize'] = 20, 5
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
weather_df = pd.read_csv("/content/weather.csv", index_col='年月日', encoding="shift-jis")
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
data_X = []
|
54
|
+
|
55
|
+
data_y = []
|
56
|
+
|
57
|
+
p = 10
|
58
|
+
|
59
|
+
for i in range(len(weather_df)-p):
|
60
|
+
|
61
|
+
data_X.append(weather_df['平均気温(℃)'][i:i+p])
|
62
|
+
|
63
|
+
data_y.append(weather_df['平均気温(℃)'][i+p])
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
data_X = np.array(data_X)
|
68
|
+
|
69
|
+
data_y = np.array(data_y)
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
len_train = int(len(data_X)*0.7)
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
X_train = data_X[:len_train]
|
78
|
+
|
79
|
+
X_test = data_X[len_train:]
|
80
|
+
|
81
|
+
y_train = data_y[:len_train]
|
82
|
+
|
83
|
+
y_test = data_y[len_train:]
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
from sklearn.preprocessing import MinMaxScaler
|
88
|
+
|
89
|
+
scaler_x = MinMaxScaler()
|
90
|
+
|
91
|
+
X_train_n = scaler_x.fit_transform(X_train)
|
92
|
+
|
93
|
+
X_test_n = scaler_x.transform(X_test)
|
94
|
+
|
95
|
+
scaler_y = MinMaxScaler()
|
96
|
+
|
97
|
+
y_train_n = scaler_y.fit_transform(y_train.reshape(len(y_train),1))
|
98
|
+
|
99
|
+
y_test_n = scaler_y.transform(y_test.reshape(len(y_test),1))
|
100
|
+
|
101
|
+
```
|
26
102
|
|
27
103
|
|
28
104
|
|