Contextual Learning for Stochastic Optimization