Multi-Armed Bandits with Covariates: Theory and Applications