Skip to content

Update SMC-ABC_Lotka-Volterra_example.ipynb #590

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

Merged
merged 3 commits into from
Nov 17, 2023
Merged

Conversation

PRKramer
Copy link
Contributor

@PRKramer PRKramer commented Nov 15, 2023

#588 Added the time array to the plots to correctly represent the independent variable in 2 plots

Helpful links


📚 Documentation preview 📚: https://pymc-examples--590.org.readthedocs.build/en/590/

Added the time array to the plots to correctly represent the independent variable in 2 plots.
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@OriolAbril
Copy link
Member

Thanks for the PR. You should also rerun the notebook and then run pre-commit

@PRKramer
Copy link
Contributor Author

Sorry I am really naive about python and GitHub. I just noticed the error in the notebook when I was adopting the material for use in a math class. I can't even figure outhow to run python on my modified notebook, nor how to download the notebook onto my computer. I just modified the syntax of the plot commands in a way that worked when I did it on a private notebook. I don't expect you to give me a tutorial on pull requests, nor do I want to read a massive amount of documentation. I just wanted to point out a small error in the example notebook which should be very simple to fix for someone who understands the GitHub process better than I do...I'm happy to abandon the issue if it's more bother than it's worth.

@PRKramer
Copy link
Contributor Author

Wait..one of my students in my class figured out how to overcome the check failure...working on it!

Run pre-commit and run notebook on changes.

Co-authored-by: Dylan Le <[email protected]>
@MacroLens
Copy link
Contributor

@OriolAbril reran the notebook and ran pre-commit on changes.
Let me know if there is anything else you need.

Copy link

review-notebook-app bot commented Nov 17, 2023

View / edit / reply to this conversation on ReviewNB

twiecki commented on 2023-11-17T07:57:01Z
----------------------------------------------------------------

This doesn't look correct.


MacroLens commented on 2023-11-17T16:20:18Z
----------------------------------------------------------------

You would be correct. I'm fixing it now, the time scale wasn't applied to the plot on line 6.

MacroLens commented on 2023-11-17T16:49:14Z
----------------------------------------------------------------

Looks better now.

@PRKramer
Copy link
Contributor Author

I was flying blind because I didn't see how to actually run the change. Dylan reminded me about cloning (yes, it's been a few years since my last GitHub encounter with some research students, which sent me fleeing). So I'll give it a closer look when I have a bit of time to walk through the mechanics.

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

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

I added a couple comments. They are on the myst file, but the changes should be made on the notebook, it's pre-commit that syncs the two up again. That should fix the wrong looking plot from the reviewNB comment.

Side note: we are having a docathon starting in 5 minutes (will go on for 3 hours). In case it might be of interest, more info on pymc's discourse

ax.plot(observed[:, 0], "o", label="prey", c="C0", mec="k")
ax.plot(observed[:, 1], "o", label="predator", c="C1", mec="k")
ax.plot(t, observed[:, 0], "o", label="prey", c="C0", mec="k")
ax.plot(t, observed[:, 1], "o", label="predator", c="C1", mec="k")
ax.plot(competition_model(None, posterior["a"].mean(), posterior["b"].mean()), linewidth=3)
Copy link
Member

Choose a reason for hiding this comment

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

This also needs t as x values

ax.plot(observed[:, 0], "o", label="prey", c="C0", mec="k")
ax.plot(observed[:, 1], "o", label="predator", c="C1", mec="k")
ax.plot(t, observed[:, 0], "o", label="prey", c="C0", mec="k")
ax.plot(t, observed[:, 1], "o", label="predator", c="C1", mec="k")
ax.plot(competition_model(None, posterior["a"].mean(), posterior["b"].mean()), linewidth=3)
for i in np.random.randint(0, size, 75):
sim = competition_model(None, posterior["a"][i], posterior["b"][i])
Copy link
Member

Choose a reason for hiding this comment

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

and so do the two plot calls right under this line

Copy link
Contributor

Choose a reason for hiding this comment

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

Weird I did run the pre-commit. I'll try again.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops I misinterpreted what you meant. I fixed this in f171270.

Copy link
Contributor

You would be correct. I'm fixing it now, the time scale wasn't applied to the plot on line 6.


View entire conversation on ReviewNB

Copy link

review-notebook-app bot commented Nov 17, 2023

View / edit / reply to this conversation on ReviewNB

MacroLens commented on 2023-11-17T16:48:38Z
----------------------------------------------------------------

Should I suppress or correct the warnings?


Copy link
Contributor

Looks better now.


View entire conversation on ReviewNB

@twiecki twiecki merged commit 836a38a into pymc-devs:main Nov 17, 2023
@twiecki
Copy link
Member

twiecki commented Nov 17, 2023

Thanks!

@MacroLens MacroLens deleted the patch-2 branch November 18, 2023 21:01
alporter08 pushed a commit to alporter08/pymc-examples that referenced this pull request Nov 20, 2023
* Update SMC-ABC_Lotka-Volterra_example.ipynb

Added the time array to the plots to correctly represent the independent variable in 2 plots.

* Run pre-commit SMC-ABC_Lotka-Volterra_example (pymc-devs#1)

Run pre-commit and run notebook on changes.

Co-authored-by: Dylan Le <[email protected]>

* fix: add time to the plot command in last plot

---------

Co-authored-by: Dylan Le <[email protected]>
Co-authored-by: Dylan Le <[email protected]>
@Fxinyu
Copy link

Fxinyu commented Nov 23, 2023

Hi, I have encountered this problem. Do you have any insights on this situation? I would appreciate that you could reply to me.
Screenshot 2023-11-23 102841

@twiecki
Copy link
Member

twiecki commented Nov 27, 2023

Are other models sampling fine?

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