In this study, artificial intelligence (AI) models including adaptive neuro-fuzzy inference systems (ANFIS), artificial neural networks (ANN), and support vector regression (SVR) were applied to predict the removal efficiency of phosphate from wastewaters using the electrocoagulation process. The five input variables used in this study were current intensity, initial phosphate concentration, initial pH, treatment time, and electrode type. The optimal hyperparameters of the ANN and SVR models were found by integrating metaheuristic algorithms such as genetic algorithms (GA) and particle swarm optimization (PSO) to these models. To increase the reliability and robustness of the developed AI models, a search for optimal hyperparameters was conducted based on repeated random sub-sampling validation instead of a single split approach. The results demonstrated that the effectiveness of the data-driven model depends on how the data is distributed to the training, validation, and test sets. However, hybrid ANN models outperformed other models and PSO-ANN models showed exceptional generalization performance for the different sub-datasets. The average MSE, R2, and MAPE values of the 10 test subsets for PSO-ANN were determined as 7.201, 0.981, and 2.022, respectively. The EC process was interpreted for phosphate removal efficiency using the trained PSO-ANN model. The two input factors with the greatest influence on the effectiveness of phosphate removal, according to the results, are the electrode type and initial phosphate concentration. Additionally, it was found that lowering the pH and initial phosphate concentration and increasing the current intensity and treatment time enhance the removal efficiency.