Skip to main content

Python library that designs and executes experiments on Python functions, enabling rapid experimentation.

Project description

raxpy, Python library to rapidly design and execute experiments

Testing CI - Test Code Coverage
Meta License: MIT

Description

raxpy is a Python library that designs and executes experiments on Python annotated functions. Given a Python function provided by the user, raxpy introspects the function signature to derive an experiment input-space. With a function's derived input-space, raxpy utilizes different experiment design algorithms to create a small set of function arguments, i.e., the design points, that attempt to cover the whole input-space. With the experiment design, raxpy maps the design points to the function's arguments to execute the function with each point.

To address limitations in factorial and random point selection algorithms, raxpy provide space-filling design algorithms to generate insightful results from a small number of function executions. For more information, see https://arxiv.org/abs/2501.03398.

Usage

  1. Install raxpy if not already installed.
  2. Import raxpy and typing Annotation
  3. Create a annotated function that is to be the subject of experimentation
from typing import Annotated
import raxpy


def f(
    age:Annotated[float, raxpy.Float(label="Age", lb=20.0, ub=80.0)],
    bmi:Annotated[float, raxpy.Float(label="BMI", lb=18.0, ub=40.0)],
    blood_pressure:Annotated[float, raxpy.Float(label="Blood Pressure", lb=90.0, ub=180.0)]
)-> float:
    
    glucose_factor = 0 if glucose is None else (glucose - 70) / (200 - 70)
    cholesterol_factor = 0 if cholesterol is None else (cholesterol - 150) / (300 - 150)

    bmi = (
        (age / 80) +
        ((bmi - 18) / (40 - 18)) +
        ((blood_pressure - 90) / (180 - 90)) +
        (glucose_factor) +
        (cholesterol_factor) -
        (physical_activity / 2)
    )

    return bmi
  1. Run experiment
inputs, outputs = raxpy.perform_experiment(f, n_points=10)

See examples folder for more usage examples.

Features

raxpy can execute experiments on functions with the following types of parameters:

  • float types
  • int types
  • str (categorical) types
  • Optional, None types
  • Hierarchical types based on dataclasses
  • Union types

Experiment Design Algorithm Support

raxpy provides extended versions of the following algorithms to support optional, hierarchical, and union typed inputs. The space-filling designs work best for exploration use cases when function executions are highly constrained by time and compute resources. Random designs work best when the function needs executed to support the creation of a very large dataset.

  • Space-filling MaxPro
  • Space-filling Uniform (using scipy)
  • Random

Installation

raxpy requires numpy and scipy. To install with pip, execute

pip install raxpy

To execute distributed experiments with MPI, also ensure you have the appropriate MPI cluster and install mpi4py.

Support

For community support, please use GitHub issues.

Roadmap

Version 1.0

  • Refine and test configspace adapter with hyper-parameter optimization algorithms

Version x.x

The following elements are being considered for development but not scheduled.

  • Auto-generated data schema and databases
  • Advanced trial meta-data features (point ids, run-time, status, etc.)
  • Adaptive experimentation algorithms
    • Response surface methodology
    • Sequential design algorithms
  • Support of more input-space constraint types
  • Mixture constraints
  • Multi-dimensional linear constraints
  • Surrogate optimization features
  • Trial artifact management

Contributing

This project is open for new contributions. Contributions should follow the coding style as evident in codebase and be unit-tested. New dependencies should mostly be avoided; one exception is the creation of a new adapter, such as creating an adapter to use raxpy with an optimization library.

Citing

If you used raxpy to support your academic research, please cite:

https://doi.org/10.48550/arXiv.2501.03398

Project status

raxpy is being actively developed as of 2025-01-01.

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

raxpy-0.2.1.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

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

raxpy-0.2.1-py3-none-any.whl (60.0 kB view details)

Uploaded Python 3

File details

Details for the file raxpy-0.2.1.tar.gz.

File metadata

  • Download URL: raxpy-0.2.1.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for raxpy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 82db9e6fb619930ed4708d85bbb5b488b3374d9fb438c45726816b61bbbc7f3d
MD5 c98726be903d1ee9440b14f199f3185b
BLAKE2b-256 ea29e4c25a747489d830f47c26b115967d274678e4407a245a31167ef30c8cce

See more details on using hashes here.

Provenance

The following attestation bundles were made for raxpy-0.2.1.tar.gz:

Publisher: python-package.yml on neil-r/raxpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file raxpy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: raxpy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 60.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for raxpy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e629739133d7d03c7160f2b5c5b120cb4d42a06f453a04b74c7826103e8fa7c
MD5 5ccc3d8b6c49945c35fdeca4efb0f5a2
BLAKE2b-256 0369c480a6af2c80a387729004bba477380e02bf504bce63a0b639e519832d02

See more details on using hashes here.

Provenance

The following attestation bundles were made for raxpy-0.2.1-py3-none-any.whl:

Publisher: python-package.yml on neil-r/raxpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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