0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

sklearn.exceptions.NotFittedError: Estimator not fitted, call fit before exploiting the model.

Posted at

LGBMNotFittedErrorが出た

何が起きて何をしたか

Google Colabで学習させたLightGBMのモデルをpickleし、別の環境でunpickleしてpredictしようとしたところ以下のエラーが出た。

Traceback (most recent call last):
  File "/usr/local/bin/rank_strings", line 8, in <module>
    sys.exit(argmain())
  File "/usr/local/lib/python3.8/site-packages/stringsifter/rank_strings.py", line 140, in argmain
    main(args.input_strings, args.limit, args.min_score,
  File "/usr/local/lib/python3.8/site-packages/stringsifter/rank_strings.py", line 39, in main
    y_pred = model.predict(X_test)
  File "/usr/local/lib/python3.8/site-packages/lightgbm/sklearn.py", line 795, in predict
    raise LGBMNotFittedError("Estimator not fitted, call fit before exploiting the model.")
sklearn.exceptions.NotFittedError: Estimator not fitted, call fit before exploiting the model.

原因はGoogle Colabの学習したLightGBMのバージョンと、実行環境のLightGBMのバージョンが異なっていたためだった。Google ColabでLightGBMのバージョンを最新に更新し、改めてモデルを作成しなおしたところ解決。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?