chrism0dwk / covid19uk Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
@chrism0dwk, I was thinking of implementing some convergence diagnostics for your MCMC; is this useful? I'm thinking effective sample size and maybe Gelman-Rubin R-hat.
In order for the model to be used in the model runner, it needs to be containerized. Brief instructions are here. Here's an example for IDMs covasim:
FROM python:3
ARG COVASIM_VER=1.0.0
RUN pip install covasim==${COVASIM_VER} pandas
COPY . /app
CMD ["python", "/app/runsim.py", "/data/input/inputFile.json", "/data/output/data.json"]
Models in the model runner take a JSON input and generate JSON output, which is validated using a JSON schema. The Typescript classes are a little easier to read:
It should be straightforward to take the minimal input and use it to modify a YAML template that you currently use. It doesn't look as though you use intervention data?
I am using the reticulate package that allows you call Python from R. This is how the first part of covid_ode.py
looks like in R:
library(reticulate)
covid <- import("covid")
config <- yaml::read_yaml("ode_config.yaml")
# Load age mixing
K_tt <- readRDS(config$data$age_mixing_matrix_term)
# Load age mixing holiday
K_hh <- readRDS(config$data$age_mixing_matrix_hol)
# Load mobility matrix
Tmat <- readRDS(config$data$mobility_matrix)
diag(Tmat) <- 0
N <- readRDS(config$data$population_size)
param <- config$parameter
settings <- covid$util$sanitise_settings(config$settings)
model <- covid$model$CovidUKODE(K_tt, K_hh, Tmat, N,
settings$start, settings$end, settings$holiday,
settings$bg_max_time, 1)
Note that it won't run because there are no start
and end
settings in the ode_config.yaml
.
A function like mcmc.py
can be run from R as simply as:
source_python("mcmc.py")
It would be useful to have a chat to know what arguments would you like to have in a R wrapper for each of the main functions.
Hi @chrism0dwk
This is a high-level issue to track what is needed in order to integrate the model with https://github.com/covid-policy-modelling/model-runner. I'll post separate issues for each of these.
covid19uk/covid19uk/model_spec.py
Line 178 in 21bef41
Function load_commute_volume in pydata.py doesn't work correctly.
The sort_index sorts by day not date so it ends up in the wrong order and commute.merge doesn't correctly match several dates.
Adding "commute_raw.index = pd.to_datetime(commute_raw.index, format = '%d/%m/%Y')" just after "commute_raw = pd.read_csv(filename, index_col='date')", changes the index to a datetime format, allowing the sorting and merging to work correctly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.