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

質問編集履歴

2

コードとエラーコードを追加

2020/08/17 21:13

投稿

taitan38
taitan38

スコア0

title CHANGED
File without changes
body CHANGED
@@ -5,20 +5,44 @@
5
5
  有識者の方々、ご助力お願いいたします。
6
6
 
7
7
  ### **__発生している問題・エラーメッセージ__**
8
+ ---------------------------------------------------------------------------
9
+ TypeError Traceback (most recent call last)
10
+ <ipython-input-126-ccfa323308ad> in <module>
11
+ 17
12
+ 18 num_round = 10
13
+ **---> 19 bst = xgb.train(param_grid, dtrain, num_round)**
14
+ 20
15
+ 21
16
+
17
+ ~\Anaconda3\lib\site-packages\xgboost\training.py in train(params, dtrain, num_boost_round, evals, obj, feval, maximize, early_stopping_rounds, evals_result, verbose_eval, xgb_model, callbacks, learning_rates)
18
+ 214 evals=evals,
19
+ 215 obj=obj, feval=feval,
20
+ **--> 216 xgb_model=xgb_model, callbacks=callbacks)**
21
+ 217
22
+ 218
23
+
8
24
  ~\Anaconda3\lib\site-packages\xgboost\training.py in _train_internal(params, dtrain, num_boost_round, evals, obj, feval, xgb_model, callbacks)
9
25
  46 nboost //= num_parallel_tree
10
26
  47 if 'num_class' in _params:
11
- ---> 48 nboost //= _params['num_class']
27
+ **---> 48 nboost //= _params['num_class']**
12
28
  49
13
29
  50 # Distributed code: Load the checkpoint from rabit.
14
30
 
15
31
  **TypeError: unsupported operand type(s) for //=: 'int' and 'list'**
16
32
 
17
33
  ### **該当のソースコード**
34
+ dtrain = xgb.DMatrix(x_train, label=y_train)
35
+ dtest = xgb.DMatrix(x_test, label=y_test)
36
+
37
+
18
38
  param_grid = {
19
- 'max_depth': [0,1,3],
39
+ 'max_depth': [0,1,3],
20
40
  'gamma':[0,0.2,0.03],
21
41
  'booster':['gbtree'],
22
- 'objective':['multi:softmax'],
42
+ 'objective':['multi:softmax'],
23
43
  'num_class':[50],
24
- }
44
+ }
45
+
46
+ num_round = 10
47
+ bst = xgb.train(param_grid, dtrain, num_round)
48
+ xgb.plot_importance(bst)

1

表題の変更

2020/08/17 21:13

投稿

taitan38
taitan38

スコア0

title CHANGED
@@ -1,1 +1,1 @@
1
- XGBoost gredサーチのエラー回避
1
+ XGBoost gridサーチのエラー回避
body CHANGED
File without changes