Welcome to arfpy’s documentation!
This is a python implementation of adversarial random forests (ARFs) for density estimation and generative modelling. Adversarial random forests (ARFs) recursively partition data into fully factorized leaves, where features are jointly independent. The procedure is iterative, with alternating rounds of generation and discrimination. Data become increasingly realistic at each round, until original and synthetic samples can no longer be reliably distinguished. This is useful for several unsupervised learning tasks, such as density estimation and data synthesis. Methods for both are implemented in this package. ARFs naturally handle unstructured data with mixed continuous and categorical covariates. They inherit many of the benefits of RFs, including speed, flexibility, and solid performance with default parameters.
Installation
The arfpy
package is available on PyPI.
$ pip install arfpy
The development version of this package is available on GitHub. To install the development version, run:
$ git clone https://github.com/bips-hb/arfpy
$ python setup.py install
Usage
Using Fisher’s iris dataset, we train an ARF, estimate distribution parameters and generate new data:
from sklearn.datasets import load_iris
from arfpy import arf
import pandas as pd
# Load data
iris = load_iris()
df = pd.DataFrame(iris['data'], columns=iris['feature_names'])
# Train the ARF
my_arf = arf.arf(x = df)
# Get density estimates
my_arf.forde()
# Generate data
my_arf.forge(n = 10)
Examples
Generative modeling with twomoons data:
Generative modeling with digit zero data:
Generative modeling and density estimation with multivariate normal data:
Other distributions
An R implementation of ARF is available on CRAN.
Funding
This work was supported by the German Research Foundation (DFG), Emmy Noether Grant 437611051.
References
Watson, D. S., Blesch, K., Kapar, J. & Wright, M. N. (2023). Adversarial random forests for density estimation and generative modeling. In Proceedings of the 26th International Conference on Artificial Intelligence and Statistics, PMLR 206:5357-5375. Link here.