bartz.mcmcloop

Functions that implement the full BART posterior MCMC loop.

Running the MCMC

run_mcmc(key, state, n_save, *[, n_burn, ...])

Run the MCMC for the BART posterior.

RunMCMCResult(final_state, burnin_trace, ...)

Return value of run_mcmc.

BurninTrace(has_chains, mesh, ...)

MCMC trace with only diagnostic values.

MainTrace(has_chains, mesh, grow_prop_count, ...)

MCMC trace with trees and diagnostic values.

MainTraceWithTrainPred(has_chains, mesh, ...)

Main trace that also stores the latent predictions at the training points.

VarprobInState()

Marks a constant MainTrace.varprob, not saved in the trace.

Evaluating the trace

evaluate_trace(X, trace, *[, ...])

Compute predictions for all iterations of the BART MCMC.

compute_varcount(p, trace)

Count how many times each predictor is used in each MCMC state.

EvaluableTrace(*args, **kwargs)

Structural type of the traces accepted by evaluate_trace.

Progress callbacks

Create the progress callbacks with PrintCallback.from_state and TqdmCallback.from_state.

Callback()

Base class for run_mcmc callbacks.

CallbackTuple(callbacks)

Callback that runs a sequence of callbacks in order.

CheckNumTreesCallback()

Warn if the number of trees is slow on the platform the MCMC runs on.

CheckPlatformCallback(platform)

Check the given platform matches the actual platform at runtime.

PrintCallback(dot_every, report_every, ...)

Progress-printing callback for run_mcmc, create it with from_state.

TqdmCallback(bar_id, update_every, ...)

tqdm progress-bar callback for run_mcmc, create it with from_state.

StatsAccumulator(sums, count)

Running average of the forest diagnostics shown during the MCMC.

StatsReport(move_acc, mean_leaves, ...)

Forest diagnostics produced by StatsAccumulator.report for one report.