Skip to main content

rbartpackages

Python wrappers of R BART (Bayesian Additive Regression Trees) packages.

rbartpackages lets you use a few R BART implementations (including the 3 most popular ones) from Python with a natural Python experience. The Python wrappers closely follow the R packages they wrap, so they should be obvious to use coming from R if one wants to switch to Python.

The packages included are:

The wrappers are incomplete and only wrap the main functions and objects of the packages. The most complete wrapper is dbarts. If you need more functionality wrapped, feel free to open an issue on github. Alternatively, this library provides simplified tools and utilities to let the user wrap arbitrary R classes and functions, see the guide and the reference.

Installation

pip install rbartpackages

You also need R with the latest version of the package(s) you want to use installed (BART, dbarts, bartMachine from CRAN; BART3 from rsparapa/bnptools and missBART from yongchengoh/missBART on GitHub). bartMachine additionally requires Java. If you install polars[pyarrow], dataframes are returned as polars dataframes instead of pandas dataframes. For convenience, you can install both with pip install 'rbartpackages[polars]'. If you install jax (separately or with pip install 'rbartpackages[jax]'), jax arrays are accepted as input in place of numpy arrays, but output arrays remain numpy.

Usage

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).

Metadata

Release files for rbartpackages 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rbartpackages 0.3.0
File Size Uploaded
rbartpackages-0.3.0.tar.gz 49.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rbartpackages 0.3.0
File Interpreter ABI Platform
rbartpackages-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 116.8 kB

Release files / rbartpackages-0.3.0.tar.gz

Download URL rbartpackages-0.3.0.tar.gz
Size 49.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a951415d2f1aea666cabdee818aa2ec8fc3141fdb5e7ee5c2e15cc6777e2722a
BLAKE2b-256 checksum
How to use checksums
448bd68510c1685671f76de5b8429709e50d89db4bd88ebf281e2abe0a256122
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / rbartpackages-0.3.0-py3-none-any.whl

Download URL rbartpackages-0.3.0-py3-none-any.whl
Size 67.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a452fd37baa55fd7b0434bcb4198801d317c6c11eeb08f808fa8130fe9b68548
BLAKE2b-256 checksum
How to use checksums
1c89a74631bb1c1b919811e9de42d5ae37b5fab36fd01ea73519b19d4a31f9ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page