ciemss / pyciemss

Causal and probabilistic reasoning with continuous time dynamical systems
Other
12 stars 4 forks source link

438 add various interventions to interfacesipynb #493

Closed sabinala closed 3 months ago

sabinala commented 4 months ago

Closes #438

review-notebook-app[bot] commented 4 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

SamWitty commented 4 months ago

@sabinala , could you resolve conflicts and then tag me when this is ready for review again? Thanks!

sabinala commented 4 months ago

@SamWitty I resolved the branch conflicts, and then went to run the notebook again and now I'm getting an error when trying to sample with interventions. I'm confused because I thought this came up and was resolved, but please see: https://github.com/ciemss/pyciemss/issues/524

SamWitty commented 4 months ago

I get an error with this notebook at the dynamic parameter intervention (which explains why the notebook CI test fails), but it is successfully running the static interventions. See my comment about a fresh environment in #524.

SamWitty commented 4 months ago

@sabinala , I fixed the notebook up to optimize. I believe in your merge you erased changes to the API that @anirban-chaudhuri had made. Once you resolve your PyCIEMSS and ChiRho version errors you should be able to pick up from there.

sabinala commented 4 months ago

@SamWitty Thanks, trying that now

SamWitty commented 4 months ago

Adding @anirban-chaudhuri as a reviewer to confirm that this did not revert previous changes to optimize. Once Anirban approves (after the remaining issue is fixed) we can merge.

sabinala commented 4 months ago

@SamWitty starting with a fresh environment did fix the errors I was getting before. Are you no longer getting an error for dynamic_parameter_intervention? When I run it with make_var_threshold defined as:

def make_var_threshold(var: str, threshold: torch.Tensor):
    def var_threshold(time, state):
        return state[var] - threshold
    return var_threshold

I get a KeyError:

File ~/anaconda3/lib/python3.10/site-packages/pyro/infer/predictive.py:55, in <dictcomp>(.0)
     52         collected.append(trace)
     53     else:
     54         collected.append(
---> 55             {site: trace.nodes[site]["value"] for site in return_site_shapes}
     56         )
     58 if return_trace:
     59     return collected

KeyError: 'parameter_intervention_value_p_cbeta_0'
sabinala commented 4 months ago

@SamWitty @anirban-chaudhuri This notebook is ready to go and includes the new optimize interface implementations

sabinala commented 4 months ago

@SamWitty @anirban-chaudhuri This notebook is ready to go and includes the new optimize interface implementations

Nevermind...cannot get the notebook test to pass :(

SamWitty commented 3 months ago

@sabinala , unfortunately the CI does not return very informative error messages for the notebook tests. When I run the test_notebooks.sh script locally I get an error ERROR docs/source/interfaces.ipynb::Cell 0 - jupyter_client.kernelspec.NoSuchKernel: No such kernel named pyciemss which is a bit more informative. It looks like you made some accidental changes to the kernel from python3 to pyciemss, which doesn't exist in the CI build.

SamWitty commented 3 months ago

@sabinala , this issue looks slightly more nuanced. I'll figure it out. Please hold off on making more commits.