Skip to main content

autoSAFE logo


The latest version of autosafe can be found on PyPI. Information on what versions of Python autosafe supports can be found on PyPI. Python tests (pytest) Coverage Docs status uv Ruff ty prek REUSE status Conventional Commits

Reference implementation of the autoSAFE specification.

autoSAFE can derive semantically correct Operational Design Domains (ODDs) purely from data. This allows to automatically generate ODDs for machine learning-based functions. The use cases range from data-driven ODD definition over ODD monitoring to retrofitting existing functions with ODDs. Moreover, if no ODD is given for a certain dataset, autoSAFE can derive one automatically to ensure safe operations of the resulting AI-based system

Installation

We recommend using uv to manage the virtual environment and dependencies. Simply running uv sync will create a virtual environment and install all dependencies as specified in pyproject.toml.

CVXOPT

Users might want to optionally install CVXOPT for enhanced performance. However, as CVXOPT is licensed under GPL-v3, it is not included as a dependency by default. Moreover, CVXOPT is not compatible with Python versions >= 3.14 or free-threaded builds as of now.

Usage

CLI

autoSAFE provides a command-line interface (CLI) for easy interaction. After installing the package, you can use the autosafe command in your terminal:

uv run autosafe --help

This will list all available commands and options. They are described in detail in the documentation.

Common CLI Commands

Here are the most frequently used commands:

Monte Carlo Sampling and Evaluation

# Run Monte Carlo sampling with default 2D box ODD
autosafe montecarlo sample --dim 2 --odd-limits 5.0 --samples 1000 --filename mc_results.json

# Evaluate results and generate precision/recall plots
autosafe montecarlo evaluate mc_results.json

ODD Comparison Methods

# Quick comparison with default parameters
autosafe comparison quick data/WineQT.csv --export results.json

# Full comparison with custom parameters
autosafe comparison evaluate data/WineQT.csv \
    --methods knn kmeans density \
    --knn-k 5 --kmeans-clusters 4 --density-gamma 0.01

Custom ODD with Inequalities

# Use YAML config for polytope with inequality constraints
autosafe montecarlo sample --odd-config odd_config.yaml

API

autoSAFE also offers a Python API for more advanced usage. To start, you can read your data from a CSV file and create an autoSAFE ODD as follows:

import autosafe as af
import numpy as np

# Load data from a CSV file
odd = af.from_csv(af.ROOT_FOLDER / "data" / "iris.csv")

# Query the ODD for a new data point
affinity_threshold = 0.8
data_point = np.array([[5.1, 3.5, 1.4, 0.2]])
is_within_odd = odd(data_point) >= affinity_threshold
print(f"The data point is within the ODD: {is_within_odd}")

De-duplication of repeated-visit anchors is OFF by default (enabling it changes the anchor set, so previously computed results are not comparable); see docs/pages/deduplication.rst for the full policy and pipeline details:

from autosafe.deduplication import exact_equality_policy

policy = exact_equality_policy(n_dims=4)
odd = af.from_csv(af.ROOT_FOLDER / "data" / "iris.csv", dedup_policy=policy)

Developing

Pre-Commit Hooks

We use prek to manage pre-commit hooks for code quality and consistency. To install the pre-commit hooks, run the following command from the project root:

uv run prek install

Tests

We use pytest for testing. To run the test suite, execute the following command from the project root:

uv run pytest

Reproducing the paper's results

The result artifacts underlying every figure and table in the paper, the archive record (once published), and the exact commands to regenerate them from scratch are documented in REPRODUCTION.md.

License

Copyright and license information are provided in accordance to the REUSE Specification 3.3.

Metadata

Release files for autosafe 2.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 autosafe 2.2.0
File Size Uploaded Provenance Actions
autosafe-2.2.0.tar.gz 212.2 kB Without provenance Details for autosafe-2.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 475.9 kB

Release files / autosafe-2.2.0.tar.gz

Download URL autosafe-2.2.0.tar.gz
Size 212.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1cfbb559c3aef355af4023e16e2f0372b3faa9d4993c8cc37ae4bc42e6f025f4
BLAKE2b-256 checksum
How to use checksums
19c3cb3000c1a74ea830a23b8d41985ce6a576ec02583e1d9996ead93f082d0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / autosafe-2.2.0-py3-none-any.whl

Download URL autosafe-2.2.0-py3-none-any.whl
Size 263.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
835ccb84dd5f65e88a894774705ccd41bcd3bdebfd9e905ea42bb20964a4a0d3
BLAKE2b-256 checksum
How to use checksums
164417278d02a333e9dfc451b1f137fe3bedde0cccf8b6d88d6b3c2daeee900a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for autosafe 2.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