Skip to main content

The official safety cage package for misclassification detection in predictive models.

Project description

SafetyCage

SafetyCage is a Python package for detecting misclassified predictions from machine learning models in classification tasks. It provides a unified interface for multiple statistical detection methods, enabling users to quantify prediction reliability and flag potentially incorrect outputs across different models and datasets easily.

It is available on PyPI here: https://pypi.org/project/safetycage/.

Background

The idea behind safetycage is that we can find statistics on each predicted sample, and compare that statisitic to some statisitc threshold "alpha" to predict whether the sample prediction was incorrectly classified.

Description

Machine learning models can produce incorrect predictions with high confidence. SafetyCage addresses this by providing post-hoc misclassification detection methods that operate on model outputs or internal representations.

The package includes several methods:

  • MSP (Maximum Softmax Probability)
  • DOCTOR (Error probability estimation)
  • Mahalanobis (Distance-based statistical testing)
  • SPARDACUS (Projection + density estimation approach)

Each method outputs a statistic or p-value that reflects how likely a prediction is to be incorrect.

Alternatively, you can implement your own method by initializing a base class from the safetycage abstract base class, that defines how methods should be implemented.

Requirements

SafetyCage uses Python 3.11.7. Consider creating an environment for your project with safetycage that uses Python 3.11.7.

Installation

Install via pip using the command:

pip install safetycage

The only additional packages you will need to work with safetycage are those required by your dataset and model.

Visuals

  • could put a gif on installing and using the package - don't think this is very necessary, should be obvious

Tutorials & Examples

A separate repository contains full examples and tutorials at https://github.com/safety-cage/safetycage-tutorials.

Support

If you encounter issues or have questions:

  • Open an issue on the repository
  • Check the safetycage-tutorials repo for examples

Roadmap

  • TBD

Contributing

  • unsure

Authors and acknowledgment

  • TBA

License

MIT License

Project status

  • active and under devlopment

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

safetycage-0.0.3.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safetycage-0.0.3-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file safetycage-0.0.3.tar.gz.

File metadata

  • Download URL: safetycage-0.0.3.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for safetycage-0.0.3.tar.gz
Algorithm Hash digest
SHA256 15d70aa5157d5406f0c0325b9f38c88e7c47e1e1a4e1f151f3d2a779b39cf7a0
MD5 0b7602e499b70744e771797a23413b18
BLAKE2b-256 70d5d3d5f68a0c8be827c047156d1a4d7b64e8ac7fbd4b637fc6efd8c7133267

See more details on using hashes here.

File details

Details for the file safetycage-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: safetycage-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for safetycage-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ff19dd3a290c0393af8e0d7b8e19001ee5697407aa658e727e57c302e11fc1b9
MD5 70ce62099f92a8628d4117273e2f55d1
BLAKE2b-256 fa73d93150dd7f6091f9def4606152d3edccbd093ab50ce237aea9256c5c94a0

See more details on using hashes here.

Supported by

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