Photovoltaic (PV) systems are created according to the series, parallel or series-parallel connection type of PV panels. Solar panels that form the PV system can have different irradiance values at different times of the day. This condition, which is called partial shading, causes the current and voltage values produced by the panels to fluctuate. Maximum power point tracking (MPPT) algorithms are used to ensure that PV systems operate at maximum power under all environmental conditions. MPPT algorithms are used to optimize the duty cycle of DC-DC converters in order to transfer maximum power to the load. In this study, a two-stage structure is used for MPPT. In the first stage, a reference voltage value is generated using the gaussian process regression (GPR) machine learning algorithm. In the second stage, the duty cycle of the PWM signal required for MPPT is optimized using the super twisting sliding mode controller (STSMC). The performance of the proposed method for three different scenarios is compared with the cuckoo search algorithm (CSA) from metaheuristic optimization algorithms and the perturb and observe (P&O) algorithm from classical optimization algorithms using real-time data. The software used to analyze and compare the researched methods is MATLAB/Simulink R2021b. The proposed method has performed better compared to both CSA and P&O for four conducted scenarios. Additionally, it was observed that the proposed method leads to less oscillation at the MPP point compared to P&O and CSA.