pymc-devs / pymc-examples

Examples of PyMC models, including a library of Jupyter notebooks.
https://www.pymc.io/projects/examples/en/latest/
MIT License
280 stars 243 forks source link

Pathfinder example references pymcx instead of pymc_experimental #503

Closed ricardoV94 closed 1 year ago

ricardoV94 commented 1 year ago

We decided to keep the long name for the library, so the example should be updated.

CC @twiecki

2022H1030042G commented 1 year ago

Hey, I would like to work on this issue, is it available?

ricardoV94 commented 1 year ago

Yes, feel free to take it

2022H1030042G commented 1 year ago

I am new to this field, can you please guide me on this?

fonnesbeck commented 1 year ago

You will want to:

  1. Fork the pymc-examples repo
  2. Create a branch on your fork to work on the issue
  3. From the branch, replace occurrences of pymcx with pymc_experimental
  4. Push the branch to GitHub
  5. Create a pull request to this repo from your branch

Hope that helps. Feel free to ask if you have additional questions.

reshamas commented 1 year ago

In case you need to set up your virtual environment, there are some instructions here:
https://pymc-data-umbrella.xyz/en/latest/sprint/tutorials/environment_setup.html

The virtual environment will be helpful for running the notebook after the changes have been made to see that they work, error free

2022H1030042G commented 1 year ago

Where is this "pymcx"?, I am unable to find it,

fonnesbeck commented 1 year ago

It doesn't exist, which is why we have to change it.

twiecki commented 1 year ago

Specifically, we renamed pymcx to pymc-experimental, which is what you have to do here. https://github.com/pymc-devs/pymc-experimental/

drbenvincent commented 1 year ago

This page is a useful guide https://pymc-data-umbrella.xyz/en/latest/sprint/tutorials/docstring_tutorial.html

And the style guide is useful to consult if you run into any issues https://docs.pymc.io/en/latest/contributing/jupyter_style.html

reshamas commented 1 year ago

code:

import arviz as az
import numpy as np
import pymc as pm
import pymc_experimental as pmx
import pytensor
import pytensor.tensor as pt

print(f"Running on PyMC v{pm.__version__}")
with model:
    idata = pmx.fit(method="pathfinder")

Error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File ~/miniforge3/envs/pymc-dev/lib/python3.11/site-packages/pymc_experimental/inference/fit.py:34, in fit(method, **kwargs)
     33 try:
---> 34     from pymc_experimental.inference.pathfinder import fit_pathfinder
     35 except ImportError as exc:

File ~/miniforge3/envs/pymc-dev/lib/python3.11/site-packages/pymc_experimental/inference/pathfinder.py:21
     20 import arviz as az
---> 21 import blackjax
     22 import jax

ModuleNotFoundError: No module named 'blackjax'

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
Cell In[3], line 2
      1 with model:
----> 2     idata = pmx.fit(method="pathfinder")

File ~/miniforge3/envs/pymc-dev/lib/python3.11/site-packages/pymc_experimental/inference/fit.py:36, in fit(method, **kwargs)
     34     from pymc_experimental.inference.pathfinder import fit_pathfinder
     35 except ImportError as exc:
---> 36     raise RuntimeError("Need BlackJAX to use `pathfinder`") from exc
     37 return fit_pathfinder(**kwargs)

RuntimeError: Need BlackJAX to use `pathfinder`
reshamas commented 1 year ago

jax installation:
https://github.com/google/jax#installation

blackjax installation: https://pypi.org/project/blackjax/

twiecki commented 1 year ago

Closed by #521.