Experiment#

class Experiment(pars=None, flags=None, label=None, **kwargs)[source]#

Bases: prettyobj

Class for running calibration to data. Effectively, it runs a single sim and compares it to data.

Parameters:
  • pars (dict) – dictionary of parameters

  • flags (dict) – which analyses to run; see fp.experiment.default_flags for options

  • label (str) – label of experiment

  • kwargs (dict) – passed into pars

Methods

load_data(key, **kwargs)[source]#

Load data from various formats

extract_data()[source]#

Load data

run_model(pars=None, **kwargs)[source]#

Create the sim and run the model

model_mmr()[source]#

Calculate maternal mortality in model over most recent 3 years

compute_fit(*args, **kwargs)[source]#

Compute how good the fit is

post_process_results(keep_people=False, compute_fit=True, **kwargs)[source]#

Compare the model and the data

run(pars=None, keep_people=False, compute_fit=True, **kwargs)[source]#

Run the model and post-process the results

compare()[source]#

Create and print a comparison between model and data

summarize(as_df=False)[source]#

Convert results to a one-number-per-key summary format. Returns summary, also saves to self.summary.

Parameters:

as_df (bool) – if True, return a dataframe instead of a dict.

to_json(filename=None, tostring=False, indent=2, verbose=False, **kwargs)[source]#

Export results as JSON.

Parameters:
  • filename (str) – if None, return string; else, write to file

  • tostring (bool) – if not writing to file, whether to write to string (alternative is sanitized dictionary)

  • indent (int) – if writing to file, how many indents to use per nested level

  • verbose (bool) – detail to print

  • kwargs (dict) – passed to savejson()

Returns:

A unicode string containing a JSON representation of the results, or writes the JSON file to disk

Examples:

json = exp.to_json()
exp.to_json('results.json')
plot(do_show=None, do_save=None, filename='fp_experiment.png', axis_args=None, do_maximize=True)[source]#

Plot the model against the data