optuna.multi_objective.trial.MultiObjectiveTrial

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.

__init__(trial: optuna.trial._trial.Trial)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(trial)

Initialize self.

report(values, step)

Report intermediate objective function values for a given step.

set_system_attr(key, value)

Set system attributes to the trial.

set_user_attr(key, value)

Set user attributes to the trial.

suggest_categorical(name, choices)

Suggest a value for the categorical parameter.

suggest_discrete_uniform(name, low, high, q)

Suggest a value for the discrete parameter.

suggest_float(name, low, high, *[, step, log])

Suggest a value for the floating point parameter.

suggest_int(name, low, high[, step, log])

Suggest a value for the integer parameter.

suggest_loguniform(name, low, high)

Suggest a value for the continuous parameter.

suggest_uniform(name, low, high)

Suggest a value for the continuous parameter.

Attributes

datetime_start

Return start datetime.

distributions

Return distributions of parameters to be optimized.

number

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

params

Return parameters to be optimized.

system_attrs

Return system attributes.

user_attrs

Return user attributes.

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: Sequence[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_system_attr(key: str, value: Any)None[source]

Set system attributes to the trial.

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

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 system_attrs

Return system attributes.

Returns

A dictionary containing all system attributes.

property user_attrs

Return user attributes.

Returns

A dictionary containing all user attributes.