lik {arf}R Documentation

Likelihood Estimation

Description

Compute the density of input data.

Usage

lik(arf, params, x, oob = FALSE, log = TRUE, batch = NULL, parallel = TRUE)

Arguments

arf

Pre-trained adversarial_rf. Alternatively, any object of class ranger.

params

Parameters learned via forde.

x

Input data. Densities will be computed for each sample.

oob

Only use out-of-bag leaves for likelihood estimation? If TRUE, x must be the same dataset used to train arf.

log

Return likelihoods on log scale? Recommended to prevent underflow.

batch

Batch size. The default is to compute densities for all of x in one round, which is always the fastest option if memory allows. However, with large samples or many trees, it can be more memory efficient to split the data into batches. This has no impact on results.

parallel

Compute in parallel? Must register backend beforehand, e.g. via doParallel.

Details

This function computes the density of input data according to a FORDE model using a pre-trained ARF. Each sample's likelihood is a weighted average of its likelihood in all leaves whose split criteria it satisfies. Intra-leaf densities are fully factorized, since ARFs satisfy the local independence criterion by construction. See Watson et al. (2022).

Value

A vector of likelihoods, optionally on the log scale.

References

Watson, D., Blesch, K., Kapar, J., & Wright, M. (2022). Adversarial random forests for density estimation and generative modeling. arXiv preprint, 2205.09435.

See Also

adversarial_rf, forge

Examples

# Estimate average log-likelihood
arf <- adversarial_rf(iris)
psi <- forde(arf, iris)
ll <- lik(arf, psi, iris, log = TRUE)
mean(ll)



[Package arf version 0.1.3 Index]