Model predictive control (MPC) has proven to be a promising method to exploit energy saving potentials in building energy systems. However, they are not widespread in practice due to high hard-and software requirements, high computational effort, and missing trust and know-how among practitioners. Approximate MPC can address these challenges by replacing the hard-and software-intensive optimization program by black box models. Machine learning models such as Artificial Neural Networks or tree-based algorithms have been widely investigated by the scientific community. However, a comparison of Artificial Neural Networks with advanced tree-based models like Random Forest and Gradient Boosting is still missing. In addition, the relation between the models' training and the resulting control performance has not yet been assessed. We close these gaps by investigating the optimal control based on an MPC of a PV-battery system in a non-residential building. The MPC optimizes the battery's power based on a preceding peak load optimization. The MPC is imitated by three machine learning models, namely, an Artificial Neural Network, a Random Forest, and Gradient Boosting, whose performance is subsequently evaluated open-and closed loop. While Gradient Boosting results in the highest open-loop performance with an R 2 of 0.83, it deviates more significantly from the optimal control trajectory than, e.g., the Artificial Neural Network. Nonetheless, Gradient Boosting even outperforms the teacher MPC when considering the system's annuity. This is explained by its ability to push beyond the peak load constraints which are set within the optimization. A rule-based backup controller is, therefore, included for all approximator-based controllers. Based on this, the approximators result in a peak load reduction between 5 % and 7 % compared to the benchmark and a change in annuity between −1 % and 4 % compared to the MPC. To summarize, all approximators can retain most of the MPC's advantages but do not surpass its overall performance.