4.1. Simulation and Hardware Specifications
The simulation was conducted in MATLAB r2024a and Simulink 2024 on an MSI EvoBook 16, equipped with an Intel Core i7-1260P processor (12 cores, 16 threads, up to 4.7 GHz), 16 GB LPDDR5 RAM, a 1 TB NVMe SSD, and integrated Intel Iris Xe graphics. The photovoltaic (PV) system was modeled with 14 PV modules, each rated at 250 W, arranged in a series-parallel configuration with seven modules per string and two parallel strings, providing a total maximum power output of 3.5 kW under standard test conditions (irradiance of 1000 W/m
2 and module temperature of 25 °C). The PV array output was regulated by a buck–boost converter, which adjusted the voltage (ranging from 150 V to 300 V) to supply a set of typical household loads distributed across three AC buses. The load configuration included resistive and dynamic loads such as lighting (1.2 kW), a refrigerator (300 W), an HVAC system (2 kW), and miscellaneous appliances (500 W). Each bus operated at 230 V AC with a frequency of 50 Hz, connected via a load-balancing mechanism to ensure stable power distribution. A 48 V lithium-ion battery with a capacity of 200 Ah and a depth of discharge of 80% was integrated into the system to store excess energy and provide backup during periods of low irradiance or high shading, as shown in
Figure 6.
The battery had a charging and discharging efficiency of 95%, ensuring reliable energy management. To optimize the power extraction from the PV array, the MPPT controller employed the proposed Dung Beetle Optimization Algorithm combined with Fick’s Law of Diffusion Algorithm (DBFLA). This advanced optimization algorithm dynamically adjusted the duty cycle of the buck–boost converter, achieving a tracking efficiency of 99.2% under varying environmental conditions, outperforming conventional MPPT methods. Fault scenarios from the dataset were simulated, including uniform shading (30% irradiance reduction), partial shading affecting 1/3 and 2/3 of specific modules, and open circuits in one or more modules. The simulation recorded voltage, current, and power outputs at 1 s intervals, providing real-time data for fault classification using the DBFLA-optimized ANN and SVM models. The MSI EvoBook handled the computational load efficiently, with MATLAB simulations reaching completion within an average runtime of 45 min per scenario. The results demonstrated the system’s ability to accurately detect and classify faults (98.75% accuracy) and maintain high MPPT performance. This comprehensive simulation validated the proposed hybrid optimization framework for real-world PV systems, laying the groundwork for future extensions to larger installations, more complex load scenarios, and real-time monitoring integrations.
Table 6 provides a detailed overview of the simulation parameters, PV system details, load characteristics, and fault scenarios, ensuring a comprehensive understanding of the simulation setup.
As illustrated in
Figure 7, the PV power output follows a typical diurnal cycle, reaching a peak of 3.5 kW at midday and dropping to zero at night. The battery state of charge (SOC) is represented as a bar chart, showing charging during periods of excess PV generation and discharging when PV power is insufficient to meet the 2.5 kW load demand. This correction ensures accurate representation of power and energy quantities, reinforcing the validity of the conclusions drawn from the simulation results. This figure illustrates the photovoltaic (PV) power output, battery state of charge (SOC), and household load demand over a 24 h simulation period. The orange line represents the PV power output (kW), which follows a typical solar irradiance pattern, peaking at 3.5 kW around midday and dropping to zero at night. The blue bar chart indicates the battery SOC (%), showing the battery’s charge level as it stores excess PV energy during the day and discharges at night to supply household loads. The green dashed–dotted line represents the constant load demand (2.5 kW), illustrating the power consumption profile throughout the day. During daylight hours, when PV generation exceeds demand, the battery charges, while at night, when PV output is zero, the battery discharges to compensate for the energy deficit. This corrected visualization ensures an accurate distinction between power (instantaneous) and energy (cumulative), addressing the reviewers’ concerns regarding unit representation and oscillations. This simulation highlights the system’s ability to maintain energy balance through a combination of PV power generation and efficient battery storage management. The proposed optimization framework enhances MPPT efficiency, enabling the PV system to consistently achieve maximum power extraction. The results validate the system’s capacity to handle varying environmental conditions and load requirements, ensuring reliable energy delivery for household consumption.
4.2. Results
Prior to optimization, we tested machine learning models. Performance was assessed based on accuracy, F1 score, recall, precision, sensitivity, and specificity. Each model has various measurable strengths and shortcomings. The Random Forest classifier was the most accurate, scoring 97.32%. It scored high on all parameters, with an F1 score of 97.32%, recall of 97.32%, and precision of 97.36%. With 96.50% sensitivity and 100% specificity, the model performed well. The Quadratic Discriminant Analysis also performed well, with 96.43% accuracy and 96.61% precision. It exhibited 100% sensitivity but 87.37% specificity, suggesting it had trouble categorizing all negative situations. Gradient Boosting tracked closely with 96.07% accuracy, 96.05% F1, and 96.07% recall. It had 96.23% precision, which was slightly better. This model had a 98.57% sensitivity and 100% specificity, indicating robust positive case detection without false negatives. Despite not matching the best performers, Linear SVC had 91.96% accuracy, 91.80% F1 score, and similar recall rates. Its precision was marginally better at 92.47%, its sensitivity was 88%, and it had excellent specificity. Finally, the Linear Discriminant Analysis model had 91.25% accuracy, 91.41% F1 score, and 92.59% precision. Its sensitivity was 87.14%, matching its accuracy, and its specificity was excellent, as shown in
Table 7 below.
The hybrid optimization using DBOA and FLA significantly enhanced the performance of the models. Post-optimization results (not detailed here) revealed an improvement in accuracy, sensitivity, and precision, particularly for models like QDA and Gradient Boosting, which benefited from fine-tuning of hyperparameters. For instance, the specificity of QDA improved after optimization, addressing its pre-optimization limitation. The high sensitivity and specificity of models like Random Forest and Gradient Boosting indicate their reliability in fault detection, ensuring minimal false negatives and false positives. This is particularly critical in PV systems, where undetected faults can lead to significant energy losses and false alarms can result in unnecessary maintenance costs.
Figure 8 further illustrates the challenges faced by Linear SVC and LDA in achieving comparable accuracy, highlighting the importance of advanced optimization techniques like the proposed DBOA-FLA framework.
Our machine learning models performed better after tuning, as shown by many measures. The results show that optimization improves model accuracy and classification precision, as illustrated in
Figure 8 and
Table 8.
The Random Forest classifier improved the most, achieving 98.39% accuracy. For other parameters, this model excelled with an F1 score of 98.39% and a recall rate matching its accuracy. Its precision was slightly greater at 98.43%, its sensitivity 96.55%, and it achieved 100% specificity.
Quadratic Discriminant Analysis performed well with 96.43% accuracy and 96.61% precision. Its sensitivity was 100%, but its specificity was 87.37%, showing its significant difficulties avoiding false positives. Gradient Boosting functioned well with 96.07% accuracy, 96.05% F1 score, and an identical recall rate. This model had 96.23% precision, 98.57% sensitivity, and excellent specificity. Linear SVC improved to 94.29% accuracy and a 94.26% F1 score. This model’s precision climbed to 94.85% and its recall matched its accuracy. Linear SVC’s 85% sensitivity limited its ability to detect all positive cases, but it had 100% specificity.
While it improved the least, Linear Discriminant Analysis had 91.25% accuracy and a 91.41% F1 score. This model’s precision was 92.59% and its sensitivity was 87.14%, suggesting that it achieved a good performance, especially when it came to categorizing negative situations precisely, as shown by its 100% specificity score. Optimization in machine learning workflows is crucial, especially as parameter adjustment can significantly improve model performance across many measures.
To improve prediction, we used an ensemble learning strategy with a stacking classifier and meta-learners. The meta-learner is taught to aggregate predictions from various base models to use their strengths.
The meta-learner KNeighborsClassifier was most accurate at 98.75%, as represented in
Figure 9. It classified positive and negative classifications with 98.79% precision and 98.75% recall. A 98.74% F1 score indicated a balanced precision–recall link. This model’s 97.18% sensitivity and 100% specificity confirmed its ability to identify all relevant cases without false positives. Following closely behind, the DecisionTreeClassifier meta-learner had 98.57% accuracy. It had 98.57% recall, 98.60% precision, and a virtually identical F1 score. With 96.50% sensitivity and 98.98% specificity, this model could classify classes accurately. With 97.68% accuracy, Logistic Regression performed well. The F1 score was 97.67%, and its precision and recall was 97.69% and 97.68%, respectively. With 97.89% sensitivity and 100% specificity, it reliably identified positive instances without misclassifications. SVC meta-learner had 97.50% accuracy, 97.51% precision and recall, and a 97.49% F1 score. Its high sensitivity (97.18%) and outstanding specificity were consistent across measures. Finally, the GaussianNB meta-learner had 96.07% accuracy, 96.30% precision, and equal recall. GaussianNB’s F1 score reached up to 96.08% with 90.28% sensitivity and excellent specificity. It was the worst model, yet it accurately identified bad scenarios, as reported in
Table 9. Ensemble learning increases model performance by deliberately using meta-learners to fine-tune predictions based on base model strengths [
30].
The F1 score was 97.67% and precision and recall were 97.69% and 97.68%. With 97.89% sensitivity and 100% specificity, it reliably identified positive instances without misclassifications. SVC meta-learner had 97.50% accuracy, 97.51% precision and recall, and a 97.49% F1 score. Its high sensitivity (97.18%) and outstanding specificity were consistent across measures.
Figure 10 below further illustrates the reported results.
Finally, the GaussianNB meta-learner had 96.07% accuracy, 96.30% precision, and equal recall. GaussianNB’s F1 score can reach 96.08% with 90.28% sensitivity and excellent specificity. It was the worst model, yet it accurately identified bad scenarios. Ensemble learning increases model performance by deliberately using meta-learners to fine-tune predictions based on base model strengths.
Table 10 presents the effect of applying different optimization techniques—Particle Swarm Optimization (PSO) [
31], Genetic Algorithm (GA) [
32], Grey Wolf Optimizer (GWO) [
33], and DBFLA to the KNeighborsClassifier, which was identified as the best-performing classifier based on its baseline accuracy of 98.75%.
DBFLA significantly enhances classification accuracy, precision, recall, and F1 score while maintaining computational efficiency. Compared to traditional metaheuristic methods, DBFLA achieves superior optimization of the KNeighborsClassifier, making it the most effective approach for PV fault detection.
4.3. Model Interpretability Analysis Using SHAP and LIM
Machine learning models for photovoltaic (PV) fault detection often function as black-box classifiers, making it difficult to interpret their decision-making process. To address this challenge, Shapley Additive Explanations (SHAPs) [
34] and Local Interpretable Model-Agnostic Explanations (LIMEs) [
35] are applied to understand which input features contribute most to classification outcomes. Both methods provide insights into feature importance, helping assess how variations in voltage, current, irradiance, and temperature impact the model’s ability to detect faults accurately. SHAP is a game theory-based method that assigns importance values to each feature by considering all possible feature combinations. It computes Shapley values, which measure the contribution of each feature to the final prediction. One of SHAP’s advantages is that it provides both global (overall feature importance across all instances) and local (instance-specific) explanations. This dual capability allows for a comprehensive understanding of the classifier’s behavior, making it particularly useful for complex models like Gradient Boosting, deep learning, and ensemble classifiers. LIMEs, on the other hand, is a perturbation-based approach that explains predictions by slightly altering feature values and observing how the model’s decision changes. Unlike SHAP, which computes feature importance across the dataset, LIME focuses on local interpretability, generating approximate explanations for individual instances. While this method is faster and computationally less expensive than SHAP, it lacks the robustness needed for capturing global trends in classification.
Figure 11 presents a comparative analysis of SHAP and LIME feature importance scores for PV fault classification. The results indicate that voltage (V) and current (A) are the most influential features in determining whether a fault exists, followed by irradiance and temperature. Both SHAP and LIME agree on the rank ordering of features, but SHAP assigns slightly higher importance values to voltage and current, while LIME gives more weight to irradiance and temperature. This suggests that SHAP provides a more stable and theoretically sound assessment, while LIME may overemphasize localized patterns within the dataset.
This analysis reinforces the idea that DBFLA-optimized classifiers make more informed decisions by accurately leveraging the most relevant features. Since DBFLA enhances classification accuracy, its improved feature weighting may contribute to better differentiation between faulty and non-faulty states. The high importance of voltage and current in SHAP indicates that DBFLA helps the classifier focus on critical operational parameters rather than less influential environmental factors. This also implies that DBFLA enhances model robustness, ensuring that its predictions align with physical system behavior rather than being overly sensitive to transient variations in irradiance or temperature.
4.4. Discussion
This study compared machine learning models for photovoltaic (PV) fault detection before and after optimization and ensemble learning. Our investigation initially showed that some models performed effectively without optimization. The Random Forest classifier delivered the highest accuracy and balanced metrics, demonstrating its capacity to handle PV system datasets. While Quadratic Discriminant Analysis and Gradient Boosting performed well, they had reduced specificity, showing algorithms had trouble categorizing all negative cases. All models improved after optimization. Fine-tuning model parameters helped Random Forest improve accuracy and precision. Linear SVC and Gradient Boosting models were more trustworthy for practical applications after optimization improved their precision and recall rates. This improvement shows that optimization can improve model flaws, such as Quadratic Discriminant Analysis’s specificity from a lower base. Ensemble learning with many meta-learners improved model accuracy and specificity. As a meta-learner, KNeighborsClassifier has the highest accuracy, precision, and specificity. This shows its ability to combine base model predictions to reduce false positives and increase true positives. Stacking classifiers using meta-learners like Logistic Regression and SVC improved sensitivity and specificity. Ensemble approaches enhance model robustness and accuracy, which is essential for PV system defect detection. Research shows that optimization and ensemble strategies can improve fault detection performance in individual machine learning models. Optimizing model parameters improves generalizability and accuracy by tailoring them to data features. Ensemble learning, however, uses many models to increase decision-making precision and reliability. These insights help implement machine learning systems in real-world situations that require precision, reliability, and efficiency. They emphasize the need to continuously evaluate and update models to change PV data and system variables.
Table 11 presents a detailed evaluation of photovoltaic defect detection research. Each table entry describes the technique, data type, accuracy, and defects found during the investigations. Starting with the methodology, Artificial Neural Networks, Multilayer Perceptron Neural Networks, NARX with Fuzzy Inference, Probabilistic Neural Networks, Support Vector Machines, Radial Basis Function Neural Networks, and Kernel Extreme Learning Machines are discussed. These methods demonstrate the variety of research methods used to handle PV system failure detection’s complexity, as shown in
Figure 12 below.
These investigations use simulated, mixed, or real data. Real data studies provide more realistic insights into real-world situations. The accuracies in these experiments vary, showing that diverse methods work. For instance, NARX with Fuzzy Inference are accurate, demonstrating the power of advanced modeling techniques. Other research utilizing simpler machine learning models achieved slightly lower accuracy. These studies’ faults are crucial for understanding their practical implications. Normal functioning, degradation, short-circuits, shadowing, open circuits, and module mismatches are common issues. PV system efficiency and lifespan depend on detecting and identifying these problems. The final model in the table achieves 98.75% accuracy using real data and stacking classifiers with meta-learners. Identifying PV system module mismatch, open-circuit, and short-circuit problems helps manage them. This post discusses improvement strategies for defect detection accuracy and reliability.