Example scenarios¶
The epifx.example.seir
module provides example scenarios for each of the provided Epidemic models, using Google Flu Trends data for Australia in 2014.
Use the write_example_files()
function to write the scenario definitions and input data files for a specific scenario to the current working directory.
You can then run forecast simulations with the epifx-forecast command.
You can also modify the scenario definitions and input data files to see how your changes affect the forecast results.
- epifx.example.seir.write_example_files(scenario)¶
Save the example files for a scenario to the working directory.
- Parameters
scenario – The scenario name.
- Raises
ValueError – If the scenario name is invalid (see below).
The valid scenarios are:
'seir'
: The deterministicSEIR
model with date times.'seir_quick'
: : The deterministicSEIR
model with date times, using only 20 particles.'seeiir'
: The deterministicSEEIIR
model with date times.'seeiir_scalar'
: The deterministicSEEIIR
model with scalar time.'stoch'
: The stochasticSEEIIR
model with date times.
Shown below is an example script that generates forecasts for the 'seir'
scenario:
import datetime
import epifx.example.seir
import pypfilt
scenario = 'seir'
toml_file = 'seir.toml'
output_file = 'seir_forecasts.hdf5'
forecast_dates = [datetime.datetime(2014, 4, 1)]
# Write the scenario files to the working directory.
epifx.example.seir.write_example_files(scenario)
# Run forecasts for each scenario instance (there is only one instance).
for instance in pypfilt.load_instances(toml_file):
context = instance.build_context()
pypfilt.forecast(context, forecast_dates, output_file)