optuna.get_all_study_summaries

optuna.get_all_study_summaries(storage, include_best_trial=True)[source]

获取存储在指定存储中的所有研究的历史记录。

示例

import optuna


def objective(trial):
    x = trial.suggest_float("x", -10, 10)
    return (x - 2) ** 2


study = optuna.create_study(study_name="example-study", storage="sqlite:///example.db")
study.optimize(objective, n_trials=3)

study_summaries = optuna.study.get_all_study_summaries(storage="sqlite:///example.db")
assert len(study_summaries) == 1

study_summary = study_summaries[0]
assert study_summary.study_name == "example-study"
参数:
  • storage (str | BaseStorage) – 数据库 URL,例如 sqlite:///example.db。有关更多详细信息,请参阅 create_study() 的文档。

  • include_best_trial (bool) – 如果存在,则包含最佳试验。这可能会增加查询次数,并且根据存储的不同,获取摘要可能需要更长时间。

返回值:

研究历史列表,汇总为 StudySummary 对象。

返回类型:

list[StudySummary]