Supervised machine learning will be central in the analysis of upcoming large-scale sky surveys. However, selection bias for astronomical objects yields labelled training data that is not representative for the unlabelled target data distribution. This affects the predictive performance with unreliable target predictions. We propose a novel, statistically principled and theoretically justified method to improve learning under such covariate shift conditions, based on propensity score stratification, a well-established methodology in causal inference. We fit learners on subgroups ("strata") constructed by partitioning the data conditional on the estimated propensity scores, leading to balanced covariates and much-improved target prediction. We demonstrate that our general-purpose method has promising applications in observational cosmology, by improving upon existing conditional density estimation of galaxy redshift from Sloan Data Sky Survey (SDSS) data, as well as improving classification of Supernovae (SNe) type Ia, obtaining the best reported AUC (0.958) on the updated “Supernovae photometric classification challenge”.