Integrating external models ------------------------------ CHAP can run external models in two ways: - By specifying a path to a local code base - or by specifying a github URL to a git repo. The url needs to start with https://github.com/ In either case, the directory or repo should be a valid MLproject directory, with an `MLproject` file. Se the specification in the `MLflow documentation `_ for details. In addition, we require the following: - An entry point in the MLproject file called `train` with parameters `train_data` and `model` - An entry point in the MLproject file called `predict` with parameters `historic_data`, `future_data`, `model` and `out_file` These should contain commands that can be run to train a model and predict the future using that model. The model parameter should be used to save a model in the train step that can be read and used in the predict step. CHAP will provide all the data (the other parameters) when running a model. `Here is an example of a valid directory with an MLproject file `_. The MLproject file can specify a docker image or Python virtual environment that will be used when running the commands. Running an external model on the command line ---------------------------------------------- External models can be run on the command line using the `chap evaluate` command. See `chap evaluate --help` for details. This example runs an auto ewars R model on public ISMIP data for Brazil using a public docker image with the R inla package. After running, a report file `report.pdf` should be made. .. code-block:: bash chap evaluate --model-name https://github.com/sandvelab/chap_auto_ewars --dataset-name ISIMIP_dengue_harmonized --dataset-country brazil Running an external model in Python ------------------------------------ CHAP contains an API for loading models through Python. The following shows an example of loading and evaluating three different models by specifying paths/github urls, and evaluating those models: .. literalinclude :: ../scripts/external_model_example.py :language: python