Skip to content
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

Python Interface #6

Closed
harrisonzhu508 opened this issue Apr 2, 2020 · 11 comments
Closed

Python Interface #6

harrisonzhu508 opened this issue Apr 2, 2020 · 11 comments
Labels
enhancement New feature or request

Comments

@harrisonzhu508
Copy link
Collaborator

To make it easier for further development within the community, I suggest we convert some of the pre-stan code in base.r into Python. Should be mostly a pandas-numpy-datetime job. After which we can use the Pystan[https://pystan.readthedocs.io/en/latest/] interface to compile the Stan code and ingest data via Python.

@harrisonzhu508 harrisonzhu508 added the enhancement New feature or request label Apr 2, 2020
@am5113
Copy link

am5113 commented Apr 2, 2020

Hi Harrison,

I have been working on this for last couple of days in a private repo. It's basically done. Just need to do some testing.

What do you think is the best way of making this open source? Should the Python version have it's own repo?

@s-mishra
Copy link
Member

s-mishra commented Apr 3, 2020

Hi @am5113 the best option would be to add that as a pull request to this repo with python as a new folder. However, anything that gets added needs to be updated regularly with changes to the model.

@dentarthur
Copy link

Hi @am5113

I've put some extensive notes out of the way, here:
thecapitalistcycle#2

Sorry, no time to make short and clear.

About subsequent steps unleashed by yours.

@harrisonzhu508
Copy link
Collaborator Author

harrisonzhu508 commented Apr 3, 2020

Added the main data-wrangling class to the python branch up to line 166 in base.r. People can then inherit this base class to play around with their own models. https://github.com/ImperialCollegeLondon/covid19model/blob/python_integration/notebooks/Test.ipynb Here's an example to my attempt.

The rest should follow up quite nicely by using pystan and whatever wrangling is needed. The plotting code can remain in R for our official results, whereas the community is free to create any visualisation they would like.

@am5113
Copy link

am5113 commented Apr 3, 2020

Hi @am5113 the best option would be to add that as a pull request to this repo with python as a new folder. However, anything that gets added needs to be updated regularly with changes to the model.

@s-mishra, I agree. I'd be happy to stay on top of this. I'm sure there's an army of Python coders who will make sure of it too.

@harrisonzhu508
Copy link
Collaborator Author

@am5113 thanks for your enthusiasm to contribute to our project! I will soon submit a PR as well with an implementation that I have done as well - I think we should merge our work to avoid replication :)

@defjaf
Copy link

defjaf commented Apr 3, 2020

Both, for what it's worth I've also got a Jupyter notebook that also replicates the data-wrangling features of base.r. Ignore if it just lowers S/N but let me know if I can help.

@harrisonzhu508
Copy link
Collaborator Author

harrisonzhu508 commented Apr 3, 2020

@am5113
Copy link

am5113 commented Apr 3, 2020

You can also check mine out at: https://github.com/am5113/covid19model/tree/master/Python

I put in a crude test using rpy2 to check that the consistency between R and Python.

@harrisonzhu508
Copy link
Collaborator Author

A pull request has been made to develop an initial prototype #13

@defjaf
Copy link

defjaf commented Apr 3, 2020

There's a working notebook at https://github.com/defjaf/covid19model/blob/master/python_ahj/COVID19-base.ipynb

It's basically a direct translation of base.r into python; not quite as pythonic as the HierarchicalDataset class...

It uses numpy, pandas and pystan, as well as some utility code (adapted from Michael Betancourt <@betanalpha>) included in the repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants