Fix a bug of HyperparameterImportance when given no trials

This commit is contained in:
c-bata
2021-04-09 18:21:09 +09:00
parent 55eec2d4d7
commit ab5354328f
+7 -7
View File
@@ -221,16 +221,16 @@ def create_app(storage: BaseStorage) -> Bottle:
study = Study(study_name=study_name, storage=storage)
trials = [trial for trial in study.trials if trial.state == TrialState.COMPLETE]
if len(trials) == 0:
return ""
evaluator = None
params = None
target = None
importances = optuna.importance.get_param_importances(
study, evaluator=evaluator, params=params, target=target
)
if target is None:
target_name = "Objective Value"
if len(trials) > 0:
importances = optuna.importance.get_param_importances(
study, evaluator=evaluator, params=params, target=target
)
else:
importances = {}
target_name = "Objective Value"
return {
"target_name": target_name,