optuna.study.create_study
- optuna.study.create_study(*, storage=None, sampler=None, pruner=None, study_name=None, direction=None, load_if_exists=False, directions=None)[源代码]
创建一个新的
Study。示例
import optuna def objective(trial): x = trial.suggest_float("x", 0, 10) return x**2 study = optuna.create_study() study.optimize(objective, n_trials=3)
- 参数:
storage (str | storages.BaseStorage | None) – 数据库 URL。如果此参数设置为 None,则使用内存存储,并且
Study将不会持久化。 .. 注意:: 当传递数据库 URL 时,Optuna 内部使用 SQLAlchemy 来处理数据库。请参考 SQLAlchemy 的文档 以获取更多详细信息。 如果你想为 SQLAlchemy 引擎 指定非默认选项,你可以使用你想要的选项实例化RDBStorage,并将其传递给storage参数,而不是 URL。 .. _SQLAlchemy: https://www.sqlalchemy.org/ .. _SQLAlchemy 的文档: https://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls .. _SQLAlchemy 引擎: https://docs.sqlalchemy.org/en/latest/core/engines.htmlsampler ('samplers.BaseSampler' | None) – A sampler object that implements background algorithm for value suggestion. If
Noneis specified,TPESampleris used during single-objective optimization andNSGAIISamplerduring multi-objective optimization. See alsosamplers.pruner (pruners.BasePruner | None) – A pruner object that decides early stopping of unpromising trials. If
Noneis specified,MedianPruneris used as the default. See alsopruners.study_name (str | None) – 研究名称。如果此参数设置为 None,则会自动生成一个唯一的名称。
direction (str | StudyDirection | None) – 优化方向。设置
minimize进行最小化,设置maximize进行最大化。你也可以传递相应的StudyDirection对象。direction和directions不能同时指定。 .. note:load_if_exists (bool) – Flag to control the behavior to handle a conflict of study names. In the case where a study named
study_namealready exists in thestorage, aDuplicatedStudyErroris raised ifload_if_existsis set toFalse. Otherwise, the creation of the study is skipped, and the existing one is returned.directions (Sequence[str | StudyDirection] | None) – 多目标优化过程中的方向序列。
direction和directions不能同时指定。
- 返回:
一个
Study对象。- 返回类型:
参见
The 使用RDB后端保存/恢复学习 tutorial provides concrete examples to save and resume optimization using RDB.