Giter VIP home page Giter VIP logo

Comments (10)

lisphilar avatar lisphilar commented on June 23, 2024

Thank you for your bug report!
However, I failed in reporducing the error with Google Colab and the same codes.
https://gist.github.com/lisphilar/e25b5ac4d1ac9dcea0f383ead0a4957e

Does the following scpript return empty dataframe?
(If yes, error is in downloading. If no, error is in subsetting.)

import covsirphy as cs
cs.__version__

eng = cs.DataEngineer()
eng.download(country='USA', province='Illinois', databases=["japan", "covid19dh"]);
eng.clean()
eng.transform()

df = eng.all()
df.loc[df['City'] == 'Cook']

from covid19-sir.

karanjogi avatar karanjogi commented on June 23, 2024

Thanks you for replying promptly!
Yes it does return a dataframe. I think I found the issue with my code. I didn't set the layer for the dataengineer

import covsirphy as cs
cs.version

eng = cs.DataEngineer(['ISO3', 'Province', 'City'], complement=True)
eng.download(country='USA', province='Illinois', databases=["japan", "covid19dh", "owid"])
eng.clean()
eng.transform()
eng.layer(geo=("USA", "Illinois",))

actual_df, status, _ = eng.subset(geo=("USA", 'Illinois', 'Cook'), variables="SIRF", complement=True)
print(status)
actual_df.tail()

This gives a subset on city level. However the sample code doesn't add any layers. Therefore eng.subset is acting funny if you provide geo=('Japan', 'Tokyo', ) or any other combination of city and province.

from covid19-sir.

lisphilar avatar lisphilar commented on June 23, 2024

I may not have understood the point correctly, but cs.DataEngineer() is the same as cs.DataEngineer(layers=None) and cs.DataEngineer(layers=[“ISO3”, “Province”, “City”]). Is this making you confused?

from covid19-sir.

karanjogi avatar karanjogi commented on June 23, 2024

I think I was able to solve the confusion.

I am trying to create a phase dependent model (SIRD) for a city in USA.

It seems that value of kappa is 0 for some phases.
I have tried different algo for segments and other arguments too. But still it is 0.
Can you suggest a work around.

Colab link below:
https://colab.research.google.com/drive/1dFKxUWd6L7ek_x1cognX49sChrE5142e#scrollTo=MD7lhKDtG6ZK

from covid19-sir.

lisphilar avatar lisphilar commented on June 23, 2024

Hi @karanjogi
I'm sorry for my very late reply.

I performed additional analysis and found that the number of fatal cases were not changed in the phases with kappa = 0.
https://gist.github.com/lisphilar/d717d73bcb1f5d3e80e79db9bbee4796

If the number of fatal cases is correct, kappa = 0 should be accepted. i.e. We need to fix the ZeroDivisionError by returning NA when kappa = 0.

from covid19-sir.

karanjogi avatar karanjogi commented on June 23, 2024

Hi @lisphilar ,

Thank you for clearing what the problem is!

Can you please suggest a workaround this error? Or where the code change needs to be done?
I can give it a try and submit a PR if solved.

Thanks!

from covid19-sir.

lisphilar avatar lisphilar commented on June 23, 2024

Thank you for your contribution!

Regarding SIR-D model, the error is raised here. Could you add if statements in "try" block?

def dimensional_parameters(self) -> dict[str, int]:
"""Calculate dimensional parameter values.
Raises:
ZeroDivisionError: either kappa or rho or sigma value was over 0
Returns:
dict of {str: int}: dictionary of dimensional parameter values
- "1/alpha2 [day]" (int): mortality period
- "1/beta [day]" (int): infection period
- "1/gamma [day]" (int): recovery period
"""
try:
return {
"1/alpha2 [day]": round(self._tau / 24 / 60 / self._kappa),
"1/beta [day]": round(self._tau / 24 / 60 / self._rho),
"1/gamma [day]": round(self._tau / 24 / 60 / self._sigma)
}
except ZeroDivisionError:
raise ZeroDivisionError(
f"Kappa, rho and sigma must be over 0 to calculate dimensional parameters with {self._NAME}.") from None

The other models (sir.py, sirf.py, sewirf.py) in the directory also have the same issues.

Additionally, please add tests (with pytest) to https://github.com/lisphilar/covid19-sir/blob/5eb55efc36db79f302c951878d8bd45bf7e6e6dc/tests/test_dynamics/test_model.py so that we can avoid the similar issues.

I look forward to our discussion.

from covid19-sir.

lisphilar avatar lisphilar commented on June 23, 2024

And could you add a title to this issue?

from covid19-sir.

karanjogi avatar karanjogi commented on June 23, 2024

Sure!
I have made the changes in a new branch named develop and will be creating a PR for it.
Could you please review it and let me know if there are any changes needed?

from covid19-sir.

lisphilar avatar lisphilar commented on June 23, 2024

Thank you got your pull request!
As I commented on that, rho_i = 0 and sigma = 0 could be acceptable as well as kappa = 0.

from covid19-sir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.