optuna.study.get_all_study_summaries

optuna.study.get_all_study_summaries(storage, include_best_trial=True)[源代码]

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

示例

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]