Skip to main content

Set of utility functions for analyzing experimental and observational data

Project description

ci PyPI version

Experiment utils

Generic functions for experiment analysis and design:

Installation

PyPI

pip install experiment-utils-pd

From GitHub

pip install git+https://github.com/sdaza/experiment-utils-pd.git

How to use it

Experiment Analyzer

df is a Pandas DataFrame:

from experiment_utils import ExperimentAnalyzer

# Example with balance adjustment and balance_method
analyzer = ExperimentAnalyzer(
    df,
    treatment_col="treatment",
    outcomes=['registrations', 'visits'],
    covariates=covariates,
    experiment_identifier=["campaign_key"],
    adjustment="balance",  # Options: 'balance', 'IV', or None
    balance_method="ps-logistic",  # Options: 'ps-logistic', 'ps-xgboost', 'entropy'
    target_effect="ATT"  # Options: 'ATT', 'ATE', 'ATC'
)

analyzer.get_effects()
print(analyzer.results)

Parameters:

  • adjustment: Choose 'balance' for covariate balancing (using balance_method), 'IV' for instrumental variable adjustment, or None for unadjusted analysis.
  • balance_method: Selects the method for balancing: 'ps-logistic' (logistic regression), 'ps-xgboost' (XGBoost), or 'entropy' (entropy balancing).
  • target_effect: Specifies the estimand: 'ATT', 'ATE', or 'ATC'.

Power Analysis

from experiment_utils import PowerSim
p = PowerSim(metric='proportion', relative_effect=False,
  variants=1, nsim=1000, alpha=0.05, alternative='two-tailed')

p.get_power(baseline=[0.33], effect=[0.03], sample_size=[3000])

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

experiment_utils_pd-0.1.7.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.

experiment_utils_pd-0.1.7-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file experiment_utils_pd-0.1.7.tar.gz.

File metadata

  • Download URL: experiment_utils_pd-0.1.7.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for experiment_utils_pd-0.1.7.tar.gz
Algorithm Hash digest
SHA256 0cbc47f5dc9b62965303a66a33db44e1df485c643fc24b8e86718b23903eaad9
MD5 16be5a65fdae9cbaffaef68e8ee28eef
BLAKE2b-256 b136de634e8f0fade598440a93b91c9b3b7cea36d2a2dc767b5496eb47584ab4

See more details on using hashes here.

File details

Details for the file experiment_utils_pd-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for experiment_utils_pd-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7cf56ffbad6d2d84689424827f41f5783da5be17d8f9ec6131e0942be396264b
MD5 94b8a92f62802899d9d1fe84e94f0225
BLAKE2b-256 bc031305d956ac142b9fe994cca9fce0afe676c4a3da1fd90cfd9dd5d13b36ea

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