Learning from Data to Optimize Control in Precision Farming