Metadata-Version: 2.4
Name: rbartpackages
Version: 0.1.0
Summary: Python wrappers of R BART packages via rpy2
Author: Giacomo Petrillo
Author-email: Giacomo Petrillo <info@giacomopetrillo.com>
License-Expression: MIT
License-File: LICENSE
Requires-Dist: rpy2>=3.6.0
Requires-Dist: numpy>=2.2.6
Requires-Dist: jaxtyping>=0.3.2
Requires-Dist: jax>=0.6.1 ; extra == 'jax'
Requires-Dist: pandas>=2.2.3 ; extra == 'pandas'
Requires-Dist: polars>=1.30.0 ; extra == 'polars'
Requires-Dist: pandas>=2.2.3 ; extra == 'polars'
Requires-Python: >=3.10
Project-URL: Homepage, https://github.com/bartz-org/rbartpackages
Project-URL: Documentation, https://bartz-org.github.io/rbartpackages/docs-dev
Project-URL: Issues, https://github.com/bartz-org/rbartpackages/issues
Provides-Extra: jax
Provides-Extra: pandas
Provides-Extra: polars
Description-Content-Type: text/markdown

# rbartpackages

Python wrappers of R BART (Bayesian Additive Regression Trees) packages, built on [rpy2](https://rpy2.github.io).

`rbartpackages` lets you call several R BART implementations from Python with a uniform, lightly-typed interface: arguments are converted to R, the fitted R object's components become Python attributes, and the original R documentation is attached to each wrapper class. It currently wraps:

- [`BART`](https://cran.r-project.org/package=BART)
- [`BART3`](https://github.com/rsparapa/bnptools) (the development superset of `BART`)
- [`bartMachine`](https://cran.r-project.org/package=bartMachine)
- [`dbarts`](https://cran.r-project.org/package=dbarts)

## Installation

```sh
pip install rbartpackages
```

You also need R with the package(s) you want to use installed (`BART`, `dbarts`, `bartMachine` from CRAN; `BART3` from `rsparapa/bnptools` on GitHub). `bartMachine` additionally requires Java. Optional extras `pandas`, `polars`, and `jax` enable passing those array/frame types directly. See the documentation for details.

## Usage

```python
import numpy as np
from rbartpackages import BART3

x_train = np.random.randn(100, 5)
y_train = x_train[:, 0] + 0.1 * np.random.randn(100)

bart = BART3.gbart(x_train=x_train, y_train=y_train, ndpost=200)
y_pred = bart.predict(x_train)  # shape (ndpost, n)
```

R argument names with dots are passed with underscores (`x.train` → `x_train`).

## Links

- [Documentation](https://bartz-org.github.io/rbartpackages/docs-dev)
- [Repository](https://github.com/bartz-org/rbartpackages)
- [List of BART packages](https://bartz-org.github.io/bartz/docs-dev/pkglist.html) (maintained in the bartz docs)

These wrappers originated in the [bartz](https://github.com/bartz-org/bartz) project, where they are used to validate against reference R implementations.
