optuna.cli

The cli module implements Optuna’s command-line functionality using the cliff framework.

See also

The Command-Line Interface tutorial provides use-cases with examples.

optuna
    [--version]
    [-v | -q]
    [--log-file LOG_FILE]
    [--debug]
    [--storage STORAGE]
--version

show program’s version number and exit

-v, --verbose

Increase verbosity of output. Can be repeated.

-q, --quiet

Suppress output except warnings and errors.

--log-file <LOG_FILE>

Specify a file to log output. Disabled by default.

--debug

Show tracebacks on errors.

--storage <STORAGE>

DB URL. (e.g. sqlite:///example.db)

ask

Create a new trial and suggest parameters.

optuna ask
    [--study-name STUDY_NAME]
    [--direction {minimize,maximize}]
    [--directions {minimize,maximize} [{minimize,maximize} ...]]
    [--sampler SAMPLER]
    [--sampler-kwargs SAMPLER_KWARGS]
    [--search-space SEARCH_SPACE]
    [-f {json,table,yaml}]
    [--flatten]
--study-name <STUDY_NAME>

Name of study.

--direction <DIRECTION>

Direction of optimization. This argument is deprecated. Please create a study in advance.

--directions <DIRECTIONS>

Directions of optimization, if there are multiple objectives. This argument is deprecated. Please create a study in advance.

--sampler <SAMPLER>

Class name of sampler object to create.

--sampler-kwargs <SAMPLER_KWARGS>

Sampler object initialization keyword arguments as JSON.

--search-space <SEARCH_SPACE>

Search space as JSON. Keys are names and values are outputs from distribution_to_json().

-f <FORMAT>, --format <FORMAT>

Output format.

--flatten

Flatten nested columns such as params.

This command is provided by the optuna plugin.

best-trial

Show the best trial.

optuna best-trial
    --study-name STUDY_NAME
    [-f {json,table,yaml}]
    [--flatten]
--study-name <STUDY_NAME>

The name of the study to get the best trial.

-f <FORMAT>, --format <FORMAT>

Output format.

--flatten

Flatten nested columns such as params and user_attrs.

This command is provided by the optuna plugin.

best-trials

Show a list of trials located at the Pareto front.

optuna best-trials
    --study-name STUDY_NAME
    [-f {json,table,yaml}]
    [--flatten]
--study-name <STUDY_NAME>

The name of the study to get the best trials (trials at the Pareto front).

-f <FORMAT>, --format <FORMAT>

Output format.

--flatten

Flatten nested columns such as params and user_attrs.

This command is provided by the optuna plugin.

create-study

Create a new study.

optuna create-study
    [--study-name STUDY_NAME]
    [--direction {minimize,maximize}]
    [--skip-if-exists]
    [--directions {minimize,maximize} [{minimize,maximize} ...]]
--study-name <STUDY_NAME>

A human-readable name of a study to distinguish it from others.

--direction <DIRECTION>

Set direction of optimization to a new study. Set ‘minimize’ for minimization and ‘maximize’ for maximization.

--skip-if-exists

If specified, the creation of the study is skipped without any error when the study name is duplicated.

--directions <DIRECTIONS>

Set directions of optimization to a new study. Put whitespace between directions. Each direction should be either “minimize” or “maximize”.

This command is provided by the optuna plugin.

delete-study

Delete a specified study.

optuna delete-study [--study-name STUDY_NAME]
--study-name <STUDY_NAME>

The name of the study to delete.

This command is provided by the optuna plugin.

storage upgrade

Upgrade the schema of a storage.

optuna storage upgrade

This command is provided by the optuna plugin.

studies

Show a list of studies.

optuna studies [-f {json,table,yaml}] [--flatten]
-f <FORMAT>, --format <FORMAT>

Output format.

--flatten

Flatten nested columns such as directions.

This command is provided by the optuna plugin.

study optimize

Start optimization of a study. Deprecated since version 2.0.0.

optuna study optimize
    [--n-trials N_TRIALS]
    [--timeout TIMEOUT]
    [--n-jobs N_JOBS]
    [--study STUDY]
    [--study-name STUDY_NAME]
    file
    method
--n-trials <N_TRIALS>

The number of trials. If this argument is not given, as many trials run as possible.

--timeout <TIMEOUT>

Stop study after the given number of second(s). If this argument is not given, as many trials run as possible.

--n-jobs <N_JOBS>

The number of parallel jobs. If this argument is set to -1, the number is set to CPU counts.

--study <STUDY>

This argument is deprecated. Use –study-name instead.

--study-name <STUDY_NAME>

The name of the study to start optimization on.

file

Python script file where the objective function resides.

method

The method name of the objective function.

This command is provided by the optuna plugin.

study set-user-attr

Set a user attribute to a study.

optuna study set-user-attr
    [--study STUDY]
    [--study-name STUDY_NAME]
    --key KEY
    --value VALUE
--study <STUDY>

This argument is deprecated. Use –study-name instead.

--study-name <STUDY_NAME>

The name of the study to set the user attribute to.

--key <KEY>, -k <KEY>

Key of the user attribute.

--value <VALUE>

Value to be set.

This command is provided by the optuna plugin.

tell

Finish a trial, which was created by the ask command.

optuna tell
    [--study-name STUDY_NAME]
    [--trial-number TRIAL_NUMBER]
    [--values VALUES [VALUES ...]]
    [--state {complete,pruned,fail}]
    [--skip-if-finished]
--study-name <STUDY_NAME>

Name of study.

--trial-number <TRIAL_NUMBER>

Trial number.

--values <VALUES>

Objective values.

--state <STATE>

Trial state.

--skip-if-finished

If specified, tell is skipped without any error when the trial is alreadyfinished.

This command is provided by the optuna plugin.

trials

Show a list of trials.

optuna trials
    --study-name STUDY_NAME
    [-f {json,table,yaml}]
    [--flatten]
--study-name <STUDY_NAME>

The name of the study which includes trials.

-f <FORMAT>, --format <FORMAT>

Output format.

--flatten

Flatten nested columns such as params and user_attrs.

This command is provided by the optuna plugin.