Learning and Forecasting Opinion Dynamics in Social Networks