Metadata-Version: 2.4
Name: argenta-cml
Version: 0.1.0
Summary: Warehouse-native causal ML experimentation platform
Project-URL: Homepage, https://github.com/argenta-ml/argenta
Project-URL: Documentation, https://argenta-ml.github.io/argenta
Project-URL: Repository, https://github.com/argenta-ml/argenta
Project-URL: Issues, https://github.com/argenta-ml/argenta/issues
Author: Argenta Contributors
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship made available under
              the License, as indicated by a copyright notice that is included in
              or attached to the work (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other transformations
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean, as submitted to the Licensor for inclusion
              in the Work by the copyright owner or by an individual or Legal Entity
              authorized to submit on behalf of the copyright owner. For the purposes
              of this definition, "submitted" means any form of electronic, verbal,
              or written communication sent to the Licensor or its representatives,
              including but not limited to communication on electronic mailing lists,
              source code control systems, and issue tracking systems that are managed
              by, or on behalf of, the Licensor for the purpose of discussing and
              improving the Work, but excluding communication that is conspicuously
              marked or designated in writing by the copyright owner as "Not a
              Contribution."
        
              "Contributor" shall mean Licensor and any Legal Entity on behalf of
              whom a Contribution has been received by the Licensor and included
              within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by the combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a cross-claim
              or counterclaim in a lawsuit) alleging that the Work or any Contribution
              embodied within the Work constitutes direct or contributory patent
              infringement, then any patent licenses granted to You under this License
              for that Work shall terminate as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or Derivative
                  Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, You must include a readable copy of the
                  attribution notices contained within such NOTICE file, in
                  at least one of the following places: within a NOTICE text
                  file distributed as part of the Derivative Works; within
                  the Source form or documentation, if provided along with the
                  Derivative Works; or, within a display generated by the
                  Derivative Works, if and wherever such third-party notices
                  normally appear. The contents of the NOTICE file are for
                  informational purposes only and do not modify the License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor.
        
           7. Disclaimer of Warranty. Unless required by applicable law or agreed
              to in writing, Licensor provides the Work on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any conditions of TITLE,
              MERCHANTIBILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
              responsible for determining the appropriateness of using or
              redistributing the Work and assume any risks associated with Your
              exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or exemplary damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (even if such Contributor has been advised of the possibility
              of such damages).
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may offer only
              conditions consistent with this License.
        
           END OF TERMS AND CONDITIONS
        
           Copyright 2024 Argenta Contributors
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
License-File: LICENSE
Keywords: a-b-testing,causal-inference,cuped,experimentation,heterogeneous-treatment-effects,uplift-modeling,warehouse
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.10
Requires-Dist: jinja2>=3.1
Requires-Dist: numpy>=1.25
Requires-Dist: pandas>=2.0
Requires-Dist: pydantic>=2.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: scipy>=1.11
Requires-Dist: statsmodels>=0.14
Provides-Extra: all
Requires-Dist: db-dtypes>=1.0; extra == 'all'
Requires-Dist: econml>=0.15; extra == 'all'
Requires-Dist: google-cloud-bigquery>=3.0; extra == 'all'
Requires-Dist: lightgbm>=4.0; extra == 'all'
Requires-Dist: redshift-connector>=2.0; extra == 'all'
Requires-Dist: scikit-learn>=1.3; extra == 'all'
Requires-Dist: snowflake-connector-python>=3.0; extra == 'all'
Provides-Extra: bigquery
Requires-Dist: db-dtypes>=1.0; extra == 'bigquery'
Requires-Dist: google-cloud-bigquery>=3.0; extra == 'bigquery'
Provides-Extra: causal
Requires-Dist: econml>=0.15; extra == 'causal'
Requires-Dist: lightgbm>=4.0; extra == 'causal'
Requires-Dist: scikit-learn>=1.3; extra == 'causal'
Provides-Extra: dev
Requires-Dist: mypy>=1.5; extra == 'dev'
Requires-Dist: pandas-stubs>=2.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1; extra == 'dev'
Provides-Extra: redshift
Requires-Dist: redshift-connector>=2.0; extra == 'redshift'
Provides-Extra: snowflake
Requires-Dist: snowflake-connector-python>=3.0; extra == 'snowflake'
Description-Content-Type: text/markdown

<p align="center">
  <img src="assets/logo.svg" alt="Argenta" width="420"/>
</p>

<p align="center">
  <a href="https://pypi.org/project/argenta-cml/"><img src="https://img.shields.io/pypi/v/argenta-cml?color=blue&style=flat-square" alt="PyPI version"/></a>
  <a href="https://pypi.org/project/argenta-cml/"><img src="https://img.shields.io/pypi/pyversions/argenta-cml?style=flat-square" alt="Python"/></a>
  <a href="https://github.com/athammad/argenta/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/athammad/argenta/ci.yml?branch=master&label=CI&style=flat-square" alt="CI"/></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-green?style=flat-square" alt="License"/></a>
  <a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/badge/code%20style-ruff-orange?style=flat-square" alt="Code style: ruff"/></a>
</p>

**Warehouse-native causal ML for experimentation.**

Most A/B testing tools answer one question: *Did the experiment work?*

Argenta answers: *For **whom** did it work, **why**, and **what should you do next**?*

---

## What Argenta Is

Argenta is an analytics layer that connects to your existing data warehouse, runs a SQL pipeline
inside it to construct an experiment dataset, and then applies causal ML methods to produce
results your current tool doesn't: heterogeneous treatment effects (HTE), per-user CATE scores,
automatic subgroup discovery, and targeted rollout recommendations.

