Skip to main content

checkrs

Tests

Tools for simulation-based model checking.

Description

The checkrs package contains functions for creating 7 model checking/diagnostic plots described in

Brathwaite, Timothy. "Check yourself before you wreck yourself: Assessing discrete choice models through predictive simulations" arXiv preprint arXiv:1806.02307 (2018). https://arxiv.org/abs/1806.02307.

Beyond the plots described in this paper, checkrs enables the creation of reliability and marginal model plots that use continuous scatterplot smooths based on Extremely Randomized Trees as kernel estimators, as opposed to only allowing discrete smooths based on binning.

As for the name, checkrs is a play on the word "checkers," i.e., those tools one uses to check, or one who checks. The name is also a play on the phrases "check the research of scientists" and "check research scientists."

Installation

pip install checkrs

Usage

Note that example_project is fictitious! This example is, literally, just an example.

from checkrs import ChartData, ViewSimCDF

from example_project import load_data

design, targets_observed, targets_simulated = load_data()

chart_data = ChartData.from_raw(
  targets=targets_observed,  # 1D Ndarray or Tensor
  targets_simulated=targets_simulated, # 2D Ndarray or Tensor
  design=design # DataFrame or None
)

chart = ViewSimCDF.from_chart_data(chart_data)

chart_plotnine = chart.draw(backend="plotnine")
chart_altair = chart.draw(backend="altair")

####
## Save to a variety of formats
####
# chart.save("temp_plot.png")
# chart.save("temp_plot.pdf")
# chart.save("temp_plot.json")
# chart.save("temp_plot.html")

See docstrings for ChartData.from_raw, ViewSimCDF.from_chart_data, and ViewSimCDF.save.

To-Do:

  • Add package to conda and conda-forge

Development installation

To work on and edit checkrs, the following setup process may be useful.

  1. from the project root, create an environment checkrs with the help of conda,
    cd checkrs
    conda env create -n checkrs -f environment.yml
    
  2. activate the new environment with
    conda activate checkrs
    
  3. install checkrs in an editable fashion using:
    flit install --pth-file
    

Optional and needed only once after git clone:

  1. install several pre-commit git hooks with:
    pre-commit install
    
    and checkout the configuration under .pre-commit-config.yaml. The -n, --no-verify flag of git commit can be used to deactivate pre-commit hooks temporarily.

Then take a look into the scripts and notebooks folders.

Dependency Management & Reproducibility

  1. Always keep your abstract (unpinned) dependencies updated in environment.yml, requirements.in, and eventually in pyproject.toml if you want to ship and install the package via pip later on.

    • Use environment.yml for dependencies that cannot be installed via pip.
    • Use requirements.in for dependencies that can be installed via pip.
    • Use pyproject.toml for dependencies that are needed for checkrs to function at all, not just in development.
  2. Create concrete dependencies as requirements.txt for the exact reproduction of your environment with:

    pip-compile requirements.in
    
  3. Manually update any non-pip dependencies in environment.yml, being sure to pin any such dependencies to a specific version.

  4. Update your current environment using:

    conda env update -f environment.yml
    

    Or

    pip install -r requirements.txt
    

    if you did not update any non-pip dependencies.

Project Organization

├── AUTHORS.rst             <- List of developers and maintainers.
├── CHANGELOG.rst           <- Changelog to keep track of new features and fixes.
├── LICENSE.txt             <- License as chosen on the command-line.
├── README.md               <- The top-level README for developers.
├── configs                 <- Directory for configurations of model & application.
├── data
│   ├── external            <- Data from third party sources.
│   ├── interim             <- Intermediate data that has been transformed.
│   ├── processed           <- The final, canonical data sets for modeling.
│   └── raw                 <- The original, immutable data dump.
├── docs                    <- Directory for Sphinx documentation in rst or md.
├── environment.yaml        <- The conda environment file for reproducibility.
├── models                  <- Trained and serialized models, model predictions,
│                              or model summaries.
├── notebooks               <- Jupyter notebooks. Naming convention is a number (for
│                              ordering), the creator's initials and a description,
│                              e.g. `1.0-fw-initial-data-exploration`.
├── references              <- Data dictionaries, manuals, and all other materials.
├── reports                 <- Generated analysis as HTML, PDF, LaTeX, etc.
│   └── figures             <- Generated plots and figures for reports.
├── scripts                 <- Analysis and production scripts which import the
│                              actual PYTHON_PKG, e.g. train_model.
├── setup.cfg               <- Declarative configuration of your project.
├── setup.py                <- Use `python setup.py develop` to install for development or
|                              or create a distribution with `python setup.py bdist_wheel`.
├── src
│   └── checkrs             <- Actual Python package where the main functionality goes.
├── tests                   <- Unit tests which can be run with `py.test`.
├── .coveragerc             <- Configuration for coverage reports of unit tests.
├── .isort.cfg              <- Configuration for git hook that sorts imports.
└── .pre-commit-config.yaml <- Configuration of pre-commit git hooks.

Note

This project has been set up using PyScaffold 3.3a1 and the dsproject extension 0.4. For details and usage information on PyScaffold see https://pyscaffold.org/.

Metadata

Release files for checkrs 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for checkrs 0.2.0
File Size Uploaded Provenance Actions
checkrs-0.2.0.tar.gz 301.8 kB Without provenance Details for checkrs-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for checkrs 0.2.0
File Interpreter ABI Platform Actions
checkrs-0.2.0-py3-none-any.whl Python 3 none any Details for checkrs-0.2.0-py3-none-any.whl

Total release size: 344.8 kB

Release files / checkrs-0.2.0.tar.gz

Download URL checkrs-0.2.0.tar.gz
Size 301.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f843f778316fbfb28d90e7803613f0aa5b0c41678f0bd15154d82fed164b912c
BLAKE2b-256 checksum
How to use checksums
35ecf816238e23d3671e6d24456f40a227d2164bf3108977cc524369cee0e0fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.24.0

Release files / checkrs-0.2.0-py3-none-any.whl

Download URL checkrs-0.2.0-py3-none-any.whl
Size 43.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9cbaa3492ff5ce82e9f03c8331161a3d6dedb1d99c478ad394353e7d20e9eba0
BLAKE2b-256 checksum
How to use checksums
8b518c066318f37d425d14b7cd1121cd3ef59caf31ea8a6010fdb94b17a5bfc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.24.0

Security for checkrs 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page