bartz.PredictKind¶
- class bartz.PredictKind(*values)[source]¶
Kind of output of
Bart.predict.The shapes are for multivariate outcomes with
kcomponents, atmtest points, withndpost = num_chains * n_saveposterior samples. For univariate outcomes, drop thekaxes. The kinds ending in_sampleshave a value for each posterior sample, the others summarize the posterior. The covariances are across the outcome components, at each test point. The intervals have the lower and upper bounds along the first axis.In the formulas, \(s = 1, \ldots, S\) indexes the posterior samples, \(f_s\) is the latent sum of trees at a test point, \(\mu_s\) and \(\Sigma_s\) are the mean and covariance of the outcome given the parameters in sample \(s\), and a bar denotes the average over the samples, e.g., \(\bar f = \frac1S \sum_{s=1}^S f_s\).
- latent_samples = 'latent_samples'[source]¶
Shape
(ndpost, k, m).The latent sum of trees \(f_s\). On continuous components, it’s the conditional mean of the outcome; on binary components, it’s the probit of the probability of 1, times the error scale.
- latent_mean = 'latent_mean'[source]¶
Shape
(k, m).Posterior mean of
PredictKind.latent_samples.\[\bar f\]
- latent_cov = 'latent_cov'[source]¶
Shape
(k, k, m).Posterior covariance of
PredictKind.latent_samples, i.e., the covariance of their empirical distribution.\[\frac1S \sum_{s=1}^S (f_s - \bar f) (f_s - \bar f)^T\]
- latent_var = 'latent_var'[source]¶
Shape
(k, m).The diagonal of
PredictKind.latent_cov.
- latent_sdev = 'latent_sdev'[source]¶
Shape
(k, m).The square root of
PredictKind.latent_var.
- latent_interval = 'latent_interval'[source]¶
Shape
(2, k, m).Equal-tailed interval with probability
levelofPredictKind.latent_samples, i.e., their quantiles at(1 - level) / 2and(1 + level) / 2as computed bynumpy.quantile(..., method='hazen').Bart.score(..., kind='coverage', target='latent')is the fraction of truths inside the interval.
- mean_samples = 'mean_samples'[source]¶
Shape
(ndpost, k, m).The conditional mean of the outcome \(\mu_s\). On continuous components, it’s
PredictKind.latent_samples; on binary components, it’s the probability of 1, \(\Phi(f_s / w)\) with \(w\) the error scale.
- mean = 'mean'[source]¶
Shape
(k, m).Posterior mean of
PredictKind.mean_samples, which is also the mean of the posterior predictive distribution of the outcome.\[\bar \mu\]
- mean_cov = 'mean_cov'[source]¶
Shape
(k, k, m).Posterior covariance of
PredictKind.mean_samples, seePredictKind.latent_cov.\[\frac1S \sum_{s=1}^S (\mu_s - \bar \mu) (\mu_s - \bar \mu)^T\]
- mean_var = 'mean_var'[source]¶
Shape
(k, m).The diagonal of
PredictKind.mean_cov.
- mean_sdev = 'mean_sdev'[source]¶
Shape
(k, m).The square root of
PredictKind.mean_var.
- mean_interval = 'mean_interval'[source]¶
Shape
(2, k, m).PredictKind.latent_intervalofPredictKind.mean_samples.Bart.score(..., kind='coverage', target='mean')is the fraction of truths inside the interval.
- cond_cov_samples = 'cond_cov_samples'[source]¶
Shape
(ndpost, k, k, m).The conditional covariance of the outcome \(\Sigma_s\). On continuous components, it’s the covariance of the error, scaled by the error scales; binary components are independent of the others, with variance \(\mu_s (1 - \mu_s)\).
- cond_var_samples = 'cond_var_samples'[source]¶
Shape
(ndpost, k, m).The diagonal of
PredictKind.cond_cov_samples.
- cond_sdev_samples = 'cond_sdev_samples'[source]¶
Shape
(ndpost, k, m).The square root of
PredictKind.cond_var_samples.
- cond_cov = 'cond_cov'[source]¶
Shape
(k, k, m).Posterior mean of
PredictKind.cond_cov_samples.\[\bar \Sigma\]
- cond_var = 'cond_var'[source]¶
Shape
(k, m).The diagonal of
PredictKind.cond_cov.
- cond_sdev = 'cond_sdev'[source]¶
Shape
(k, m).The square root of
PredictKind.cond_var, which differs from the posterior mean ofPredictKind.cond_sdev_samples.
- outcome_samples = 'outcome_samples'[source]¶
Shape
(ndpost, k, m).Draws of the outcome from its conditional distribution in each posterior sample, i.e., a sample of the posterior predictive distribution. Requires
key.
- outcome_cov = 'outcome_cov'[source]¶
Shape
(k, k, m).Covariance of the posterior predictive distribution of the outcome, the sum of
PredictKind.cond_covandPredictKind.mean_covby the law of total covariance.\[\bar \Sigma + \frac1S \sum_{s=1}^S (\mu_s - \bar \mu) (\mu_s - \bar \mu)^T\]
- outcome_var = 'outcome_var'[source]¶
Shape
(k, m).The diagonal of
PredictKind.outcome_cov. On binary components, it’s \(\bar \mu (1 - \bar \mu)\).
- outcome_sdev = 'outcome_sdev'[source]¶
Shape
(k, m).The square root of
PredictKind.outcome_var.
- outcome_interval = 'outcome_interval'[source]¶
Shape
(2, k, m), NaN on binary components.Equal-tailed interval with probability
levelof the posterior predictive distribution of the outcome, i.e., of the mixture of the conditional distributions in the posterior samples. The bounds are its exact quantiles, computed by root finding rather than fromPredictKind.outcome_samples.Bart.score(..., kind='coverage')is the fraction of truths inside the interval.\[\left[F^{-1}\left(\frac{1 - \mathtt{level}}2\right), F^{-1}\left(\frac{1 + \mathtt{level}}2\right)\right], \qquad F(t) = \frac1S \sum_{s=1}^S \Phi\left(\frac{t - f_s}{\sigma_s}\right)\]where \(\sigma_s^2\) is the diagonal entry of \(\Sigma_s\).