The faults in photovoltaic (PV) array lead to increased system losses and even fire hazards. The most frequent faults in PV strings are line-to-line (LL) and line-to-ground (LG) faults. Many efforts have been made to develop machine learning-based methods that are capable of detecting faults. However, these methods do not consider low mismatch faults, high impedance faults, active MPPT control, the effect of blocking diodes, step changes in irradiation levels and partial shading conditions in a single window. In this article, a novel and efficient modified binary genetic algorithm (MBGA) based on the weighted K-nearest neighbor method, which incorporates all the abovementioned constraints, has been proposed to identify and classify faults. In addition, it also gives information about the severity of faults. Unlike other machine learning (ML)-based methods, the developed technique considers features based on both frequency and time domain and employs MBGA to extract the optimal set of features, which further improves the accuracy of the algorithm and reduces the size of the dataset. The proposed method efficiently distinguishes faults from sudden shading conditions as both have similar characteristics and prevent false detection. Moreover, it has been verified that the developed method detects faults with an accuracy of 97.3% and classifies LL and LG faults with a precision of 99.25%.