CodeForPhilly / chime

COVID-19 Hospital Impact Model for Epidemics
https://codeforphilly.github.io/chime/
MIT License
205 stars 151 forks source link

Improve model performance #464

Closed PhilMiller closed 4 years ago

PhilMiller commented 4 years ago

Description:

Right now, on my local system, a prescribed doubling time serves a page in about 30 ms, while fitting to a prescribed first date of hospitalization serves a page in about a second. If we start fitting more parameters, that's going to blow up, and the tool will become less functional for interactive use.

PhilMiller commented 4 years ago

Rudimentary timing measurement shows that almost all of the time, >90%, is spent in building the dataframes in run_projection

PhilMiller commented 4 years ago

The calculations are a tiny fraction of the runtime. Dataframe construction itself is somehow quite costly. Eliminating that makes things much faster. PR coming soon.

PhilMiller commented 4 years ago

Yep, doing the entire inner fitting process with straight numpy arrays, and just constructing the DataFrame at the end gets a net 17x faster.