Skip to main content

Early signs, faster decisions. A Python library for sequential/safe testing (alpha-spending, e-processes, etc.).

Project description

PyPI version

Status Release

EarlySign


Early signs, faster decisions.

What is this?

EarlySign is a Python library for sequential/safe testing (alpha-spending, e-processes, etc.).

  1. Group sequential tests for interim analysis
    • By using alpha-spending functions to control the overall Type I error rate, you can stop early for efficacy or futility, making your experiments more efficient without compromising statistical integrity. This approach allows for a pre-specified number of interim analyses during an experiment.
  2. e-processes for anytime-valid inference
    • It allows you to continuously monitor your experiments and make decisions as soon as the evidence is strong enough, without waiting for a predetermined sample size. This can lead to faster conclusions, saving time and resources, while maintaining statistical rigor.

Install

pip install earlysign

Usage

This library supports the following steps in your experimentation.

  1. Planning / Designing
  2. Executing / Analyzing
  3. Reporting / Visualizing
  4. (optionally) Educating

Overview

from earlysign import designs

##################
# Planning phase #
##################
# A) assisted planning
design = designs.GroupSequential.from_power_analysis(
    mde=0.01,
    power=0.8,
    alpha=0.05,
    outcome_type="binary",
    num_interims=4 # analyze 4 times
)

# B) or... manually specify your experimental design
design = designs.GroupSequential(
    name="example-run", variants=["A", "B"],
    outcome_type="binary",
    alpha_spending_fn="obrien-fleming",
    max_batches=1000,
    alpha=0.05,
    efficacy=True, futility=False
)

###################
# Execution phase #
###################
# 1) execute the experiment in object-oriented style
from earlysign import Experiment
experiment = Experiment(design)  # stateful experiment object
experiment.initialize()          # init state
experiment.update(observation_1) # first batch of data
experiment.update(observation_2) # second batch of data
experiment.conclude()            # form the best advice with the current state
report = experiment.report()     # generate a report

# 2) or in functional style if you prefer
from earlysign import handlers
handler = handlers.get_handler(design)        # design-specific handler
state = handler.initial_state()              # {} -> State
state = handler.update(state, observation_1) # (Design, State, Obs) -> State
state = handler.update(state, observation_2) # (Design, State, Obs) -> State
conclusion = handler.conclude(state)         # (State) -> Conclusion
report = handlers.get_reporter(design).report(conclusion) # Conclusion -> Report

Internally, the object-oriented API is a wrapper around the functional-programming API.

Documentation

For detailed usage and available methods, see the docs.

You can also find useful tutorial here.

References

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

earlysign-0.1.6.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

earlysign-0.1.6-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file earlysign-0.1.6.tar.gz.

File metadata

  • Download URL: earlysign-0.1.6.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for earlysign-0.1.6.tar.gz
Algorithm Hash digest
SHA256 970e6ad64621cc8a36d1069e4a4c56295bf73772302e9be105dcd7140ad54fc9
MD5 bdebd6082a755cdc752e3a05571a6b6f
BLAKE2b-256 09090f0e88cc6e32e6e437bf74f065c518820e74f4a3f633c87ab99a300a6f64

See more details on using hashes here.

File details

Details for the file earlysign-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: earlysign-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for earlysign-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 edae289f0f5b0cbc1dbdaabd18bd182065d5330a6a0170693fae174f2d1f95c3
MD5 8e9032de8b5d820a565471d8a078d5f9
BLAKE2b-256 210dfc7f0ae2466755bb3caa552c50615af35e6f13335924ac81a8d21a827f8d

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