Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix is_optimal sometimes being used for y_metric_name #2849

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions ax/analysis/plotly/scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def compute(
fig = _prepare_plot(
df=df,
x_metric_name=self.x_metric_name,
y_metric_name=self.y_metric_name,
show_pareto_frontier=self.show_pareto_frontier,
x_lower_is_better=experiment.metrics[self.x_metric_name].lower_is_better
or False,
Expand Down Expand Up @@ -140,8 +141,9 @@ def is_optimal(row: pd.Series) -> bool:
def _prepare_plot(
df: pd.DataFrame,
x_metric_name: str,
x_lower_is_better: bool,
y_metric_name: str,
show_pareto_frontier: bool,
x_lower_is_better: bool,
) -> go.Figure:
"""
Prepare a scatter plot for the given DataFrame.
Expand All @@ -154,16 +156,12 @@ def _prepare_plot(
- Y_METRIC_NAME: The observed mean of the metric to plot on the y-axis
- is_optimal: Whether the arm is on the Pareto frontier (this can be
omitted if show_pareto_frontier=False)
x_metric_name: The name of the metric to plot on the x-axis (the other metric
will be plotted on the y-axis)
x_metric_name: The name of the metric to plot on the x-axis
y_metric_name: The name of the metric to plot on the y-axis
show_pareto_frontier: Whether to draw the Pareto frontier for the two metrics
x_lower_is_better: Whether the metric on the x-axis is being minimized (only
relevant if show_pareto_frontier=True)
show_pareto_frontier: Whether to draw the Pareto frontier for the two metrics

"""
# Infer y metric name based on expected columns
y_metric_name = ({*df.columns} - {x_metric_name, "trial_index", "arm_name"}).pop()

fig = px.scatter(
df,
x=x_metric_name,
Expand Down