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) 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.contains(data_point) >= affinity_threshold
print(f"The data point is within the ODD: {is_within_odd}")

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

License

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autosafe-1.0.3.tar.gz (114.2 kB view details)

Uploaded Source

Built Distribution

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

autosafe-1.0.3-py3-none-any.whl (149.0 kB view details)

Uploaded Python 3

File details

Details for the file autosafe-1.0.3.tar.gz.

File metadata

  • Download URL: autosafe-1.0.3.tar.gz
  • Upload date:
  • Size: 114.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for autosafe-1.0.3.tar.gz
Algorithm Hash digest
SHA256 6eaacec82c7dc457cd94dfae32a94e503d67e527e794de53bb02cd6c82de95aa
MD5 9e4139adc3e2f1addc75744a7281d5e0
BLAKE2b-256 a6c54d24fa8bbc12424c8d6f1e402bcd2f7f7b24b1ace5aef431cf95b3e0a5b2

See more details on using hashes here.

File details

Details for the file autosafe-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: autosafe-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 149.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for autosafe-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f57faf7789f19309615c7659e204a88d8952f5e22fef54daabcb16c303f7bdf4
MD5 1b5c143dde8565cecda9ce7e5ddc4d77
BLAKE2b-256 b684ce332ea299a5448de8e5d898422d6b0980f6fc0835a4a2e1ce26b4643950

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.0

2 files

This release

1.0.3 This release

2 files

1.0.1

2 files

Supported by

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