CovsirPhy introduction
Documentation | Installation | Tutorial | API reference | GitHub | Qiita (Japanese)
CovsirPhy is a Python library for infectious disease (COVID-19: Coronavirus disease 2019, Monkeypox 2022) data analysis with phase-dependent SIR-derived ODE models. We can download datasets and analyze them easily. Scenario analysis with CovsirPhy enables us to make data-informed decisions.
Inspiration
Monitor the spread of COVID-19/Monkeypox with SIR-derived ODE models
Predict the number of cases in each country/province
Find the relationship of reproductive number and measures taken by each country
If you have ideas or need new functionalities, please join this project. Any suggestions with Github Issues and Twitter: @lisphilar are always welcomed. Questions are also great. Please refer to Guideline of contribution.
Installation
The latest stable version of CovsirPhy is available at PyPI (The Python Package Index): covsirphy and supports Python 3.8 or newer versions. Details are explained in Documentation: Installation.
pip install --upgrade covsirphy
Demo
Quickest tour of CovsirPhy is here. The following codes analyze the records in Japan.
import covsirphy as cs
# Data preparation,time-series segmentation, parameter estimation with SIR-F model
snr = cs.ODEScenario.auto_build(geo="Japan", model=cs.SIRFModel)
# Check actual records
snr.simulate(name=None);
# Show the result of time-series segmentation
snr.to_dynamics(name="Baseline").detect();
# Perform simulation with estimated ODE parameter values
snr.simulate(name="Baseline");
# Predict ODE parameter values (30 days from the last date of actual records)
snr.build_with_template(name="Predicted", template="Baseline");
snr.predict(days=30, name="Predicted");
# Perform simulation with estimated and predicted ODE parameter values
snr.simulate(name="Predicted");
# Add a future phase to the baseline (ODE parameters will not be changed)
snr.append();
# Show created phases and ODE parameter values
snr.summary()
# Compare reproduction number of scenarios (predicted/baseline)
snr.compare_param("Rt");
# Compare simulated number of cases
snr.compare_cases("Confirmed");
# Describe representative values
snr.describe()
Output of snr.simulate(name="Predicted");
Tutorial
Tutorials of functionalities are included in the CovsirPhy documentation.
Release notes
Release notes are here. Titles & links of issues are listed with acknowledgement.
We can see the release plan for the next stable version in milestone page of the GitHub repository. If you find a highly urgent matter, please let us know via issue page.
Developers
CovsirPhy library is developed by a community of volunteers. Please see the full list here.
This project started in Kaggle platform. Hirokazu Takaya
(@lisphilar) published Kaggle
Notebook: COVID-19 data with SIR
model
on 12Feb2020 and developed it, discussing with Kaggle community. On
07May2020, “covid19-sir” repository was created. On 10May2020,
covsirphy
version 1.0.0 was published in GitHub. The first release
in PyPI (version 2.3.0) was on 28Jun2020. Many APIs were reviewed via
2.x series and version 3.0.0 was released on 12May2023.
Support
License: Apache License 2.0
Please refer to LICENSE file.
Citation
Please cite this library as follows with version number
(import covsirphy as cs; cs.__version__
).
Hirokazu Takaya and CovsirPhy Development Team (2020-2024), CovsirPhy version [version number]: Python library for COVID-19 analysis with phase-dependent SIR-derived ODE models,https://github.com/lisphilar/covid19-sir
This is the output of covsirphy.__citation__
.
import covsirphy as cs
cs.__citation__
We have no original papers the author and contributors wrote, but note that some scientific approaches, including SIR-F model, S-R change point analysis, phase-dependent approach to SIR-derived models, were developed in this project.
- Data preparation
- Data engineering
- SIR-derived ODE models
- Phase-dependent SIR models
- Scenario analysis
- ODE parameter prediction
- covsirphy package
get_citation()
get_version()
- covsirphy.downloading package
- covsirphy.dynamics package
- covsirphy.dynamics.dynamics module
Dynamics
Dynamics.detect()
Dynamics.estimate()
Dynamics.estimate_params()
Dynamics.estimate_tau()
Dynamics.evaluate()
Dynamics.from_data()
Dynamics.from_sample()
Dynamics.model
Dynamics.model_name
Dynamics.name
Dynamics.parse_days()
Dynamics.parse_phases()
Dynamics.register()
Dynamics.segment()
Dynamics.simulate()
Dynamics.start_dates()
Dynamics.summary()
Dynamics.tau
Dynamics.track()
- covsirphy.dynamics.ode module
ODEModel
ODEModel.definitions()
ODEModel.dimensional_parameters()
ODEModel.from_data()
ODEModel.from_data_with_optimization()
ODEModel.from_data_with_quantile()
ODEModel.from_sample()
ODEModel.inverse_transform()
ODEModel.name()
ODEModel.r0()
ODEModel.settings()
ODEModel.solve()
ODEModel.sr()
ODEModel.transform()
- covsirphy.dynamics.sewirf module
- covsirphy.dynamics.sir module
- covsirphy.dynamics.sird module
- covsirphy.dynamics.sirf module
- covsirphy.dynamics.dynamics module
- covsirphy.engineering package
- covsirphy.engineering.engineer module
DataEngineer
DataEngineer.add()
DataEngineer.all()
DataEngineer.assign()
DataEngineer.choropleth()
DataEngineer.citations()
DataEngineer.clean()
DataEngineer.diff()
DataEngineer.div()
DataEngineer.download()
DataEngineer.inverse_transform()
DataEngineer.layer()
DataEngineer.mul()
DataEngineer.recovery_period()
DataEngineer.register()
DataEngineer.sub()
DataEngineer.subset()
DataEngineer.subset_alias()
DataEngineer.transform()
DataEngineer.variables_alias()
- covsirphy.engineering.engineer module
- covsirphy.gis package
- covsirphy.science package
- covsirphy.science.ml module
- covsirphy.science.ode_scenario module
ODEScenario
ODEScenario.append()
ODEScenario.auto_build()
ODEScenario.build_with_dynamics()
ODEScenario.build_with_model()
ODEScenario.build_with_template()
ODEScenario.compare_cases()
ODEScenario.compare_param()
ODEScenario.delete()
ODEScenario.describe()
ODEScenario.from_json()
ODEScenario.predict()
ODEScenario.rename()
ODEScenario.represent()
ODEScenario.simulate()
ODEScenario.summary()
ODEScenario.to_dynamics()
ODEScenario.to_json()
ODEScenario.track()
- covsirphy.util package
- covsirphy.util.alias module
- covsirphy.util.config module
- covsirphy.util.error module
EmptyError
ExperimentalWarning
NAFoundError
NotEnoughDataError
NotIncludedError
NotNoneError
NotRegisteredError
NotSubclassError
ScenarioNotFoundError
SubsetNotFoundError
UnExecutedError
UnExpectedLengthError
UnExpectedNoneError
UnExpectedTypeError
UnExpectedValueError
UnExpectedValueRangeError
deprecate()
experimental()
- covsirphy.util.evaluator module
- covsirphy.util.filer module
- covsirphy.util.stopwatch module
- covsirphy.util.term module
Term
Term.A
Term.ACTUAL
Term.AREA_ABBR_COLS
Term.AREA_COLUMNS
Term.C
Term.CI
Term.CITY
Term.COLUMNS
Term.COUNTRY
Term.DATE
Term.DATE_FORMAT
Term.DATE_FORMAT_DESC
Term.DSIFR_COLUMNS
Term.E
Term.END
Term.F
Term.FIG_COLUMNS
Term.FITTED
Term.FR
Term.FUTURE
Term.ID
Term.INITIAL
Term.ISO3
Term.MAIN
Term.MODERATE
Term.MONO_COLUMNS
Term.N
Term.NA
Term.NLOC_COLUMNS
Term.ODE
Term.OTHERS
Term.P
Term.PARAM_DICT
Term.PAST
Term.PHASE
Term.PRODUCT
Term.PROVINCE
Term.R
Term.RATE_COLUMNS
Term.RT
Term.RT_FULL
Term.RUNTIME
Term.S
Term.SEP
Term.SERIES
Term.SEVERE
Term.START
Term.STEP_N
Term.STR_COLUMNS
Term.SUB_COLUMNS
Term.SUFFIX_DICT
Term.T
Term.TAU
Term.TENSE
Term.TESTS
Term.TESTS_DIFF
Term.TRIALS
Term.TS
Term.V
Term.VAC
Term.VAC_BOOSTERS
Term.VALUE_COLUMNS
Term.V_FULL
Term.V_ONCE
Term.W
Term.Y0_DICT
Term.num2str()
Term.str2num()
- covsirphy.util.validator module
- covsirphy.visualization package