A constrained Bayesian approach to out-of-distribution prediction