Metadata-Version: 2.2
Name: elaraai-east-py-datascience
Version: 1.0.112
Summary: East Data Science - ML/optimization platform functions for East Python runtime
License: BSL-1.1
Requires-Python: >=3.12
Requires-Dist: elaraai-east-py
Requires-Dist: numpy>=2.0.0
Provides-Extra: mads
Requires-Dist: PyNomadBBO>=4.4.0; extra == "mads"
Provides-Extra: optuna
Requires-Dist: optuna>=4.0.0; extra == "optuna"
Provides-Extra: simanneal
Requires-Dist: simanneal>=0.5.0; extra == "simanneal"
Provides-Extra: sklearn
Requires-Dist: scikit-learn<1.6.0,>=1.4.0; extra == "sklearn"
Requires-Dist: skl2onnx>=1.17.0; extra == "sklearn"
Requires-Dist: onnxruntime>=1.18.0; extra == "sklearn"
Requires-Dist: cloudpickle>=3.0.0; extra == "sklearn"
Provides-Extra: scipy
Requires-Dist: scipy>=1.12.0; extra == "scipy"
Requires-Dist: cloudpickle>=3.0.0; extra == "scipy"
Provides-Extra: xgboost
Requires-Dist: xgboost>=3.4.0; extra == "xgboost"
Requires-Dist: cloudpickle>=3.0.0; extra == "xgboost"
Provides-Extra: lightgbm
Requires-Dist: lightgbm>=4.3.0; extra == "lightgbm"
Requires-Dist: cloudpickle>=3.0.0; extra == "lightgbm"
Provides-Extra: ngboost
Requires-Dist: ngboost>=0.5.0; extra == "ngboost"
Requires-Dist: cloudpickle>=3.0.0; extra == "ngboost"
Provides-Extra: shap
Requires-Dist: shap>=0.45.0; extra == "shap"
Requires-Dist: cloudpickle>=3.0.0; extra == "shap"
Provides-Extra: torch
Requires-Dist: torch==2.15.0; extra == "torch"
Requires-Dist: cloudpickle>=3.0.0; extra == "torch"
Provides-Extra: gp
Requires-Dist: scikit-learn<1.6.0,>=1.4.0; extra == "gp"
Requires-Dist: cloudpickle>=3.0.0; extra == "gp"
Provides-Extra: lightning
Requires-Dist: torch==2.15.0; extra == "lightning"
Requires-Dist: pytorch-lightning==2.6.6; extra == "lightning"
Requires-Dist: cloudpickle>=3.0.0; extra == "lightning"
Provides-Extra: mapie
Requires-Dist: mapie>=1.2.0; extra == "mapie"
Requires-Dist: cloudpickle>=3.0.0; extra == "mapie"
Provides-Extra: alns
Requires-Dist: alns>=6.0.0; extra == "alns"
Provides-Extra: google-or
Requires-Dist: ortools>=9.9; extra == "google-or"
Provides-Extra: pymc
Requires-Dist: pymc>=6.3.2; extra == "pymc"
Requires-Dist: arviz>=1.1.0; extra == "pymc"
Requires-Dist: cloudpickle>=3.0.0; extra == "pymc"
Provides-Extra: causal
Requires-Dist: dowhy>=0.12; extra == "causal"
Requires-Dist: econml>=0.15.0; extra == "causal"
Requires-Dist: PyALE>=1.2.0; extra == "causal"
Requires-Dist: statsmodels>=0.14.0; extra == "causal"
Requires-Dist: pandas>=2.0.0; extra == "causal"
Requires-Dist: matplotlib>=3.8.0; extra == "causal"
Requires-Dist: scikit-learn<1.6.0,>=1.4.0; extra == "causal"
Requires-Dist: cloudpickle>=3.0.0; extra == "causal"
Provides-Extra: all
Requires-Dist: PyNomadBBO>=4.4.0; extra == "all"
Requires-Dist: optuna>=4.0.0; extra == "all"
Requires-Dist: simanneal>=0.5.0; extra == "all"
Requires-Dist: scikit-learn<1.6.0,>=1.4.0; extra == "all"
Requires-Dist: skl2onnx>=1.17.0; extra == "all"
Requires-Dist: onnxruntime>=1.18.0; extra == "all"
Requires-Dist: scipy>=1.12.0; extra == "all"
Requires-Dist: xgboost>=3.4.0; extra == "all"
Requires-Dist: lightgbm>=4.3.0; extra == "all"
Requires-Dist: ngboost>=0.5.0; extra == "all"
Requires-Dist: shap>=0.45.0; extra == "all"
Requires-Dist: torch==2.15.0; extra == "all"
Requires-Dist: pytorch-lightning==2.6.6; extra == "all"
Requires-Dist: mapie>=1.2.0; extra == "all"
Requires-Dist: alns>=6.0.0; extra == "all"
Requires-Dist: ortools>=9.9; extra == "all"
Requires-Dist: pymc>=6.3.2; extra == "all"
Requires-Dist: arviz>=1.1.0; extra == "all"
Requires-Dist: dowhy>=0.12; extra == "all"
Requires-Dist: econml>=0.15.0; extra == "all"
Requires-Dist: PyALE>=1.2.0; extra == "all"
Requires-Dist: statsmodels>=0.14.0; extra == "all"
Requires-Dist: pandas>=2.0.0; extra == "all"
Requires-Dist: matplotlib>=3.8.0; extra == "all"
Requires-Dist: cloudpickle>=3.0.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Description-Content-Type: text/markdown

