Trial

class optuna.multi_objective.trial.MultiObjectiveTrial(trial: optuna.trial._trial.Trial)[source]

A trial is a process of evaluating an objective function.

This object is passed to an objective function and provides interfaces to get parameter suggestion, manage the trial’s state, and set/get user-defined attributes of the trial.

Note that the direct use of this constructor is not recommended. This object is seamlessly instantiated and passed to the objective function behind the optuna.multi_objective.study.MultiObjectiveStudy.optimize() method; hence library users do not care about instantiation of this object.

Parameters

trial – A Trial object.

Note

Added in v1.4.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v1.4.0.

property datetime_start

Return start datetime.

Returns

Datetime where the Trial started.

property distributions

Return distributions of parameters to be optimized.

Returns

A dictionary containing all distributions.

property number

Return trial’s number which is consecutive and unique in a study.

Returns

A trial number.

property params

Return parameters to be optimized.

Returns

A dictionary containing all parameters.

report(values: Tuple[float], step: int)None[source]

Report intermediate objective function values for a given step.

The reported values are used by the pruners to determine whether this trial should be pruned.

See also

Please refer to BasePruner.

Note

The reported values are converted to float type by applying float() function internally. Thus, it accepts all float-like types (e.g., numpy.float32). If the conversion fails, a TypeError is raised.

Parameters
  • values – Intermediate objective function values for a given step.

  • step – Step of the trial (e.g., Epoch of neural network training).

set_user_attr(key: str, value: Any)None[source]

Set user attributes to the trial.

Please refer to the documentation of optuna.trial.Trial.set_user_attr() for further details.

suggest_categorical(name: str, choices: Sequence[Union[None, bool, int, float, str]]) → Union[None, bool, int, float, str][source]

Suggest a value for the categorical parameter.

Please refer to the documentation of optuna.trial.Trial.suggest_categorical() for further details.

suggest_discrete_uniform(name: str, low: float, high: float, q: float)float[source]

Suggest a value for the discrete parameter.

Please refer to the documentation of optuna.trial.Trial.suggest_discrete_uniform() for further details.

suggest_float(name: str, low: float, high: float, *, step: Optional[float] = None, log: bool = False)float[source]

Suggest a value for the floating point parameter.

Please refer to the documentation of optuna.trial.Trial.suggest_float() for further details.

suggest_int(name: str, low: int, high: int, step: int = 1, log: bool = False)int[source]

Suggest a value for the integer parameter.

Please refer to the documentation of optuna.trial.Trial.suggest_int() for further details.

suggest_loguniform(name: str, low: float, high: float)float[source]

Suggest a value for the continuous parameter.

Please refer to the documentation of optuna.trial.Trial.suggest_loguniform() for further details.

suggest_uniform(name: str, low: float, high: float)float[source]

Suggest a value for the continuous parameter.

Please refer to the documentation of optuna.trial.Trial.suggest_uniform() for further details.

property user_attrs

Return user attributes.

Returns

A dictionary containing all user attributes.

class optuna.multi_objective.trial.FrozenMultiObjectiveTrial(n_objectives: int, trial: optuna.trial._frozen.FrozenTrial)[source]

Status and results of a MultiObjectiveTrial.

number

Unique and consecutive number of MultiObjectiveTrial for each MultiObjectiveStudy. Note that this field uses zero-based numbering.

state

TrialState of the MultiObjectiveTrial.

values

Objective values of the MultiObjectiveTrial.

datetime_start

Datetime where the MultiObjectiveTrial started.

datetime_complete

Datetime where the MultiObjectiveTrial finished.

params

Dictionary that contains suggested parameters.

distributions

Dictionary that contains the distributions of params.

user_attrs

Dictionary that contains the attributes of the MultiObjectiveTrial set with optuna.multi_objective.trial.MultiObjectiveTrial.set_user_attr().

intermediate_values

Intermediate objective values set with optuna.multi_objective.trial.MultiObjectiveTrial.report().

Note

Added in v1.4.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v1.4.0.