# Train ARF and estimate leaf parameters
arf <- adversarial_rf(iris)
psi <- forde(arf, iris)
# What is the expected value of Sepal.Length?
expct(psi, query = "Sepal.Length")
# What if we condition on Species = "setosa"?
evi <- data.frame(Species = "setosa")
expct(psi, query = "Sepal.Length", evidence = evi)
# Compute expectations for all features other than Species
expct(psi, evidence = evi)
# Condition on Species = "setosa" and Petal.Width > 0.3
evi <- data.frame(Species = "setosa",
Petal.Width = ">0.3")
expct(psi, evidence = evi)
# Condition on first two rows with some missing values
evi <- iris[1:2,]
evi[1, 1] <- NA_real_
evi[1, 5] <- NA_character_
evi[2, 2] <- NA_real_
x_synth <- expct(psi, evidence = evi)
if (FALSE) {
# Parallelization with doParallel
doParallel::registerDoParallel(cores = 4)
# ... or with doFuture
doFuture::registerDoFuture()
future::plan("multisession", workers = 4)
}
Run the code above in your browser using DataLab