def _get_observation_pairs( study: optuna.study.Study, param_name: str, ) -> Tuple[List[Optional[float]], List[List[float]]]: """Get observation pairs from the study. This function collects observation pairs from the complete trials of the study. Pruning is currently not supported. The values for trials that don't contain the parameter named ``param_name`` are set to None. Objective values are negated if their directions are maximization and all objectives are treated as minimization in the MOTPE algorithm. """ trials = study.get_trials(deepcopy=False, states=(optuna.trial.TrialState.COMPLETE,)) values = [] scores = [] for trial in trials: param_value = None # type: Optional[float] if param_name in trial.params: distribution = trial.distributions[param_name] param_value = distribution.to_internal_repr(trial.params[param_name]) # Convert all objectives to minimization score = [ cast(float, v) if d == StudyDirection.MINIMIZE else -cast(float, v) for d, v in zip(study.directions, trial.values) ] values.append(param_value) scores.append(score) return values, scores
def _should_log_plots(self, study: optuna.study.Study, trial: optuna.trial.FrozenTrial): if not len(study.get_trials(states=(optuna.trial.TrialState.COMPLETE,))): return False elif self._plots_update_freq == 'never': return False else: if trial._trial_id % self._plots_update_freq == 0: return True return False