A Framework for Modeling and Optimization of Data-Driven Energy Systems Using Machine Learning