質問編集履歴
5
.
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,7 +52,9 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
# 学習データを70%(X_train[X_vars]_val, y_train[Y_vars]_val)、
|
55
|
+
# 学習データを70%(X_train[X_vars]_val, y_train[Y_vars]_val)、
|
56
|
+
|
57
|
+
テストデータを30%(X_test, y_test)に分割
|
56
58
|
|
57
59
|
X_train[X_vars]_val, X_test, y_train[Y_vars]_val, y_test = \
|
58
60
|
|
4
コードを修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,7 +72,7 @@
|
|
72
72
|
|
73
73
|
rf = RandomForestRegressor()
|
74
74
|
|
75
|
-
rf.fit(X
|
75
|
+
rf.fit(X_train[X_vars], y_train[Y_vars])
|
76
76
|
|
77
77
|
|
78
78
|
|
3
.
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,6 +19,38 @@
|
|
19
19
|
|
20
20
|
|
21
21
|
```ここに言語を入力
|
22
|
+
|
23
|
+
dataset['date_year'] = dataset['ds'].apply(dataset_str2year)
|
24
|
+
|
25
|
+
dataset['date_month'] = dataset['ds'].apply(dataset_str2month)
|
26
|
+
|
27
|
+
dataset.iloc[0:9][['date_year', 'date_month']
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
target_col = 'y'
|
32
|
+
|
33
|
+
exclude_cols = ['y','ds','date_year']
|
34
|
+
|
35
|
+
feature_cols = []
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
for col in dataset.columns:
|
40
|
+
|
41
|
+
if col not in exclude_cols:
|
42
|
+
|
43
|
+
feature_cols.append(col)
|
44
|
+
|
45
|
+
feature_cols
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
y = dataset[target_col]
|
50
|
+
|
51
|
+
X = dataset[feature_cols]
|
52
|
+
|
53
|
+
|
22
54
|
|
23
55
|
# 学習データを70%(X_train[X_vars]_val, y_train[Y_vars]_val)、テストデータを30%(X_test, y_test)に分割
|
24
56
|
|
2
.
test
CHANGED
File without changes
|
test
CHANGED
@@ -90,7 +90,7 @@
|
|
90
90
|
|
91
91
|
print('Random Forest RMSE: ', np.sqrt(rf_mse))
|
92
92
|
|
93
|
-
|
93
|
+
|
94
94
|
|
95
95
|
---------------------------------------------------------------------------
|
96
96
|
|
1
エラーを追記しました。エラー箇所は一番最後に出ています。
test
CHANGED
File without changes
|
test
CHANGED
@@ -90,4 +90,28 @@
|
|
90
90
|
|
91
91
|
print('Random Forest RMSE: ', np.sqrt(rf_mse))
|
92
92
|
|
93
|
+
``````ここに言語を入力
|
94
|
+
|
95
|
+
---------------------------------------------------------------------------
|
96
|
+
|
97
|
+
NameError Traceback (most recent call last)
|
98
|
+
|
99
|
+
<ipython-input-53-76f91fadb21b> in <module>
|
100
|
+
|
101
|
+
1 rf = RandomForestRegressor(random_state=1234)
|
102
|
+
|
103
|
+
----> 2 rf.fit(X_train[X_vars], y_train[Y_vars])
|
104
|
+
|
105
|
+
3
|
106
|
+
|
107
|
+
4 for fday in pred["ds"]:
|
108
|
+
|
109
|
+
5 idx = pred[pred["ds"] == fday].index[0]
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
NameError: name 'X_vars' is not defined
|
114
|
+
|
115
|
+
|
116
|
+
|
93
117
|
```
|