Solar energy is a very efficient alternative for generating clean electric energy. However, pollution on the surface of solar panels reduces solar radiation, increases surface transmittance, and raises the surface temperature. All these factors cause photovoltaic (PV) panels to be less efficient. To address this problem, a stacking ensemble classifier-based machine learning model is proposed. In this study, different sources of pollution on each solar panel are used, and their power generation is recorded. The proposed model includes gradient boost, extra tree, and random forest classifiers, with the extra tree classifier serving as a meta-learner. The model takes into account various weather features during the training process, including irradiance and temperature, aiming to increase its accuracy and robustness in identifying pollution sources on the PV panel. Moreover, the proposed model is evaluated using various methods in order to examine performance metrics such as accuracy, F1 score, and precision. Results show that the model can achieve an accuracy score of 97.37%. The model’s performance is also compared to state-of-the-art machine learning models, demonstrating its superiority in accurately classifying pollution sources on PV panels. By utilizing different sources of pollution and weather features during training, the model can accurately classify different pollution sources, resulting in increased power generation efficiency and the longevity of PV panels. The main results of this study can be used to manage and maintain PV panels since the model can identify PV modules that need to be cleaned to keep producing the most power. Furthermore, the efficiency, reliability, and sustainability of PV panels can be further enhanced by the proposed model.