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)[source]¶ Create a new
Study
.Example
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)
- Parameters
storage (Optional[Union[str, optuna.storages._base.BaseStorage]]) –
Database URL. If this argument is set to None, in-memory storage is used, and the
Study
will not be persistent.Note
When a database URL is passed, Optuna internally uses SQLAlchemy to handle the database. Please refer to SQLAlchemy’s document for further details. If you want to specify non-default options to SQLAlchemy Engine, you can instantiate
RDBStorage
with your desired options and pass it to thestorage
argument instead of a URL.sampler (Optional[optuna.samplers._base.BaseSampler]) – A sampler object that implements background algorithm for value suggestion. If
None
is specified,TPESampler
is used during single-objective optimization andNSGAIISampler
during multi-objective optimization. See alsosamplers
.pruner (Optional[optuna.pruners._base.BasePruner]) – A pruner object that decides early stopping of unpromising trials. If
None
is specified,MedianPruner
is used as the default. See alsopruners
.study_name (Optional[str]) – Study’s name. If this argument is set to None, a unique name is generated automatically.
direction (Optional[Union[str, optuna.study._study_direction.StudyDirection]]) –
Direction of optimization. Set
minimize
for minimization andmaximize
for maximization. You can also pass the correspondingStudyDirection
object.Note
If none of direction and directions are specified, the direction of the study is set to “minimize”.
load_if_exists (bool) – Flag to control the behavior to handle a conflict of study names. In the case where a study named
study_name
already exists in thestorage
, aDuplicatedStudyError
is raised ifload_if_exists
is set toFalse
. Otherwise, the creation of the study is skipped, and the existing one is returned.directions (Optional[Sequence[Union[str, optuna.study._study_direction.StudyDirection]]]) – A sequence of directions during multi-objective optimization.
- Returns
A
Study
object.- Raises
ValueError – If the length of
directions
is zero. Or, ifdirection
is neither ‘minimize’ nor ‘maximize’ when it is a string. Or, if the element ofdirections
is neither minimize nor maximize. Or, if bothdirection
anddirections
are specified.- Return type
optuna.study.study.Study
See also
optuna.create_study()
is an alias ofoptuna.study.create_study()
.