質問するログイン新規登録

質問編集履歴

3

コード編集

2020/11/13 05:10

投稿

yyy-
yyy-

スコア4

title CHANGED
File without changes
body CHANGED
@@ -89,10 +89,10 @@
89
89
  # autoscaling
90
90
  if do_autoscaling:
91
91
  autoscaled_x_train_pre = (x_train - x_train.mean(axis=0)) / x_train.std(axis=0, ddof=1)
92
- autoscaled_x_train =np.insert(autoscaled_x_train_pre, x2_train)
92
+ autoscaled_x_train =np.concatenate([autoscaled_x_train_pre, x2_train],axis=1)
93
93
  autoscaled_y_train = (y_train - y_train.mean()) / y_train.std(ddof=1)
94
94
  autoscaled_x_test_pre = (x_test - x_train.mean(axis=0)) / x_train.std(axis=0, ddof=1)
95
- autoscaled_x_train =np.append([autoscaled_x_test_pre, x2_test], axis=1)
95
+ autoscaled_x_train =np.concatenate([[autoscaled_x_test_pre], [x2_test]], axis=1)
96
96
  else:
97
97
  autoscaled_x_train = x_train.copy()
98
98
  autoscaled_y_train = y_train.copy()
@@ -135,23 +135,22 @@
135
135
  ```
136
136
 
137
137
  エラー:
138
- TypeError Traceback (most recent call last)
138
+ ValueError Traceback (most recent call last)
139
- <ipython-input-33-e0eb315c7c97> in <module>
139
+ <ipython-input-40-de7659de5d58> in <module>
140
140
  99 # DCV
141
141
  100 inner_cv = GridSearchCV(svm.SVR(), parameters, scoring = 'max_error', n_jobs = -1, cv = inner_fold_number)
142
142
  --> 101 y_pred = double_cross_validation(gs_cv=inner_cv, x=x, x2 =x2, y=y, outer_fold_number=outer_fold_number, do_autoscaling=True, random_state=0)
143
143
  102
144
144
  103 # 汎化性能 from DCV using SVR
145
145
 
146
- <ipython-input-33-e0eb315c7c97> in double_cross_validation(gs_cv, x, x2, y, outer_fold_number, do_autoscaling, random_state)
146
+ <ipython-input-40-de7659de5d58> in double_cross_validation(gs_cv, x, x2, y, outer_fold_number, do_autoscaling, random_state)
147
- 63 if do_autoscaling:
148
- 64 autoscaled_x_train_pre = (x_train - x_train.mean(axis=0)) / x_train.std(axis=0, ddof=1)
149
- ---> 65 autoscaled_x_train =np.insert(autoscaled_x_train_pre, x2_train)
150
147
  66 autoscaled_y_train = (y_train - y_train.mean()) / y_train.std(ddof=1)
151
148
  67 autoscaled_x_test_pre = (x_test - x_train.mean(axis=0)) / x_train.std(axis=0, ddof=1)
149
+ ---> 68 autoscaled_x_train =np.concatenate([[autoscaled_x_test_pre], [x2_test]], axis=1)
150
+ 69 else:
151
+ 70 autoscaled_x_train = x_train.copy()
152
152
 
153
- TypeError: insert() missing 1 required positional argument: 'values'
153
+ ValueError: all the input array dimensions except for the concatenation axis must match exactly
154
-
155
154
  よろしくお願いします。
156
155
 
157
156
  ![![イメージ説明](67b6071399bcd616340be0b24c608851.jpeg)](76b8eeb2cfb84fe71c8d4025542ffe90.jpeg)

2

写真の追加

2020/11/13 05:10

投稿

yyy-
yyy-

スコア4

title CHANGED
File without changes
body CHANGED
@@ -154,4 +154,5 @@
154
154
 
155
155
  よろしくお願いします。
156
156
 
157
- ![![イメージ説明](67b6071399bcd616340be0b24c608851.jpeg)](76b8eeb2cfb84fe71c8d4025542ffe90.jpeg)
157
+ ![![イメージ説明](67b6071399bcd616340be0b24c608851.jpeg)](76b8eeb2cfb84fe71c8d4025542ffe90.jpeg)
158
+ ![イメージ説明](dac26fe0337e7c15f4fa79976cb16f35.jpeg)

1

写真の追加

2020/11/13 05:00

投稿

yyy-
yyy-

スコア4

title CHANGED
File without changes
body CHANGED
@@ -152,4 +152,6 @@
152
152
 
153
153
  TypeError: insert() missing 1 required positional argument: 'values'
154
154
 
155
- よろしくお願いします。
155
+ よろしくお願いします。
156
+
157
+ ![![イメージ説明](67b6071399bcd616340be0b24c608851.jpeg)](76b8eeb2cfb84fe71c8d4025542ffe90.jpeg)