This research work aims at providing power quality improvement for the nonlinear load to improve the system performance indices by eliminating maximum total harmonic distortion (THD) and reducing neutral wire current. The idea is to integrate a shunt hybrid active power filter (SHAPF) with the system using machine learning control techniques. The system proposed has been evaluated under an artificial neural network (ANN), gated recurrent unit, and long short-term memory for the optimization of the SHAPF. The method is based on the detection of harmonic presence in the power system by testing and comparison of traditional pq0 theory and deep learning neural networks. The results obtained through the proposed methodology meet all the suggested international standards of THD. The results also satisfy the current removal from the neutral wire and deal efficiently with minor DC voltage variations occurring in the voltage-regulating current. The proposed algorithms have been evaluated on the performance indices of accuracy and computational complexities, which show effective results in terms of 99% accuracy and computational complexities. deep learning-based findings are compared based on their root-mean-square error (RMSE) and loss function. The proposed system can be applied for domestic and industrial load conditions in a four-wire three-phase power distribution system for harmonic mitigation.