optuna.multi_objective.study.MultiObjectiveStudy¶
- class optuna.multi_objective.study.MultiObjectiveStudy(study: optuna.study.Study)[source]¶
A study corresponds to a multi-objective optimization task, i.e., a set of trials.
This object provides interfaces to run a new
Trial
, access trials’ history, set/get user-defined attributes of the study itself.Note that the direct use of this constructor is not recommended. To create and load a study, please refer to the documentation of
create_study()
andload_study()
respectively.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__(study: optuna.study.Study)[source]¶
Methods
__init__
(study)enqueue_trial
(params)Enqueue a trial with given parameter values.
Return trials located at the pareto front in the study.
get_trials
([deepcopy])Return all trials in the study.
optimize
(objective[, timeout, n_trials, ...])Optimize an objective function.
set_system_attr
(key, value)Set a system attribute to the study.
set_user_attr
(key, value)Set a user attribute to the study.
Attributes
Return the optimization direction list.
Return the number of objectives.
Return the sampler.
Return system attributes.
Return all trials in the study.
Return user attributes.
- property directions: List[optuna._study_direction.StudyDirection]¶
Return the optimization direction list.
- Returns
A list that contains the optimization direction for each objective value.
- enqueue_trial(params: Dict[str, Any]) None [source]¶
Enqueue a trial with given parameter values.
You can fix the next sampling parameters which will be evaluated in your objective function.
Please refer to the documentation of
optuna.study.Study.enqueue_trial()
for further details.- Parameters
params – Parameter values to pass your objective function.
- get_pareto_front_trials() List[optuna.multi_objective.trial.FrozenMultiObjectiveTrial] [source]¶
Return trials located at the pareto front in the study.
A trial is located at the pareto front if there are no trials that dominate the trial. It’s called that a trial
t0
dominates another trialt1
ifall(v0 <= v1) for v0, v1 in zip(t0.values, t1.values)
andany(v0 < v1) for v0, v1 in zip(t0.values, t1.values)
are held.- Returns
A list of
FrozenMultiObjectiveTrial
objects.
- get_trials(deepcopy: bool = True) List[optuna.multi_objective.trial.FrozenMultiObjectiveTrial] [source]¶
Return all trials in the study.
The returned trials are ordered by trial number.
For library users, it’s recommended to use more handy
trials
property to get the trials instead.- Parameters
deepcopy – Flag to control whether to apply
copy.deepcopy()
to the trials. Note that if you set the flag toFalse
, you shouldn’t mutate any fields of the returned trial. Otherwise the internal state of the study may corrupt and unexpected behavior may happen.- Returns
A list of
FrozenMultiObjectiveTrial
objects.
- optimize(objective: Callable[[optuna.multi_objective.trial.MultiObjectiveTrial], Sequence[float]], timeout: Optional[int] = None, n_trials: Optional[int] = None, n_jobs: int = 1, catch: Tuple[Type[Exception], ...] = (), callbacks: Optional[List[Callable[[optuna.multi_objective.study.MultiObjectiveStudy, optuna.multi_objective.trial.FrozenMultiObjectiveTrial], None]]] = None, gc_after_trial: bool = True, show_progress_bar: bool = False) None [source]¶
Optimize an objective function.
This method is the same as
optuna.study.Study.optimize()
except for taking an objective function that returns multi-objective values as the argument.Please refer to the documentation of
optuna.study.Study.optimize()
for further details.
- property sampler: optuna.multi_objective.samplers._base.BaseMultiObjectiveSampler¶
Return the sampler.
- Returns
A
BaseMultiObjectiveSampler
object.
- set_system_attr(key: str, value: Any) None [source]¶
Set a system attribute to the study.
Note that Optuna internally uses this method to save system messages. Please use
set_user_attr()
to set users’ attributes.- Parameters
key – A key string of the attribute.
value – A value of the attribute. The value should be JSON serializable.
- set_user_attr(key: str, value: Any) None [source]¶
Set a user attribute to the study.
- Parameters
key – A key string of the attribute.
value – A value of the attribute. The value should be JSON serializable.
- property system_attrs: Dict[str, Any]¶
Return system attributes.
- Returns
A dictionary containing all system attributes.
- property trials: List[optuna.multi_objective.trial.FrozenMultiObjectiveTrial]¶
Return all trials in the study.
The returned trials are ordered by trial number.
This is a short form of
self.get_trials(deepcopy=True)
.- Returns
A list of
FrozenMultiObjectiveTrial
objects.