- optuna.create_study(*, storage=None, sampler=None, pruner=None, study_name=None, direction=None, load_if_exists=False, directions=None)
Create a new
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)
Database URL. If this argument is set to None, in-memory storage is used, and the
Studywill not be persistent.
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
RDBStoragewith your desired options and pass it to the
storageargument instead of a URL.
sampler (Optional[BaseSampler]) – A sampler object that implements background algorithm for value suggestion. If
TPESampleris used during single-objective optimization and
NSGAIISamplerduring multi-objective optimization. See also
Direction of optimization. Set
minimizefor minimization and
maximizefor maximization. You can also pass the corresponding
directionsmust not be specified at the same time.
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_namealready exists in the
DuplicatedStudyErroris raised if
load_if_existsis set to
False. Otherwise, the creation of the study is skipped, and the existing one is returned.
- Return type
The Saving/Resuming Study with RDB Backend tutorial provides concrete examples to save and resume optimization using RDB.