Skip to content

Commit

Permalink
Don't show constraint violations unless there are sems (#3212)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #3212

Reviewed By: lena-kashtelyan

Differential Revision: D67608494

fbshipit-source-id: f981081f527aa3ca41e6b391e2081e1e6f68a8e2
  • Loading branch information
Daniel Cohen authored and facebook-github-bot committed Dec 23, 2024
1 parent 2d375ab commit 15ff1dd
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions ax/analysis/plotly/arm_effects/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from typing import Any

import numpy as np

import pandas as pd
from ax.analysis.plotly.utils import (
format_constraint_violated_probabilities,
Expand Down Expand Up @@ -86,6 +88,7 @@ def prepare_arm_effects_plot(
# visible when there is a lower chance of constraint violation
f"rgba(255, 0, 0, {(alpha) ** .75})"
for alpha in df.loc[indices, "overall_probability_constraints_violated"]
if not np.isnan(alpha)
]
# Create a separate trace for the legend, otherwise the legend
# will have the constraint violation indicator of the first arm
Expand All @@ -106,20 +109,21 @@ def prepare_arm_effects_plot(
trace.showlegend = False

# Add an item to the legend for the constraint violation indicator
legend_trace = go.Scatter(
# (None, None) is a hack to get a legend item without
# appearing on the plot
x=[None],
y=[None],
mode="markers",
marker={
"size": dot_size,
"color": "white",
"line": {"width": 2, "color": "red"},
},
name="Constraint Violation",
)
fig.add_trace(legend_trace)
if df["overall_probability_constraints_violated"].notna().any():
legend_trace = go.Scatter(
# (None, None) is a hack to get a legend item without
# appearing on the plot
x=[None],
y=[None],
mode="markers",
marker={
"size": dot_size,
"color": "white",
"line": {"width": 2, "color": "red"},
},
name="Constraint Violation",
)
fig.add_trace(legend_trace)

_add_style_to_effects_by_arm_plot(
fig=fig, df=df, metric_name=metric_name, outcome_constraints=outcome_constraints
Expand Down

0 comments on commit 15ff1dd

Please sign in to comment.