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.2.tar.gz (28.4 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.2-py3-none-any.whl (36.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: safetycage-0.0.2.tar.gz
  • Upload date:
  • Size: 28.4 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.2.tar.gz
Algorithm Hash digest
SHA256 9198da82c5da07f1d457e319b3b42d46074fdca25e3a0564ea2b27cfd8961a7a
MD5 255ff553861213ecf3e70771d1f3cf4d
BLAKE2b-256 3810c9a1324252b3aa82ac4f420c1c002bc779c510c8e0a70fdf32431c43003b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: safetycage-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 36.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 26d6b322db2112d790fded7433cd4ae91fc7308b0579bf36787526494befee4e
MD5 80d9f0d1c147c3329b6cac437b62b65a
BLAKE2b-256 26b6fdab2197fb2a2e06a3637e6d4bb1fbfb858de62c02fabd2a7d3f246b43bf

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