Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualize: allow for log scale of hierarchical parameters for visualization #1435

Merged
merged 9 commits into from
Aug 13, 2024

Conversation

Doresic
Copy link
Contributor

@Doresic Doresic commented Jul 30, 2024

Allow for 'log' and 'log10' parameter scales of scaling and offset hierarchical parameters. This does not change anything in their inner optimizations, as that's done analytically, but it allows for better visualization of their values in parameter plots together with all other (mostly log-scaled) parameters. I added a Boehm example below.

Currently not supported for hierarchical sigma parameters as they cannot have different parameter bounds than (0, +inf). So log-scale of its lower bound is -inf causing issues in petab.lint checks. It would be possible to fix, but would require some larger restructuring of when the petab.lint is applied, removing hierarchical sigma parameters from the parameter table before the lint or changes in petab.

@Doresic
Copy link
Contributor Author

Doresic commented Jul 30, 2024

Boehm_log_scaling_offset

@codecov-commenter
Copy link

codecov-commenter commented Jul 30, 2024

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

Codecov Report

Attention: Patch coverage is 81.81818% with 14 lines in your changes missing coverage. Please review.

Project coverage is 83.41%. Comparing base (4fb1f9e) to head (6572f45).

Files Patch % Lines
pypesto/hierarchical/base_problem.py 71.42% 6 Missing ⚠️
pypesto/hierarchical/base_parameter.py 50.00% 2 Missing ⚠️
pypesto/hierarchical/petab.py 50.00% 2 Missing ⚠️
pypesto/visualize/observable_mapping.py 33.33% 2 Missing ⚠️
pypesto/visualize/parameters.py 93.93% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1435      +/-   ##
===========================================
+ Coverage    83.21%   83.41%   +0.19%     
===========================================
  Files          161      161              
  Lines        13396    13460      +64     
===========================================
+ Hits         11148    11227      +79     
+ Misses        2248     2233      -15     

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

@Doresic
Copy link
Contributor Author

Doresic commented Jul 30, 2024

Added the scale description into the labels of parameters into the parameter plot
Boehm_log_scaling_text

Copy link
Member

@dweindl dweindl left a comment

Choose a reason for hiding this comment

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

Thanks, looks good to me.

x_labels = result.problem.x_names
# get labels as x_names and scales
x_labels = [
f"{x_name} ({x_scale})"
Copy link
Member

Choose a reason for hiding this comment

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

If all parameters use the same scale, the scale could be included once in the x axis label instead of repeatedly in the tick labels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm true, will change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it, but it is quite a bit of changes to make it work, worth it?
Look at x_axis_label choice after # If all the scales are the same, put it in the x_axis_label comment at line 465, and then it has to be passed back and into parameters_lowlevel. Works tho, and the plot is nicer.

Copy link
Member

Choose a reason for hiding this comment

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

Works for me, but it was an optional suggestion for now.

and then it has to be passed back and into parameters_lowlevel.

Alternatively, you could override labels outside parameters_lowlevel, but this doesn't simplify things that much, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah not much, think it would be even uglier if it was outside of there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will see what the visualization ppl (@m-philipps and @stephanmg) think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, looks fine to me, don't think the repetition of scale label is too bad. Certainly optional to think and implement a more visually pleasing appearance.

Copy link
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.

Looks good to me.

@@ -420,7 +433,7 @@ def noise_inner_parameters_from_parameter_df(
SplineInnerParameter(
inner_parameter_id=row[PARAMETER_ID],
inner_parameter_type=InnerParameterType.SIGMA,
scale=LIN,
scale=row[PARAMETER_SCALE],
Copy link
Collaborator

Choose a reason for hiding this comment

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

If sigma parameters cannot handle the log values, why would we change that here from the LIN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True... This is left from a version in which I tried doing it for sigma as well.
But even tho it doesn't work for sigma, it might be good to keep row[PARAMETER_SCALE] here. There are petab checks that will fail before you come to this spot if you have any LOG scale for the sigma parameters. So it feels cleaner to have it taken from petab parameter df instead of hard-coding LIN scale here.

@Doresic Doresic changed the title Visualize: allow or log scale of hierarchical parameters for visualization Visualize: allow for log scale of hierarchical parameters for visualization Aug 1, 2024
@Doresic
Copy link
Contributor Author

Doresic commented Aug 1, 2024

@PaulJonasJost I did add the option we talked about in the meeting briefly, that sigma hierarchical parameters are plotted in LOG10 scale by default. But it takes some manual finding which parameters are sigma parameters in the inner subproblems which can contain noise parameters, then rescaling all the estimated values and its bounds to LOG10. Not the nicest, but it works.

For reference, lines 536 to 558 in _handle_inner_inputs and the log10_scale_hier_sigma argument being passed around everywhere until it comes to that point.

Can leave and can remove, what do you think?

@Doresic Doresic merged commit bd4b81b into develop Aug 13, 2024
18 checks passed
@Doresic Doresic deleted the log_scale_hier_pars branch August 13, 2024 14:40
This was referenced Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants