Python

Python

LightGBMでCannot use Dataset instance for prediction, please use raw data instead

LightGBMで2値分類の学習をさせていた際、表題のエラー。 import lightgbm as lgb lgb_train = lgb.Dataset(X_train, label=y_train) lgb_eval = lgb.Da...
Python

sklearnのlog_lossでValueError: y_true contains only one label (0).

2値分類タスクでKfold分割してloglossを計算した時にエラー。 from sklearn.metrics import log_loss loss = log_loss(y_valdation, oof_prediction) Va...
Python

Macのpyenvでconfigure: error: C compiler cannot create executables

Macでpyenv installしようとしたところ表題のエラー。 % pyenv install 3.8.4 python-build: use openssl@1.1 from homebrew python-build: use re...
Python

Pythonのitertoolsで順列や組合せを重複あり・なしで全列挙する

順列や組合せを求めたいときに、ネストしたループを組むと可読性が低いしネストの回数が変わるとコードの保守も面倒くさい。 itertoolsを使えば、読みやすいコードで全列挙を簡単にしてくれる。 組合せイテレータは全部で4種類。 abcという文...
Python

pip installでpermission deniedが出てsudoや–userでも上手く行かない

pip installした時にpermission deniedが起きた。 --userフラグを使うと上手くいくらしい。 pip install hogehoge --user が、またpermission denied. 安直にsudoを...
Python

LightGBMでAttributeError: ‘LGBMRegressor’ object has no attribute ‘feature_name_’

LightGBMを使っていると表題のエラー。 feature_name_属性がないと怒られる。 最新のmasterブランチにこの属性は含まれていないようで、nightlyビルドを使ってみたらエラーは出なくなった。 feature_name_...
Python

scikit-leranのKerasClassifierでValueError: The estimator KerasClassifier should be a classifier.

scikit-learnのStackingClassifierでKerasClassifierを使った時に表題のエラー。 ValueError: The estimator KerasClassifier should be a class...
Python

MacのLightGBMでエラー image not found

MacOS 10.15.5 LightGBMを使いたくなったのでpipでインストールしたら表題のエラー。 公式ドキュメントを見てみる。 On macOS LightGBM can be installed using Homebrew, o...
Python

PythonでFunction nameをStringで取り出す

Tensorflowで複数モデルをループさせて色々な学習をさせていた時、今なんのモデルを学習しているのかprintしたくなった。 単純にprintしてみたところ、以下のような出力になった。 print(EfficientNetB0) > <...
Python

tkinterで’PhotoImage’ object has no attribute ‘_PhotoImage__photo’

tkinterでjpgを表示しようとした時に表題のエラー。 image = Image.open(image_path) image = ImageTk.PhotoImage(file=image) AttributeError: 'Pho...