Skip to content

Add red outline visual indicators for infeasible arms in ScatterPlot and ArmEffectsPlot#5026

Closed
sdaulton wants to merge 1 commit into
facebook:mainfrom
sdaulton:export-D94783502
Closed

Add red outline visual indicators for infeasible arms in ScatterPlot and ArmEffectsPlot#5026
sdaulton wants to merge 1 commit into
facebook:mainfrom
sdaulton:export-D94783502

Conversation

@sdaulton
Copy link
Copy Markdown
Contributor

Summary:
The ScatterPlot and ArmEffectsPlot analyses compute p_feasible_mean for each arm but only displayed it in the hover tooltip. Users had to hover over each point to discover constraint violations.

This change adds a red outline around scatter points for arms that are likely infeasible (p_feasible_mean < 0.1), making constraint violations immediately visible. A "Likely Infeasible" legend entry is also added when any infeasible arms are present.

In addition, prepare_arm_data() previously only included columns for the requested (plotted) metrics in its DataFrame. When a constraint metric differed from the plotted metrics, _prepare_p_feasible() couldn't find the constraint column, filled it with NaN, and all arms incorrectly appeared feasible. This fix ensures _prepare_modeled_arm_data() extracts all predicted metrics and _prepare_raw_arm_data() extracts all available data metrics, so constraint feasibility is computed correctly regardless of which metrics are plotted.

Changes:

  • plotly/utils.py: Add MINIMUM_P_FEASIBLE threshold (renamed from MINIMUM_CONTRAINT_VIOLATION_THRESHOLD), get_infeasibility_marker_line() helper, and infeasibility constants.
  • plotly/scatter.py, plotly/arm_effects.py: Apply marker line to each trial's scatter points and add a "Likely Infeasible" legend entry.
  • analysis/utils.py: Fix _prepare_modeled_arm_data to extract all predicted metrics (not just plotted ones), _prepare_raw_arm_data to extract all available data metrics, _get_status_quo_df to handle extra columns in NaN checks and status quo column selection. Extra columns are stripped before returning from prepare_arm_data() to preserve the API contract.
  • Tests: Add TestScatterPlotInfeasibility and TestArmEffectsPlotInfeasibility classes covering red outlines on infeasible arms, legend presence/absence, and the case where the constraint metric differs from the plotted metrics.

Reviewed By: mpolson64

Differential Revision: D94783502

…and ArmEffectsPlot

Summary:
The ScatterPlot and ArmEffectsPlot analyses compute `p_feasible_mean` for each arm but only displayed it in the hover tooltip. Users had to hover over each point to discover constraint violations.

This change adds a red outline around scatter points for arms that are likely infeasible (`p_feasible_mean < 0.1`), making constraint violations immediately visible. A "Likely Infeasible" legend entry is also added when any infeasible arms are present.

In addition, `prepare_arm_data()` previously only included columns for the requested (plotted) metrics in its DataFrame. When a constraint metric differed from the plotted metrics, `_prepare_p_feasible()` couldn't find the constraint column, filled it with NaN, and all arms incorrectly appeared feasible. This fix ensures `_prepare_modeled_arm_data()` extracts all predicted metrics and `_prepare_raw_arm_data()` extracts all available data metrics, so constraint feasibility is computed correctly regardless of which metrics are plotted.

Changes:
- `plotly/utils.py`: Add `MINIMUM_P_FEASIBLE` threshold (renamed from `MINIMUM_CONTRAINT_VIOLATION_THRESHOLD`), `get_infeasibility_marker_line()` helper, and infeasibility constants.
- `plotly/scatter.py`, `plotly/arm_effects.py`: Apply marker line to each trial's scatter points and add a "Likely Infeasible" legend entry.
- `analysis/utils.py`: Fix `_prepare_modeled_arm_data` to extract all predicted metrics (not just plotted ones), `_prepare_raw_arm_data` to extract all available data metrics, `_get_status_quo_df` to handle extra columns in NaN checks and status quo column selection. Extra columns are stripped before returning from `prepare_arm_data()` to preserve the API contract.
- Tests: Add `TestScatterPlotInfeasibility` and `TestArmEffectsPlotInfeasibility` classes covering red outlines on infeasible arms, legend presence/absence, and the case where the constraint metric differs from the plotted metrics.

Reviewed By: mpolson64

Differential Revision: D94783502
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Mar 13, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Mar 13, 2026

@sdaulton has exported this pull request. If you are a Meta employee, you can view the originating Diff in D94783502.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.84%. Comparing base (e2056d2) to head (9da328c).

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #5026    +/-   ##
========================================
  Coverage   96.83%   96.84%            
========================================
  Files         605      605            
  Lines       65235    65338   +103     
========================================
+ Hits        63173    63274   +101     
- Misses       2062     2064     +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@meta-codesync meta-codesync Bot closed this in ad3e606 Mar 14, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Mar 14, 2026

This pull request has been merged in ad3e606.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants