The integration of solar photovoltaic (PV) systems into weak power grids presents significant challenges due to low short circuit ratios (SCR), resulting in voltage instability, high harmonic distortion, and diminished fault tolerance. This study proposes a data-driven framework to enhance grid stability and power quality by employing a Unified Power Quality Conditioner (UPQC) integrated with Proportional-Integral (PI) controllers. A comprehensive simulation model was developed using MATLAB/Simulink and validated through hardware-in-the-loop (HIL) experiments. Key electrical performance metrics—such as voltage profiles, total harmonic distortion (THD), and reactive power—were collected and analyzed. To enhance system insight, the dataset was further processed using statistical analysis and predictive modeling techniques to evaluate control response under varying solar irradiance and load conditions. The results demonstrate that the UPQC system maintains stable voltage, reduces THD to within IEEE-519 standards, and improves power factor to 0.98. This research highlights the potential of combining power electronics control with data-centric evaluation to ensure reliable renewable energy integration in weak grid environments. The proposed system contributes toward developing intelligent grid-support solutions for sustainable energy transitions and process innovation.