Fix: Correct GMM fitting visualization in amrex_data.ipynb#165
Fix: Correct GMM fitting visualization in amrex_data.ipynb#165henry2004y wants to merge 2 commits into
Conversation
- Switched from `get_gmm_temperatures` to `get_gmm_parameters` to use thermal velocities instead of temperatures in the GMM fitting examples. - Updated the plotting to use contours of the reconstructed Gaussian distributions instead of ellipses for a more accurate visualization.
Summary of ChangesHello @henry2004y, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the Gaussian Mixture Model (GMM) fitting visualization within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #165 +/- ##
=======================================
Coverage 68.39% 68.39%
=======================================
Files 25 25
Lines 4202 4202
=======================================
Hits 2874 2874
Misses 1328 1328 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request correctly switches from get_gmm_temperatures to get_gmm_parameters and updates the GMM fitting visualization to use contours, which is a great improvement for accuracy. However, the implementation of the contour plotting doesn't produce the 1, 2, and 3-sigma contours as described in the notebook. I've provided suggestions to correct the contour level calculations in both plotting sections. The other changes are well-implemented and consistent.
| " rv = multivariate_normal(mean, cov)\n", | ||
| " ax.contour(X, Y, rv.pdf(pos), levels=3, colors='red', linestyles='--')\n", |
There was a problem hiding this comment.
The use of levels=3 in ax.contour does not plot 1, 2, and 3-sigma contours as stated in the markdown description. It will instead draw 4 automatically-chosen contour levels. To accurately plot the sigma contours, you should calculate the PDF values corresponding to 1, 2, and 3 standard deviations.
rv = multivariate_normal(mean, cov)
levels = rv.pdf(mean) * np.exp(-0.5 * np.array([1.0, 2.0, 3.0])**2)
ax.contour(X, Y, rv.pdf(pos), levels=np.sort(levels), colors='red', linestyles='--')
| " rv = multivariate_normal(mean, cov)\n", | ||
| " ax.contour(X, Y, rv.pdf(pos), levels=3, colors='red', linestyles='--')\n", |
There was a problem hiding this comment.
Similar to the isotropic case, using levels=3 here will not produce the desired 1, 2, and 3-sigma contours. It will draw 4 automatically-chosen levels. To correctly visualize the sigma contours, the levels must be calculated based on the probability density function.
rv = multivariate_normal(mean, cov)
levels = rv.pdf(mean) * np.exp(-0.5 * np.array([1.0, 2.0, 3.0])**2)
ax.contour(X, Y, rv.pdf(pos), levels=np.sort(levels), colors='red', linestyles='--')
- Switched from `get_gmm_temperatures` to `get_gmm_parameters` to use thermal velocities instead of temperatures in the GMM fitting examples. - Updated the plotting to use contours of the reconstructed Gaussian distributions instead of ellipses for a more accurate visualization. - Correctly calculate and plot 1, 2, and 3-sigma contours. - Updated the markdown description to reflect the contour plot changes.
get_gmm_temperaturestoget_gmm_parametersto use thermal velocities instead of temperatures in the GMM fitting examples.