def _get_objective_v_param_plot( search_space: SearchSpace, model: ModelBridge, metric_name: str, trials: Dict[int, BaseTrial], ) -> Optional[go.Figure]: range_params = list(search_space.range_parameters.keys()) if len(range_params) == 1: # individual parameter slice plot output_slice_plot = plot_slice_plotly( model=not_none(model), param_name=range_params[0], metric_name=metric_name, generator_runs_dict={ str(t.index): not_none(checked_cast(Trial, t).generator_run) for t in trials.values() }, ) return output_slice_plot if len(range_params) > 1: # contour plot output_contour_plot = interact_contour_plotly( model=not_none(model), metric_name=metric_name, ) return output_contour_plot # if search space contains no range params logger.warning( "_get_objective_v_param_plot requires a search space with at least one " "RangeParameter. Returning None." ) return None
def testSlices(self): exp = get_branin_experiment(with_batch=True) exp.trials[0].run() model = Models.BOTORCH( # Model bridge kwargs experiment=exp, data=exp.fetch_data(), ) # Assert that each type of plot can be constructed successfully plot = plot_slice_plotly(model, model.parameters[0], list(model.metric_names)[0]) self.assertIsInstance(plot, go.Figure) plot = interact_slice_plotly(model) self.assertIsInstance(plot, go.Figure) plot = plot_slice(model, model.parameters[0], list(model.metric_names)[0]) self.assertIsInstance(plot, AxPlotConfig) plot = interact_slice(model) self.assertIsInstance(plot, AxPlotConfig)