Skip to content

Commit ed082ac

Browse files
eonofreyfacebook-github-bot
authored andcommitted
Fix Duplicate Candidate Trial Plotting Bug (#4133)
Summary: Pull Request resolved: #4133 Fix bug where `ArmEffectsPlot` and `ScatterPlot` are showing the latest CANDIDATE Trial twice. This is currently happening because the following line: ``` ~df["trial_status"].isin([ts.name for ts in FAILED_ABANDONED_STATUSES]) ``` brings in candidates before we additionally append `candidate_trial` a few lines later. By including candidate trials in the exclusion filter (i.e. `FAILED_ABANDONED_CANDIDATE_STATUSES`), we avoid duplicate candidate trials Reviewed By: Cesar-Cardoso Differential Revision: D80046532 fbshipit-source-id: 947b64ac6695a0f51308fd376a43e3cb3087c01a
1 parent c2e6c01 commit ed082ac

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

ax/analysis/plotly/arm_effects.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from ax.core.arm import Arm
3939
from ax.core.base_trial import sort_by_trial_index_and_arm_name
4040
from ax.core.experiment import Experiment
41-
from ax.core.trial_status import FAILED_ABANDONED_STATUSES, TrialStatus
41+
from ax.core.trial_status import FAILED_ABANDONED_CANDIDATE_STATUSES, TrialStatus
4242
from ax.exceptions.core import UserInputError
4343
from ax.generation_strategy.generation_strategy import GenerationStrategy
4444
from plotly import graph_objects as go
@@ -323,7 +323,9 @@ def _prepare_figure(
323323
].max()
324324
# Filter out undesired trials like FAILED and ABANDONED trials from plot.
325325
trials = df[
326-
~df["trial_status"].isin([ts.name for ts in FAILED_ABANDONED_STATUSES])
326+
~df["trial_status"].isin(
327+
[ts.name for ts in FAILED_ABANDONED_CANDIDATE_STATUSES]
328+
)
327329
]["trial_index"].unique()
328330

329331
# Check if candidate_trial is NaN and handle it

ax/analysis/plotly/scatter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040
from ax.core.arm import Arm
4141
from ax.core.experiment import Experiment
42-
from ax.core.trial_status import FAILED_ABANDONED_STATUSES, TrialStatus
42+
from ax.core.trial_status import FAILED_ABANDONED_CANDIDATE_STATUSES, TrialStatus
4343
from ax.exceptions.core import UserInputError
4444
from ax.generation_strategy.generation_strategy import GenerationStrategy
4545
from ax.utils.common.logger import get_logger
@@ -330,7 +330,9 @@ def _prepare_figure(
330330
].max()
331331
# Filter out undesired trials like FAILED and ABANDONED trials from plot.
332332
trials = df[
333-
~df["trial_status"].isin([ts.name for ts in FAILED_ABANDONED_STATUSES])
333+
~df["trial_status"].isin(
334+
[ts.name for ts in FAILED_ABANDONED_CANDIDATE_STATUSES]
335+
)
334336
]["trial_index"].unique()
335337

336338
trials_list = trials.tolist()

ax/core/trial_status.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ def __repr__(self) -> str:
148148
TrialStatus.EARLY_STOPPED,
149149
]
150150

151-
FAILED_ABANDONED_STATUSES: list[TrialStatus] = [
151+
FAILED_ABANDONED_CANDIDATE_STATUSES: list[TrialStatus] = [
152152
TrialStatus.ABANDONED,
153153
TrialStatus.FAILED,
154+
TrialStatus.CANDIDATE,
154155
]

0 commit comments

Comments
 (0)