Skip to main content

a package for investigating and comparing the predictive uncertainties from deep learning models

Project description

DeepUQ

DeepUQ is a package for injecting and measuring different types of uncertainty in ML models.

PyPi License Downloads

Installation

Install the deepuq package via venv and pypi

python3.10 -m venv name_of_your_virtual_env

source name_of_your_virtual_env/bin/activate

pip install deepuq

Now you can run some of the scripts!

UQensemble --generatedata

^generatedata is required if you don't have any saved data. You can set other keywords like so.

It's also possible to verify the install works by running:

pytest

Preferred dev install option: Poetry

If you'd like to contribute to the package development, please follow these instructions.

First, navigate to where you'd like to put this repo and type:

git clone https://github.com/deepskies/DeepUQ.git

Then, cd into the repo:

cd DeepUQ

Poetry is our recommended method of handling a package environment as publishing and building is handled by a toml file that handles all possibly conflicting dependencies. Full docs can be found here.

Install instructions:

Add poetry to your python install

pip install poetry

Then, from within the DeepUQ repo, run the following:

Install the pyproject file

poetry install

Begin the environment

poetry shell

Now you have access to all the dependencies necessary to run the package.

Package structure

DeepUQ/
├── CHANGELOG.md
├── LICENSE.txt
├── README.md
├── DeepUQResources/
├── data/
├── notebooks/
├── poetry.lock
├── pyproject.toml
├── deepuq/
│   ├── __init__.py
│   ├── analyze/
│   │   ├── __init__.py
│   │   ├── analyze.py
│   ├── data/
│   │   ├── __init__.py
│   │   ├── data.py
│   ├── models/
│   │   ├── __init__.py
│   │   ├── models.py
│   ├── scripts/
│   │   ├── __init__.py
│   │   ├── DeepEnsemble.py
│   │   ├── DeepEvidentialRegression.py
│   ├── train/
│   │   ├── __init__.py
│   │   ├── train.py
│   └── utils/
│   │   ├── __init__.py
│   │   ├── defaults.py
│   │   ├── config.py
├── test/
│   ├── DeepUQResources/
│   ├── data/
│   ├── test_DeepEnsemble.py
│   └── test_DeepEvidentialRegression.py

The deepuq/ folder contains the relevant modules for config settings, data generation, model parameters, training, and the two scripts for training the Deep Ensemble and the Deep Evidential Regression models. It also includes tools for loading and analyzing the saved checkpoints in analysis/.

Example notebooks for how to train and analyze the results of the models can be found in the notebooks/ folder.

The DeepUQResources/ folder is the default location for saving checkpoints from the trained model and the data/ folder is where the training and validation set are saved.

How to run the workflow

The scripts can be accessed via the ipython example notebooks or via the model modules (ie DeepEnsemble.py). For example, to ingest data and train a Deep Ensemble from the DeepUQ/ directory:

python deepuq/scripts/DeepEnsemble.py

The equivalent shortcut command:

UQensemble

With no config file specified, this command will pull settings from the default.py file within utils. For the DeepEnsemble.py script, it will automatically select the DefaultsDE dictionary.

Another option is to specify your own config file:

python deepuq/scripts/DeepEnsemble.py --config "path/to/config/myconfig.yaml"

Where you would modify the "path/to/config/myconfig.yaml" to specify where your own yaml lives.

The third option is to input settings on the command line. These choices are then combined with the default settings and output in a temporary yaml.

python deepuq/scripts/DeepEnsemble.py --noise_level "low" --n_models 10 --out_dir ./DeepUQResources/results/ --save_final_checkpoint True --savefig True --n_epochs 10

This command will train a 10 network, 10 epoch ensemble on the low noise data and will save figures and final checkpoints to the specified directory. Required arguments are the noise setting (low/medium/high), the number of ensembles, and the working directory.

For more information on the arguments:

python deepuq/scripts/DeepEnsemble.py --help

The other available script is the DeepEvidentialRegression.py script:

python deepuq/scripts/DeepEvidentialRegression.py --help

The shortcut:

UQder

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

deepuq-0.1.5.tar.gz (565.5 kB view details)

Uploaded Source

Built Distribution

deepuq-0.1.5-py3-none-any.whl (526.9 kB view details)

Uploaded Python 3

File details

Details for the file deepuq-0.1.5.tar.gz.

File metadata

  • Download URL: deepuq-0.1.5.tar.gz
  • Upload date:
  • Size: 565.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/23.6.0

File hashes

Hashes for deepuq-0.1.5.tar.gz
Algorithm Hash digest
SHA256 32f4ccab227e7c994396ca8711daa272b54bc53c938bffe32563ad45e604326d
MD5 9e4e9f9fcdcc5c04bb37e82061415588
BLAKE2b-256 ac3886876a657970d1d0c07801f968492430df3770dc8730cf5b154a731f186b

See more details on using hashes here.

File details

Details for the file deepuq-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: deepuq-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 526.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/23.6.0

File hashes

Hashes for deepuq-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d5a32c37ad4621881442a8a4741ba2fff888776076f9fffdafedcc9078466514
MD5 e2f2d37b8d790ad6c9e14e77d9452c4d
BLAKE2b-256 f5b02ed4d32587a4643f4a222bc0375344727f7dd14a363cbb750f8d26a078bf

See more details on using hashes here.

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