  Cosmological analyses can be accelerated by approximating slow calculations
using a training set, which is either precomputed or generated dynamically.
However, this approach is only safe if the approximations are well understood
and controlled. This paper surveys issues associated with the use of
machine-learning based emulation strategies for accelerating cosmological
parameter estimation. We describe a learn-as-you-go algorithm that is
implemented in the Cosmo++ code and (1) trains the emulator while
simultaneously estimating posterior probabilities; (2) identifies unreliable
estimates, computing the exact numerical likelihoods if necessary; and (3)
progressively learns and updates the error model as the calculation progresses.
We explicitly describe and model the emulation error and show how this can be
propagated into the posterior probabilities. We apply these techniques to the
Planck likelihood and the calculation of $\Lambda$CDM posterior probabilities.
The computation is significantly accelerated without a pre-defined training set
and uncertainties in the posterior probabilities are subdominant to statistical
fluctuations. We have obtained a speedup factor of $6.5$ for
Metropolis-Hastings and $3.5$ for nested sampling. Finally, we discuss the
general requirements for a credible error model and show how to update them
on-the-fly.
