AutoDelphiRF is an end-to-end pipeline for data that are revised after first publication. It can inspect a revision archive, prepare the modeling data, train and test forecasting models retrospectively, evaluate their predictions, run post-forecast assessments, and produce a local HTML report.
You can use AutoDelphiRF from the terminal or run the complete workflow in its local web application.
Important
Development status
AutoDelphiRF is under active development, and the associated manuscript is
currently in preparation. The dev branch is currently the recommended
branch for use and testing. Interfaces, functionality, and documentation
may change prior to the first stable release.
Feedback and bug reports are welcome. Please open a GitHub issue if you encounter any problems.
- Python 3.10 or newer
- R and
Rscript - The R package DelphiRF
- The R package
quantreg
Install the R dependencies:
Rscript -e 'install.packages(c("remotes", "quantreg")); remotes::install_github("cmu-delphi/DelphiRF")'Pre-diagnosis runs entirely in Python. R and DelphiRF are required when the pipeline prepares data or trains a DelphiRF model.
Install directly from GitHub:
python -m pip install "autodelphirf[parquet] @ git+https://github.com/cmu-delphi/AutoDelphiRF.git"Or install from a clone:
git clone https://github.com/cmu-delphi/AutoDelphiRF.git
cd AutoDelphiRF
python -m pip install -e ".[parquet]"The parquet extra installs pyarrow, which is needed for the default
prepared-data format. Use --triangle-format csv if you do not want Parquet.
Confirm the installation:
autodelphirf --version
autodelphirf --helpAutoDelphiRF accepts CSV, gzipped CSV, and Parquet files. The input is a long revision archive with one row for every published value:
| geo_value | reference_date | report_date | value |
|---|---|---|---|
| ak | 2024-03-04 | 2024-03-06 | 118 |
| ak | 2024-03-04 | 2024-03-13 | 142 |
| ak | 2024-03-04 | 2024-03-20 | 147 |
| ak | 2024-03-05 | 2024-03-06 | 95 |
reference_date: the date the measurement describes.report_date: the date that version of the value was published.value: the value available on that report date.geo_value: the location or series identifier.
Column names can be changed with command-line options. A single-location file
without a location column can use --no-geo.
For a count or a fraction stored in one value column:
autodelphirf run \
--archive my_archive.csv \
--name mydata \
--value-col value \
--value-type count \
--out autodelphirf_workUse --value-type fraction if the one column represents a fraction.
Pass --value-col twice, numerator first and denominator second:
autodelphirf run \
--archive my_archive.csv \
--name mydata \
--value-type fraction \
--value-col numerator \
--value-col denominator \
--out autodelphirf_workautodelphirf run \
--archive my_archive.csv \
--name mydata \
--geo-col location_id \
--reference-col event_date \
--report-col issue_date \
--value-col count \
--out autodelphirf_workUse diagnose to inspect the data before preparing or training anything:
autodelphirf diagnose --archive my_archive.csvThis reports the archive size, location count, date ranges, reference-date and report-date cadence, revision rate, suggested feature lags, recommended target lag, and training-window length. It writes no files and does not require R.
Use the same column options that you would use for a full run:
autodelphirf diagnose \
--archive my_archive.csv \
--geo-col location_id \
--reference-col event_date \
--report-col issue_date \
--value-col countFor machine-readable output:
autodelphirf diagnose --archive my_archive.csv --jsonThe following command performs pre-diagnosis, preprocessing, retrospective training and testing, evaluation, post-forecast assessment, and report generation:
autodelphirf run \
--archive my_archive.csv \
--name mydata \
--out autodelphirf_workThe default model selection is baseline_null,delphirf. Select additional
available models with --methods:
autodelphirf run \
--archive my_archive.csv \
--name mydata \
--methods baseline_null,delphirf,naive_delphirf,global_delphirf \
--out autodelphirf_workRun autodelphirf run --help to see the model identifiers and all available
options.
autodelphirf run \
--archive my_archive.csv \
--name mydata \
--first-origin-date 2024-01-01 \
--retrain-days 30 \
--out autodelphirf_workYou can also provide an explicit start and end date:
autodelphirf run \
--archive my_archive.csv \
--name mydata \
--start-date 2024-01-01 \
--end-date 2025-01-01 \
--retrain-days 30 \
--out autodelphirf_workAutoDelphiRF recommends an operational target lag from the archive. To provide one:
autodelphirf run \
--archive my_archive.csv \
--name mydata \
--target-lag 28 \
--out autodelphirf_workIf the selected value is shorter than the diagnosed recommendation, add
--confirm-target-lag to explicitly retain it:
autodelphirf run \
--archive my_archive.csv \
--name mydata \
--target-lag 28 \
--confirm-target-lag \
--out autodelphirf_workBuild the prepared dataset and configuration without fitting models:
autodelphirf prepare \
--archive my_archive.csv \
--name mydata \
--out autodelphirf_workThen run the saved configuration:
autodelphirf run --config autodelphirf_work/mydata.jsonValidate the prepared input without model fitting:
autodelphirf run \
--config autodelphirf_work/mydata.json \
--diagnosis-onlyStart the local web application:
autodelphirf webAutoDelphiRF opens http://127.0.0.1:8765 in the default browser. The web
workflow lets you:
- Select a revision archive.
- Identify the date, location, and value columns.
- Review the pre-diagnosis.
- Confirm the target lag.
- Choose models and retraining settings.
- Start, stop, or resume the run.
- Review the results and generated report.
Use another port or output directory if needed:
autodelphirf web --port 9000 --out ~/autodelphirf_workStart the server without opening a browser automatically:
autodelphirf web --no-browserThe web application runs locally. Files selected in the page are handled by the AutoDelphiRF process on the same computer.
A complete run writes results under the selected working directory:
autodelphirf_work/
├── mydata.json
├── mydata/
│ ├── preparation.json
│ ├── inventory.csv
│ ├── test_dates.csv
│ └── prepared data files
└── results/
├── report/
│ ├── report.html
│ ├── figures/
│ └── tables/
├── predictions.csv.gz
├── predictions_wide.csv.gz
├── run_manifest.json
├── target_lag_resolution.json
├── runtime_by_method.csv
└── runtime_by_origin.csv
The HTML report is normally located at:
autodelphirf_work/results/report/report.html
Predictions and evaluation values are written on the original data scale.
python examples/make_example_archive.py --out example_archive.csv
autodelphirf diagnose --archive example_archive.csvTo run the full example:
autodelphirf run \
--archive example_archive.csv \
--name example \
--out autodelphirf_work| Variable | Purpose |
|---|---|
AUTODELPHIRF_RSCRIPT |
Path to the Rscript executable to use. |
AUTODELPHIRF_CONFIG_DIR |
Directory containing optional user configuration files. |
AUTODELPHIRF_TARGET_LAG_PARAMS |
Path to an optional target-lag configuration file. |
AUTODELPHIRF_RAW_ARCHIVE_MANIFEST |
Path to an optional raw-archive manifest. |
git clone https://github.com/cmu-delphi/AutoDelphiRF.git
cd AutoDelphiRF
python -m pip install -e ".[dev]"
python -m pytest -m "not slow"The slow tests require R and a compatible DelphiRF installation.
AutoDelphiRF is distributed under the MIT License. See LICENSE.