Skip to content

Commit

Permalink
[python] Improve error message for plot_metric with Booster (#4709)
Browse files Browse the repository at this point in the history
* Improve error message for plot_metric with Booster

* Update error message
  • Loading branch information
js850 committed Oct 26, 2021
1 parent f497068 commit 1cc84b3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python-package/lightgbm/plotting.py
Expand Up @@ -342,6 +342,8 @@ def plot_metric(
eval_results = deepcopy(booster.evals_result_)
elif isinstance(booster, dict):
eval_results = deepcopy(booster)
elif isinstance(booster, Booster):
raise TypeError("booster must be dict or LGBMModel. To use plot_metric with Booster type, first record the metrics using record_evaluation callback then pass that to plot_metric as argument `booster`")
else:
raise TypeError('booster must be dict or LGBMModel.')

Expand Down

0 comments on commit 1cc84b3

Please sign in to comment.