Skip to content

add low level 2d profile plot function and 2d profile function#1652

Open
EchoRLiu wants to merge 7 commits intodevelopfrom
1651-profiles-do-not-show-if-dropoff-due-to-bound-hitting
Open

add low level 2d profile plot function and 2d profile function#1652
EchoRLiu wants to merge 7 commits intodevelopfrom
1651-profiles-do-not-show-if-dropoff-due-to-bound-hitting

Conversation

@EchoRLiu
Copy link
Copy Markdown
Collaborator

@EchoRLiu EchoRLiu commented Dec 4, 2025

This PR is to address #1651.

To do so, I added two new visualization functions:

  1. profile_lowlevel_2d() - Visualizes the relationship between two parameters during profiling
  • Shows one profiled parameter on the x-axis and tracks a second parameter on the y-axis
  • Uses color mapping (via scatter plot) to indicate objective ratio or function values along the profile path
  1. visualize_2d_profile() - High-level n by n profile grid:
  • Diagonal plots: Shows traditional 1D profiles for each parameter
  • Off-diagonal plots: Shows 2D parameter relationships during profiling using profile_lowlevel_2d()

This would provide a complete overview of how parameters interact during profile likelihood computation

@EchoRLiu EchoRLiu requested a review from Doresic December 4, 2025 15:19
@EchoRLiu EchoRLiu self-assigned this Dec 4, 2025
@EchoRLiu EchoRLiu added enhancement New feature or request visualization Related to any visualization profiling Related to profiling labels Dec 4, 2025
@EchoRLiu EchoRLiu linked an issue Dec 4, 2025 that may be closed by this pull request
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 4, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 88.35616% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.90%. Comparing base (9ccf617) to head (3e4f818).

Files with missing lines Patch % Lines
pypesto/visualize/profiles.py 88.27% 17 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1652      +/-   ##
===========================================
+ Coverage    83.86%   83.90%   +0.03%     
===========================================
  Files          164      164              
  Lines        14346    14491     +145     
===========================================
+ Hits         12031    12158     +127     
- Misses        2315     2333      +18     

☔ 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.

Doresic added 2 commits March 9, 2026 16:05
- Fix colorbar layout using constrained_layout (no more overlap)
- Always extend axes to parameter bounds; remove show_bounds parameter
- Auto-generate scale-aware axis labels from problem.x_scales
- Accept optional x_labels override to match 1D profiles API
- Pairplot-style label cleanup: parameter names on edges only, ratio
  label kept on off-edge diagonal subplots
- Reset MaxNLocator on diagonal subplots to avoid dense tick marks
- Add smoke tests for visualize_2d_profile and profile_lowlevel_2d
- Add 2D profile cell to getting_started.ipynb
@Doresic
Copy link
Copy Markdown
Contributor

Doresic commented Mar 9, 2026

Remaining TODO list from @EchoRLiu

TODO List for still needed improvements:

  • there is some weird jumps when doing profile

This will be taken care of in the another PR dealing with profiling enhancements.

  • some range can not be profiled

This is weird, I saw it a couple of times. We'll need to check what happens, why does profiling stop prematurely sometimes. It might be the weird conditions in adaptive searches that doesn't have a else, so profiling can fail silently. Needs to be investigated.

  • color scheme can be improved

Good as initial visualization, can be changed via user.

  • original profile function can also be improved with threshold

For another PR as it deals with general profiling.

- Compute global vmin/vmax across all off-diagonal panels so the
  colorbar accurately represents all subplots
- Add profile_color parameter for diagonal 1D profile line color
- Add vmin/vmax parameters to profile_lowlevel_2d for external control
@Doresic Doresic marked this pull request as ready for review March 9, 2026 16:28
@dweindl
Copy link
Copy Markdown
Member

dweindl commented Mar 11, 2026

Thanks, looks mostly good to me.

Two minor things looking at https://pypesto--1652.org.readthedocs.build/en/1652/example/getting_started.html:
image

  • I find the top-left y-label confusing. how about showing all y-labels, or at least always for the first, the diagonal, and the first off-diagonal subplot?
  • the markers in the off-diagonal plots look all black. I guess this is just due to the overlap here. it might be preferable to plot them from low to high log-posterior ratio or setting the z-order accordingly.

Copy link
Copy Markdown
Collaborator

@PaulJonasJost PaulJonasJost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that is bugging me a bit is that if we have a lot of points in a small intervall, the black borders of the point overshadow the coloring.

Doresic added 2 commits April 24, 2026 14:56
Addresses reviewer feedback on #1652 and polishes the 2D profile
grid so every subplot is legible on its own.

- Self-describing subplots: every panel now carries its own axis
  label and tick labels instead of relying on grid position. Diagonal
  panels show "Log-posterior ratio" / "Objective value"; off-diagonals
  show both parameter labels.
- Off-diagonal scatter points are sorted by color so dense clusters
  reveal actual ratio structure rather than reading as uniformly dark.
  Marker edges removed for the same reason.
- New `_add_bound_lines_1d` / `_add_bound_lines_2d` helpers draw dashed
  lower/upper bound lines on every panel as a cross-plot anchor.
- New `_add_panel_legend` helper adds compact legends on the top-left
  diagonal and the first 2D off-diagonal, explaining the glyphs.
- New `label_fontsize` parameter; labels are rendered bold with a
  larger default, tick labels follow two points smaller, colorbar
  label matches. Tightened gridspec so y-labels hug their own axis
  rather than drifting between columns.
- Tests cover the new styling (fontsize, spines hidden, legend
  presence on the expected panels, dashed bound line count).
@Doresic
Copy link
Copy Markdown
Contributor

Doresic commented Apr 24, 2026

Ok some updates

  • some separation of the plots
  • y and x labels on each of the plots, bolded so it's easy to read
  • fixed the black border (removed) and plotting the better points on top on the worse ones, so we see the better areas nicer
    Some examples:
    The same example from getting started:
image And another example (Boehm). It has huge parameter names so they kinda overlap a bit, but I wouldn't reduce the plot font sizes, as usually parameters aren't so large. boehm_2d_profile

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

Labels

enhancement New feature or request profiling Related to profiling visualization Related to any visualization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Profiles do not show if dropoff due to bound hitting

5 participants