optunaのlightGBMを実行時にエラーが発生します.
以下の最後のlgb.LightGBMTunerCV実行時に
'set' object has no attribute 'startswith'
というエラーが発生してしまします.ここではcross validationを使用していますが,通常の学習でも同様のエラーが発生しました.
最初はlgb_train
の作成の仕方が悪いのかと疑いました.
しかし,optunaではなく本来のlightGBMモジュールを使用し同様に作成したデータを使用した際にはエラーは発生しませんでした.
どなたか理由のわかるかたお願いいたします.
Python
1import optuna.integration.lightgbm as lgb 2from sklearn.model_selection import StratifiedKFold 3 4 5lgb_train = lgb.Dataset(train_val_X, train_val_y) 6lgb_test = lgb.Dataset(test_X, test_y, reference=lgb_train) 7 8folds = StratifiedKFold(n_splits=5, shuffle=True, random_state=42) 9 10 11params = {'boosting_type': 'gbdt', 12 'objective': 'multiclass', 13 'metric': {'multi_logloss'}, 14 'num_class': 6 15 } 16 17tuner_cv = lgb.LightGBMTunerCV(params, 18 lgb_train, 19 early_stopping_rounds=20, 20 verbose_eval=True, 21 folds=folds 22 )
エラーを全文載せておきます.
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-72-9371d79f08d8> in <module> 19 early_stopping_rounds=20, 20 verbose_eval=True, ---> 21 folds=folds 22 ) ~/OneDrive/research/lab_env/lib/python3.7/site-packages/optuna/_experimental.py in wrapped_init(self, *args, **kwargs) 84 ), 85 ExperimentalWarning, ---> 86 stacklevel=2, 87 ) 88 ~/OneDrive/research/lab_env/lib/python3.7/site-packages/optuna/integration/lightgbm_tuner/optimize.py in __init__(self, params, train_set, num_boost_round, folds, nfold, stratified, shuffle, fobj, feval, feature_name, categorical_feature, early_stopping_rounds, fpreproc, verbose_eval, show_stdv, seed, callbacks, time_budget, sample_size, study, optuna_callbacks, verbosity) ~/OneDrive/research/lab_env/lib/python3.7/site-packages/optuna/integration/lightgbm_tuner/optimize.py in __init__(self, params, train_set, num_boost_round, fobj, feval, feature_name, categorical_feature, early_stopping_rounds, verbose_eval, callbacks, time_budget, sample_size, study, optuna_callbacks, verbosity) ~/OneDrive/research/lab_env/lib/python3.7/site-packages/optuna/integration/lightgbm_tuner/optimize.py in higher_is_better(self) AttributeError: 'set' object has no attribute 'startswith'
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/08/16 15:04