The exponential growth in energy demand is leading to massive energy consumption from fossil resources causing a negative effects for the environment. It is essential to promote sustainable solutions based on renewable energies infrastructures such as microgrids integrated to the existing network or as stand alone solution. Moreover, the major focus of today is being able to integrate a higher percentages of renewable electricity into the energy mix. The variability of wind and solar energy requires knowing the relevant long-term patterns for developing better procedures and capabilities to facilitate integration to the network. Precise prediction is essential for an adequate use of these renewable sources. This article proposes machine learning approaches compared to an hybrid method, based on the combination of machine learning with optimisation approaches. The results show the improvement in the accuracy of the machine learning models results once the optimisation approach is used.