Skip to main content

Comparing Sequential Forecasters

Project description

ComparingForecasters

image image

Code accompanying our paper, Comparing Sequential Forecasters (arXiv preprint), where we derive time-uniform, distribution-free, and non-asymptotic confidence sequences (CS), as well as e-processes, for comparing forecasts on sequential data.

Installation

Requires Python 3.7+.

From pip:

pip install --upgrade pip
pip install --upgrade comparecast

From source:

git clone https://github.com/yjchoe/ComparingForecasters
cd ComparingForecasters

pip install --upgrade pip
pip install -e .

Data Sources

See data/README.md.

Sample Usage

Python

import comparecast as cc

# Generate/retrieve synthetic data
data = cc.data_utils.synthetic.get_data("default", size=1000)

# Calculate forecasts
forecasters = ["k29_poly3", "laplace", "always_0.5"]
data = cc.forecast(data, forecasters, out_file="data/test.csv") 
cc.plot_forecasts(data, forecasters, plots_dir="plots/test")

# Compare forecasts using confidence sequences & e-values
lcbs, ucbs, evalues = cc.compare_forecasts(
    data, 
    "k29_poly3", 
    "laplace", 
    scoring_rule="brier", 
    alpha=0.05,
    boundary_type="mixture",
    v_opt=10,
    compute_evalues=True,
)

# Draw a comparison plot
results, axes = cc.plot_comparison(
    data, 
    "k29_poly3", 
    "laplace", 
    scoring_rule="brier", 
    alpha=0.05,
    boundary_type="mixture",
    compare_baselines=("h", "acs"),
    plot_width=True,
    plots_dir="plots/test",
)

Command Line Interface

# Generate synthetic data and forecasts
python forecast.py -d default -n 1000 -f all \
    -o forecasts/test.csv -p plots/test

# Compare forecasts and plot results
python plot_comparisons.py -d forecasts/test.csv -p k29_poly3 -q laplace \
    --compare-baselines h acs --plot-width -o plots/test
    
# Compare 538 and vegas forecasters
python plot_comparisons.py -d forecasts/mlb_2010_2019.csv \
    -p fivethirtyeight -q vegas \
    --compare-baselines acs --plot-width -o plots/mlb_2010_2019

Experiments

License

MIT

Authors

YJ Choe and Aaditya Ramdas

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

comparecast-0.1.2.tar.gz (29.6 kB view hashes)

Uploaded Source

Built Distribution

comparecast-0.1.2-py3-none-any.whl (33.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page