The real-time prediction of energy production is essential for effective energy management and planning. Forecasts are essential in various areas, including the efficient utilization of energy resources, the provision of energy flexibility services, decision-making amidst uncertainty, the balancing of supply and demand, and the optimization of online energy systems. This study examines the use of tree-based ensemble learning models for renewable energy production prediction, focusing on environmental factors such as temperature, pressure, and humidity. The study’s primary contribution lies in demonstrating the effectiveness of the bagged trees model in reducing overfitting and achieving higher accuracy compared to other models, while maintaining computational efficiency. The results indicate that less sophisticated models are inadequate for accurately representing complex datasets. The results evaluate the effectiveness of machine learning methods in delivering valuable insights for energy sectors managing environmental conditions and predicting renewable energy sources