More sustainable generation and use of electricity are being achieved through a growing contribution from solar and wind power. These are intermittent sources with output evolving according to broad seasonal and diurnal patterns on which superimpose rather unpredictable changes due to weather, such as an appearance of cloud layers attenuating the amount of irradiance received by the surface. The integration of the solar production and the parameters that influence it creates a complex system where on continuous basis decisions need to be made on whether to store or forfeit excess solar electricity or whether to call on hydrocarbon-powered stations. All of this is to satisfy demand which is itself constantly changing with broad seasonal and diurnal trends. Thus, optimal decisions depend on a multitude of variables, from technical parameters of the devices to weather-related variables to predict demand on a timescale sufficient to adjust supply and decide on the best mix of technologies. Machine learning techniques are promising for the integration of renewable energies into the grid. Thus, this chapter proposes an efficient solution for grid management and control of the distribution of electrical energy while encouraging the integration of renewable energy. In particular, the proposed solution aims to be able to predict the production of intermittent sources such as the sun in our case so that its integration is more efficient. So, it will ensure that renewable and non-renewable sources are complementary at all times, offering then the best possible storage and production tools. All this is to ensure instantaneous energy balance.