It works with experiments you've already run — using whatever tool assigned variants (Statsig,
LaunchDarkly, Optimizely, homegrown feature flags). Argenta only analyzes.

## What Argenta Is NOT

- **Not an A/B testing platform.** Argenta does not assign variants or run feature flags.
- **Not a real-time system.** Analysis runs post-hoc, after experiments have collected data.
- **Not a data pipeline tool.** Argenta does not move or replicate your data. SQL runs inside
  your warehouse; results are written back to a schema you control.

---

## Quick Start

### 1. Install

```bash
# Pick your warehouse:
pip install "argenta-cml[snowflake]"
pip install "argenta-cml[bigquery]"
pip install "argenta-cml[redshift]"
pip install "argenta-cml[all]"   # all warehouses
```

### 2. Create a config file

```yaml
# argenta.yaml
warehouse:
  warehouse_type: snowflake
  output_schema: argenta
  credentials:
    account: my_account
    user: argenta_svc
    password: "${SNOWFLAKE_PASSWORD}"
    database: ANALYTICS
    schema: PUBLIC
    warehouse: COMPUTE_WH

exposures:
  table: ANALYTICS.PUBLIC.STATSIG_EXPOSURES
  user_id_col: user_id
  experiment_id_col: experiment_name
  variant_col: group
  timestamp_col: exposure_time

outcomes:
  table: ANALYTICS.PUBLIC.EVENTS
  user_id_col: user_id
  event_name_col: event_type
  value_col: revenue
  timestamp_col: event_time
  target_events:
    - purchase
    - add_to_cart

user_features:
  table: ANALYTICS.PUBLIC.USER_DIM
  user_id_col: user_id
  feature_cols:
    - country
    - device_type
    - account_age_days
  covariate_col: pre_experiment_revenue

experiment:
  experiment_id: checkout_redesign_2024
  control_variant: control
  treatment_variant: treatment
  alpha: 0.05
  winsorize_percentile: 0.99
  use_cuped: true
```

### 3. Run

```python
from argenta import ArgentoConfig, PipelineRunner
from argenta.config.loader import load_config

config = load_config("argenta.yaml")
runner = PipelineRunner(config)
result = runner.run("checkout_redesign_2024")

print(result)
```

Results are also written back to your warehouse at `argenta.experiment_results`.

---

## Architecture

```
Your warehouse (Snowflake / BigQuery / Redshift)
         │
         │  read-only + write to argenta schema
         ▼
Argenta SQL pipeline (runs INSIDE your warehouse)
  ├── 1. Exposure deduplication   — first exposure per user wins
  ├── 2. Outcome join             — only events after first exposure
  └── 3. User feature join        — covariates for CUPED + future CATE
         │
         ▼
Argenta stats layer (Python)
  ├── ATE + Welch CI + p-value
  ├── Winsorization
  ├── SRM detection
  └── CUPED variance reduction
         │
         ▼
Results written back to your warehouse
  ├── argenta.experiment_results   — per-metric ATE, CI, p-value
  ├── argenta.user_cate_scores     — per-user CATE (Phase 2)
  └── argenta.segment_effects      — HTE by segment (Phase 2)
```

---

## Statistical Methods

| Method | Purpose |
|---|---|
| Welch's t-test | ATE + p-value |
| Confidence intervals | 95% CI on ATE |
| Winsorization | Outlier handling for revenue metrics |
| SRM detection | Sample ratio mismatch check |
| CUPED | Variance reduction via pre-experiment covariate |
| Causal Forest (CausalForestDML) | Non-parametric CATE estimation |
| X-Learner | CATE with unbalanced treatment/control |
| Uplift modeling | Score users not in experiment |
| Sequential testing (mSPRT) | Always-valid p-values |
| Multiple testing correction | Bonferroni / BH-FDR across metrics |

---

## Input Tables Required

Argenta needs three tables in your warehouse (all column names are configurable):

| Table | Required columns |
|---|---|
| Exposures | `user_id`, `experiment_id`, `variant`, `timestamp` |
| Outcomes / events | `user_id`, `event_name`, `value`, `timestamp` |
| User features | `user_id`, + any feature columns |

The user features table is required for CUPED variance reduction. Without it, set `use_cuped: false`.

---

## Output Tables

Argenta writes results back to `{output_schema}` in your warehouse (default: `argenta`):

| Table | Contents |
|---|---|
| `argenta.experiment_results` | ATE, CI, p-value, SRM flag per metric |
| `argenta.user_cate_scores` | Per-user CATE score |
| `argenta.segment_effects` | HTE by segment |

---

## Supported Warehouses

| Warehouse | Extra | Status |
|---|---|---|
| Snowflake | `argenta[snowflake]` | Supported |
| BigQuery | `argenta[bigquery]` | Supported |
| Redshift | `argenta[redshift]` | Supported |
| Databricks | `argenta[databricks]` | Planned |

---

## Documentation

- [Architecture](docs/architecture.md)
- [Onboarding a new warehouse](docs/onboarding.md)
- [SQL pipeline explained](docs/sql_pipeline.md)
- [Statistics reference](docs/statistics.md)
- [Contributing](CONTRIBUTING.md)

---

## Contributing

Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions,
coding conventions, and the PR process.

---

## License

Apache 2.0. See [LICENSE](LICENSE).

---

## Side note

The name "Argenta" is inspired by the name of a professor who introduced me to causal inference during my bachelor's degree.
