This study focuses on the optimization of photovoltaic (PV) prediction using machine learning (ML) models by analyzing the impact of environmental variables in Marrakech. The research compares two types of meteorological data from satellites and ground stations to assess their respective contributions to forecast accuracy.The results show that global solar irradiance (G), air temperature (Ta) and wind speed (Wv) are the most influential parameters on energy production, whatever the data source. However, forecasts based on ground-measured data showed slightly higher accuracy, with an R²=0.98 for measured data versus 0.86 for stalietes data, underlining the importance of localized measurements.Of the scenarios tested, Scenario 1 (all inputs) achieved the highest accuracy, with an R² of 0.98 and an RMSE of 91.39. Scenarios 2 (without Wv) and 4(without DNI) also delivered acceptable levels of accuracy, albeit slightly lower than Scenario 1. These results highlight the importance of integrating localized weather data to improve the accuracy of PV power generation forecasts.