def take_action(self, parsed_args: Namespace) -> None: warnings.warn( "'best-trials' is an experimental CLI command. The interface can change in the " "future.", ExperimentalWarning, ) storage_url = _check_storage_url(self.app_args.storage) study = optuna.load_study(storage=storage_url, study_name=parsed_args.study_name) best_trials = [trial.number for trial in study.best_trials] attrs = ( "number", "value" if not study._is_multi_objective() else "values", "datetime_start", "datetime_complete", "duration", "params", "user_attrs", "state", ) records, columns = _dataframe._create_records_and_aggregate_column( study, attrs) best_records = list( filter(lambda record: record[("number", "")] in best_trials, records)) print( _format_output(best_records, columns, parsed_args.format, parsed_args.flatten))
def take_action( self, parsed_args: Namespace ) -> Tuple[List[str], List[List[Union[int, float, str]]]]: warnings.warn( "'best-trials' is an experimental CLI command. The interface can change in the " "future.", ExperimentalWarning, ) storage_url = _check_storage_url(self.app_args.storage) study = optuna.load_study(storage=storage_url, study_name=parsed_args.study_name) best_trials = [trial.number for trial in study.best_trials] attrs = ( "number", "value" if not study._is_multi_objective() else "values", "datetime_start", "datetime_complete", "duration", "params", "user_attrs", "state", ) records, columns = _dataframe._create_records_and_aggregate_column( study, attrs) best_records = filter( lambda record: record[("number", "")] in best_trials, records) list_of_trial_values = [ _format_trial_values(record, columns) for record in best_records ] return _dataframe._flatten_columns(columns), list_of_trial_values