Skip to contents

Compute the expectation of some query variable(s), optionally conditioned on some event(s).

Usage

expct(params, query = NULL, evidence = NULL)

Arguments

params

Circuit parameters learned via forde.

query

Optional character vector of variable names. Estimates will be computed for each. If NULL, all variables other than those in evidence will be estimated.

evidence

Optional set of conditioning events. This can take one of three forms: (1) a partial sample, i.e. a single row of data with some but not all columns; (2) a data frame of conditioning events, which allows for inequalities; or (3) a posterior distribution over leaves. See Details.

Value

A one row data frame with values for all query variables.

Details

This function computes expected values for any subset of features, optionally conditioned on some event(s).

References

Watson, D., Blesch, K., Kapar, J., & Wright, M. (2023). Adversarial random forests for density estimation and generative modeling. In Proceedings of the 26th International Conference on Artificial Intelligence and Statistics, pp. 5357-5375.

See also

Examples

# Train ARF and corresponding circuit
arf <- adversarial_rf(iris)
#> Iteration: 0, Accuracy: 82.43%
#> Iteration: 1, Accuracy: 38.38%
psi <- forde(arf, iris)

# What is the expected value Sepal.Length?
expct(psi, query = "Sepal.Length")
#>   Sepal.Length
#> 1          5.8

# What if we condition on Species = "setosa"?
evi <- data.frame(Species = "setosa")
expct(psi, query = "Sepal.Length", evidence = evi)
#>   Sepal.Length
#> 1            5

# Compute expectations for all features other than Species
expct(psi, evidence = evi)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 1            5         3.4          1.5         0.3