-
Notifications
You must be signed in to change notification settings - Fork 2
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
Interactive plot #46
Interactive plot #46
Conversation
Running the formatter also edited multi_gaussian_process.py and swift.py |
318f165
to
f42aba2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this addition, these sort of visualisations also really nicely highlight the use of the emulators! I have some minor comments, only on some of the phrasing. After fixing these I'll be happy to merge.
to try an interactive plot. Every emulator object contains an | ||
`interactive_plot` method. This generates a plot with a slider | ||
for each parameter. The plot will update to show the emulator | ||
predictions when sliders are adjusted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a line that explains the default reference line.
.. image:: interactive_plot.png | ||
|
||
It is possible to pass reference data to be plotted when calling | ||
:meth:`swiftemulator.emulators.base.BaseEmulator.interactive\_plot`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could add this to the example? Similar to the previous comment I would at least mention the reference line and/or the extra datapoints
swiftemulator/emulators/base.py
Outdated
""" | ||
Generates an interactive plot which displays the emulator predictions. | ||
If no reference data is passed to be overplotted then the plot will | ||
display a line which corresponds to the predictions for the mean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it the mean or the midpoint of the ranges? (also out of curiosity, I guess it's the same for uniform points)
swiftemulator/emulators/base.py
Outdated
name = model_specification.parameter_names[i] | ||
lo_lim = sorted(model_specification.parameter_limits[i])[0] | ||
hi_lim = sorted(model_specification.parameter_limits[i])[1] | ||
param_means[name] = (lo_lim + hi_lim) / 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe refer to it as midpoints as that is more correct (also clarifies my earlier comment)
Just thinking about it now, just like for the parameter sweeps it might be nice to be able to give it a reference set of parameters (in case you have already done a fit for example). Not super important for when you compare with external points, but it could provide a nicer "default" comparison line |
@EvgeniiChaikin maybe this is also interesting for you to look at and see if you have suggestions |
I've implemented that, along with the documentation changes you suggested |
Thanks for this! |
I added a method to allow for visualisation of the effect of varying parameter values on the emulator predictions. Maybe visualisation.py would be a better place to put it though.
I tested this by adding a single line (
schecter_emulator.interactive_plot(predict_x, xlabel='Stellar mass', ylabel='dn/dlogM')
) to the end of the getting started example. If you decide to merge this then I'd need to add it an example somewhere in the documentation.The plot is pretty responsive for me when testing with two parameters. For a large emulator model this might not be the case though, as the emulator has to make a prediction every time you move the slider.
The axis limits of the plot are set by the initial values. This means that the line can move off the plot, but I think resizing the plot would make it more difficult to see the effect of varying the parameters.
It would be nice to save the plot as an html/javascript for sharing. In the past I've used the bokeh package for these kind of plots, but I didn't want to add another dependency.