I am trying to implement the methodology described here. The details except for the ones I will post here are irrelevant to the scope of the question
- The intent is to implement hyperparameter tuning for lightgbm
- I do it the typical way - import lightgbm via
import lightgbm
, write a class that does it for me - There is a special way to do hyperparameter optimization for lightgbm and that requires me to import lightgbm like
from optuna.integration import lightgbm
and the rest of the code can remain identical - I want to provide the end users the capability to choose between the vanilla methodology (in point 2) or the special methodology (point 3). To implement that I have the following in the
__init__
of the main class and the__init__
takes and argumentuse_lightgbm_heuristics=True
global lightgbm
if use_lightgbm_heuristics:
print("will be using heuristics")
from optuna.integration import lightgbm
else:
print("will be using vanilla lgbm")
import lightgbm
There is an import statement in the main class of my code. Can I do better?
Aucun commentaire:
Enregistrer un commentaire