Skip to content

Commit 4127865

Browse files
Sunny Shenfacebook-github-bot
authored andcommitted
exp_tp_df calculate relative metrics after calculating feasibility (facebook#3103)
Summary: Pull Request resolved: facebook#3103 As titled, move the logic of calculating relative metrics to after calculating feasibility, as feasibility calculation relies on derelativized optimization config + metrics. Reviewed By: Balandat Differential Revision: D66319304 fbshipit-source-id: 0a224e3918bc4987942957c6c4bdcc0d175dbde3
1 parent 1c01236 commit 4127865

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

ax/service/utils/report_utils.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -874,23 +874,6 @@ def exp_to_df(
874874
metric_names = [m.name for m in metrics]
875875
results = results[results["metric_name"].isin(metric_names)]
876876

877-
# Calculate relative metrics if `show_relative_metrics` is True.
878-
if show_relative_metrics:
879-
if exp.status_quo is None:
880-
logger.warning(
881-
"No status quo arm found. Showing raw metric values instead of "
882-
"relative metric values."
883-
)
884-
else:
885-
status_quo_arm_name = exp.status_quo.name
886-
try:
887-
results = _get_relative_results(results, status_quo_arm_name)
888-
except Exception:
889-
logger.warning(
890-
"Failed to calculate relative metrics. Showing raw metric values "
891-
"instead of relative metric values."
892-
)
893-
894877
# Add `FEASIBLE_COL_NAME` column according to constraints if any.
895878
if (
896879
exp.optimization_config is not None
@@ -910,6 +893,23 @@ def exp_to_df(
910893
except (KeyError, ValueError, DataRequiredError) as e:
911894
logger.warning(f"Feasibility calculation failed with error: {e}")
912895

896+
# Calculate relative metrics if `show_relative_metrics` is True.
897+
if show_relative_metrics:
898+
if exp.status_quo is None:
899+
logger.warning(
900+
"No status quo arm found. Showing raw metric values instead of "
901+
"relative metric values."
902+
)
903+
else:
904+
status_quo_arm_name = exp.status_quo.name
905+
try:
906+
results = _get_relative_results(results, status_quo_arm_name)
907+
except Exception:
908+
logger.warning(
909+
"Failed to calculate relative metrics. Showing raw metric values "
910+
"instead of relative metric values."
911+
)
912+
913913
# If arms_df is empty, return empty results (legacy behavior)
914914
if len(arms_df.index) == 0:
915915
if len(results.index) != 0:

0 commit comments

Comments
 (0)