# East Data Science

> Data science and ML platform functions for the East language

[![TypeScript: AGPL-3.0](https://img.shields.io/badge/TypeScript-AGPL--3.0-blue.svg)](LICENSE.md)
[![Python: BSL 1.1](https://img.shields.io/badge/Python-BSL%201.1-orange.svg)](LICENSE.md)
[![Node Version](https://img.shields.io/badge/node-%3E%3D22.0.0-brightgreen.svg)](https://nodejs.org)

**East Data Science** provides machine learning and optimization platform functions for the [East language](https://github.com/elaraai/east-workspace/tree/main/libs/east).

## Installation

```bash
npm install @elaraai/east-py-datascience @elaraai/east
```

### Python Optional Dependencies

Each module has its own optional Python dependencies to avoid installing unnecessary packages. Install only the extras you need:

```bash
# Single extra
uv pip install "elaraai-east-py-datascience[scipy]"

# Multiple extras
uv pip install "elaraai-east-py-datascience[scipy,sklearn,xgboost]"

# All extras, under the release's overrides (east-py-overrides.txt, below)
uv pip install --override east-py-overrides.txt "elaraai-east-py-datascience[all]"
```

**`all`, or `causal` with `shap`, takes the release's overrides, and so uv.**
econml, which `causal` installs, asks for a shap before 0.49, and that shap
cannot read the models of the xgboost the extras install (`could not convert
string to float`). The release overrides it (`shap>=0.51.0`). pip takes no
overrides: installed with pip, these extras resolve, and
`Shap.treeExplainerCreate` fails on every XGBoost model. Any other extras
install with pip as with uv.

**Python 3.12 or later.** xgboost 3.4, whose NCCL library is the CUDA 13 one
torch uses, needs it. Give your project's `requires-python` a floor of 3.12
too: uv locks for every Python a project admits, so a project that admits 3.11
is locked to an earlier release of this package, one that took 3.11.

**torch is pinned.** The `torch`, `lightning` and `all` extras pin torch and
pytorch-lightning exactly, at the versions the release was tested with. Ask
for torch through them, and name no torch of your own:

```toml
dependencies = ["elaraai-east-py-datascience[torch,lightning]"]   # not "torch", "pytorch-lightning"
```

Your lock then holds the torch from PyPI that the release's `py-datascience`
image holds, so an e3 task that runs on a rack over that image is not sent
torch and its NVIDIA libraries. A pin with no local label is met by every
local label, so a project that takes torch from a PyTorch index locks that
index's build (`2.15.0+cpu`, `2.15.0+cu130`), which is not the image's, and is
sent it. A project that needs another torch leaves the extras out and lists
torch itself.

**torch and xgboost share one NCCL library.** The extras ask for xgboost 3.4 or
later, whose NCCL library is `nvidia-nccl-cu13`, the one torch pins. An
earlier xgboost asks for `nvidia-nccl-cu12`, which installs the same file, and
with it on top `import torch` fails (`undefined symbol: ncclCommResume`): a
project that names xgboost itself keeps it at 3.4 or later. An environment
that held both, from an earlier xgboost beside this torch, loses the file they
share when uv removes xgboost's: put torch's back once, with `uv sync
--reinstall-package nvidia-nccl-cu13`.

Each release ships the settings its packages were tested with, in
`@elaraai/e3-core` (`tier/`): `east-py-constraints.txt`, every third-party
version of this workspace's lock, each pin with the platforms it is for, and
`east-py-overrides.txt`. A project `npm create @elaraai/e3` scaffolds carries
them already, in a marked block of its root `[tool.uv]` table, which
`npm create @elaraai/e3@<version> -- --update` replaces with that release's.
In any other project, to hold a distribution at the release's version, put
its pins under `[tool.uv] constraint-dependencies` in your workspace root, each
as `name==version ; marker`: the pin and its marker, and none of the line's
trailing `\`, `--hash` lines or `# via` notes. Keep every pin of the name and
its marker, or one platform is held at another's version:

```toml
[tool.uv]
constraint-dependencies = [
  "numpy==2.3.5 ; platform_machine == 'x86_64' and sys_platform == 'darwin'",
  "numpy==2.4.4 ; platform_machine != 'x86_64' or sys_platform != 'darwin'",
]
override-dependencies = ["shap>=0.51.0"]
```

The overrides go under `override-dependencies`, as above. With the `causal`
and `shap` extras together, the override (`shap>=0.51.0`) is what gives you a
shap that reads current xgboost models.

When using a git dependency in `pyproject.toml`:
```toml
"elaraai-east-py-datascience[scipy] @ git+https://github.com/elaraai/east-workspace@main#subdirectory=libs/east-py/packages/east-py-datascience"
```

| Module | Extra | Python Packages |
|--------|-------|-----------------|
| **MADS** | `mads` | PyNomadBBO |
| **Optuna** | `optuna` | optuna |
| **SimAnneal** | `simanneal` | simanneal |
| **Scipy** | `scipy` | scipy, cloudpickle |
| **Optimization** | *(none)* | *(core only — numpy)* |
| **GoogleOr** | `google-or` | ortools |
| **Sklearn** | `sklearn` | scikit-learn, skl2onnx, onnxruntime, cloudpickle |
| **XGBoost** | `xgboost` | xgboost, cloudpickle |
| **LightGBM** | `lightgbm` | lightgbm, cloudpickle |
| **NGBoost** | `ngboost` | ngboost, cloudpickle |
| **Torch** | `torch` | torch, cloudpickle |
| **GP** | `gp` | scikit-learn, cloudpickle |
| **Lightning** | `lightning` | torch, pytorch-lightning, cloudpickle |
| **Shap** | `shap` | shap, cloudpickle |
| **MAPIE** | `mapie` | mapie, cloudpickle |
| **ALNS** | `alns` | alns |
| **PyMC** | `pymc` | pymc, cloudpickle |
| **Simulation** | *(none)* | *(core only — numpy)* |
| **Causal** | `causal` | dowhy, econml, PyALE, pandas, matplotlib, scikit-learn, cloudpickle |

## Quick Start

```typescript
import { East, FloatType, variant } from "@elaraai/east";
import { MADS } from "@elaraai/east-py-datascience";

// Define objective function: minimize sum of squares
const objective = East.function([MADS.Types.VectorType], FloatType, ($, x) => {
    const x0 = $.let(x.get(0n));
    const x1 = $.let(x.get(1n));
    return $.return(x0.multiply(x0).add(x1.multiply(x1)));
});

// Optimize
const optimize = East.function([], MADS.Types.ResultType, $ => {
    const x0 = $.let([0.5, 0.5]);
    const bounds = $.let({
        lower: [-1.0, -1.0],
        upper: [1.0, 1.0],
    });
    const config = $.let({
        max_bb_eval: variant('some', 100n),
        display_degree: variant('some', 0n),
        direction_type: variant('none', null),
        initial_mesh_size: variant('none', null),
        min_mesh_size: variant('none', null),
        seed: variant('some', 42n),
    });

    return $.return(MADS.optimize(objective, x0, bounds, variant('none', null), config));
});
```

## Modules

### Optimization

| Module | Description | Use Cases |
|--------|-------------|-----------|
| **MADS** | Derivative-free blackbox optimization using NOMAD algorithm | Functions without derivatives, expensive evaluations, noisy/discontinuous objectives |
| **Optuna** | Bayesian optimization with TPE sampler | Hyperparameter tuning, mixed-type parameters, efficient search with few evaluations |
| **SimAnneal** | Simulated annealing for discrete optimization | TSP, scheduling, subset selection, knapsack, assignment problems |
| **Scipy** | Scientific optimization and curve fitting | Gradient-based minimization, curve fitting, interpolation, statistics |
| **Optimization** | Iterative coordinate descent optimization | Parameter tuning, sequential optimization across parameter groups |
| **GoogleOr** | Google OR-Tools constraint programming, routing, LP, and graph algorithms | CP-SAT, vehicle routing (TSP/VRP), linear/mixed-integer programming, min-cost flow, max flow, assignment, sparse min-cost assignment |

### Machine Learning

| Module | Description | Use Cases |
|--------|-------------|-----------|
| **Sklearn** | Core ML utilities from scikit-learn | N-way splits, preprocessing (Standard/MinMax/RobustScaler), encoding (Label/Ordinal), metrics, GMM clustering, multi-target regression |
| **XGBoost** | Gradient boosting with XGBoost | Regression, classification, feature importance, fast training |
| **LightGBM** | Fast gradient boosting with leaf-wise growth | Large datasets, high cardinality features, faster than XGBoost on big data |
| **NGBoost** | Natural gradient boosting with uncertainty | Probabilistic predictions, confidence intervals, uncertainty quantification |
| **Torch** | Neural networks with PyTorch | MLP regression/classification, deep learning, custom architectures |
| **Lightning** | PyTorch Lightning neural networks | MLP, autoencoder, conv1d, sequential, transformer architectures |
| **GP** | Gaussian Process regression | Small datasets, uncertainty quantification, Bayesian optimization surrogate |
| **MAPIE** | Conformal prediction intervals | Prediction intervals, prediction sets, uncertainty quantification |

### Bayesian Inference

| Module | Description | Use Cases |
|--------|-------------|-----------|
| **PyMC** | Bayesian inference with PyMC | Bayesian linear regression, hierarchical models, multi-layer joint estimation, posterior analysis |

### Causal Inference

| Module | Description | Use Cases |
|--------|-------------|-----------|
| **Causal** | One declarative causal experiment (`Causal.experiment`) over DoWhy / EconML / PyALE internals, plus `Causal.designValidation` (statsmodels power) | Naive vs adjusted effect, confounder balance, propensity overlap, placebo/E-value robustness, and an honesty verdict (refuses when the data can't support an answer); and the real controlled-trial recipe that would confirm it — sample size, split, match-on categories, and a power curve |

### Simulation

| Module | Description | Use Cases |
|--------|-------------|-----------|
| **Simulation** | Economic ontology simulation via DES | Simulating economic resources, events, and processes; single deterministic runs, Monte Carlo trajectories |

### Explainability

| Module | Description | Use Cases |
|--------|-------------|-----------|
| **Shap** | SHAP values for model interpretation | Feature importance, model explanations, debugging predictions |

## Documentation

See [USAGE.md](./USAGE.md) for detailed API reference with examples.

## Development

```bash
npm run build     # Compile TypeScript
npm run test      # Run test suite
npm run lint      # Check code quality
```

## Claude Code plugin

The East ecosystem also ships a [Claude Code](https://claude.com/claude-code) plugin — East language skills, example search, and preemptive diagnostics for East code — installed separately from the `elaraai` marketplace:

```text
# Inside Claude Code
/plugin marketplace add elaraai/east-workspace
/plugin install east@elaraai
```

```bash
# From a terminal
claude plugin marketplace add elaraai/east-workspace
claude plugin install east@elaraai
```

## License

This package has different licenses for TypeScript and Python code:

**TypeScript (type definitions):** Dual AGPL-3.0 / Commercial
- Open source use: [AGPL-3.0](LICENSE.md)
- Commercial use: Available for proprietary use - contact support@elara.ai

**Python (runtime implementations):** BSL 1.1 (Business Source License)
- Non-production use (evaluation, testing, development) is free
- Production use by or on behalf of for-profit entities requires a commercial license
- Code becomes AGPL-3.0 four years after each release

See [LICENSE.md](LICENSE.md) for full details.

**Commercial licensing:** support@elara.ai

### Ecosystem

- **[East](https://github.com/elaraai/east-workspace/tree/main/libs/east)**: Statically typed, expression-based language with serializable IR. Run portable logic across TypeScript, Python, C, and other runtimes.
  - [@elaraai/east](https://www.npmjs.com/package/@elaraai/east): Core language SDK with type system, expressions, and reference JS compiler

- **[East Node](https://github.com/elaraai/east-workspace/tree/main/libs/east-node)**: Node.js platform functions for I/O, databases, and system operations.
  - [@elaraai/east-node-std](https://www.npmjs.com/package/@elaraai/east-node-std): Console, FileSystem, Fetch, Crypto, Time, Path, Random
  - [@elaraai/east-node-io](https://www.npmjs.com/package/@elaraai/east-node-io): SQLite, PostgreSQL, MySQL, MongoDB, Redis, S3, FTP, SFTP, XLSX, XML, compression
  - [@elaraai/east-node-cli](https://www.npmjs.com/package/@elaraai/east-node-cli): CLI for running East IR programs in Node.js

- **[East C](https://github.com/elaraai/east-workspace/tree/main/libs/east-c)**: C11 native runtime for executing East IR. Distributed via npm (launcher + per-platform optional dependencies) and as tarballs on each GitHub Release.
  - [@elaraai/east-c-cli](https://www.npmjs.com/package/@elaraai/east-c-cli): npm launcher — installs the matching native binary as an optional dependency
  - `east-c`: Core runtime — type system, IR interpreter, builtins, serialization (Beast2, JSON, CSV, East text)
  - `east-c-std`: Console, FileSystem, Fetch, Crypto, Time, Path, Random
  - `east-c-cli`: CLI for running East IR programs natively

- **[East Python](https://github.com/elaraai/east-workspace/tree/main/libs/east-py)**: Python runtime, standard platform, I/O, and data-science platform functions. Published to PyPI.
  - [east-py](https://pypi.org/project/east-py/): Core Python runtime — type system, IR compiler, 212+ builtins, Cython-accelerated hot paths
  - [east-py-std](https://pypi.org/project/east-py-std/): Console, FileSystem, Fetch, Crypto, Time, Path, Random
  - [east-py-io](https://pypi.org/project/east-py-io/): SQLite, PostgreSQL, MySQL, MongoDB, Redis, S3, FTP, SFTP, XLSX, XML, compression
  - [east-py-cli](https://pypi.org/project/east-py-cli/): CLI for running East IR programs in Python
  - [east-py-datascience](https://pypi.org/project/east-py-datascience/) (PyPI) + [@elaraai/east-py-datascience](https://www.npmjs.com/package/@elaraai/east-py-datascience) (npm): Optimization (MADS, Optuna, ALNS, GoogleOR), ML (XGBoost, LightGBM, NGBoost, PyTorch, Lightning, GP), Bayesian inference (PyMC), explainability (SHAP), conformal prediction (MAPIE)

- **[East UI](https://github.com/elaraai/east-workspace/tree/main/libs/east-ui)**: Typed UI component definitions and React renderer, plus VS Code preview.
  - [@elaraai/east-ui](https://www.npmjs.com/package/@elaraai/east-ui): 50+ typed UI components for layouts, forms, charts, tables, dialogs
  - [@elaraai/east-ui-components](https://www.npmjs.com/package/@elaraai/east-ui-components): React renderer with Chakra UI v3 styling
  - [@elaraai/e3-ui](https://www.npmjs.com/package/@elaraai/e3-ui): e3 + UI bridge — Data bindings, `e3.ui()` task, manifest
  - [@elaraai/e3-ui-components](https://www.npmjs.com/package/@elaraai/e3-ui-components): React Query hooks and preview components for the e3 API

- **[e3 — East Execution Engine](https://github.com/elaraai/east-workspace/tree/main/libs/e3)**: Durable execution engine for running East pipelines at scale. Git-like content-addressable storage, automatic memoization, reactive dataflow, real-time monitoring.
  - [@elaraai/e3](https://www.npmjs.com/package/@elaraai/e3): SDK for authoring e3 packages with typed tasks and pipelines
  - [@elaraai/e3-core](https://www.npmjs.com/package/@elaraai/e3-core): Object store, dataflow orchestrator, execution state
  - [@elaraai/e3-types](https://www.npmjs.com/package/@elaraai/e3-types): Shared type definitions for e3 packages
  - [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3 repo`, `e3 package`, `e3 workspace`, `e3 dataflow run`, `e3 watch`, `e3 task logs` commands
  - [@elaraai/e3-api-client](https://www.npmjs.com/package/@elaraai/e3-api-client): HTTP client for remote e3 repositories
  - [@elaraai/e3-api-server](https://www.npmjs.com/package/@elaraai/e3-api-server): REST API server for e3 repositories
  - [@elaraai/e3-api-tests](https://www.npmjs.com/package/@elaraai/e3-api-tests): Shared API compliance test suites

## Links

- **Website**: [https://elaraai.com/](https://elaraai.com/)
- **East Repository**: [https://github.com/elaraai/east-workspace/tree/main/libs/east](https://github.com/elaraai/east-workspace/tree/main/libs/east)
- **Issues**: [https://github.com/elaraai/east-workspace/issues](https://github.com/elaraai/east-workspace/issues)
- **Email**: support@elara.ai

## About Elara

East is developed by [Elara AI Pty Ltd](https://elaraai.com/), an AI-powered platform that creates economic digital twins of businesses that optimize performance. Elara combines business objectives, decisions and data to help organizations make data-driven decisions across operations, purchasing, sales and customer engagement, and project and investment planning. East powers the computational layer of Elara solutions, enabling the expression of complex business logic and data in a simple, type-safe and portable language.

---

*Developed by [Elara AI Pty Ltd](https://elaraai.com/).*

---

*Developed by [Elara AI Pty Ltd](https://elaraai.com/)*
