To improve the prediction accuracy of water quality time series, a type of prediction model based on wavelet packet transform (WPT), chameleon optimization algorithm (CSA), cheetah optimization (CO) algorithm and mountain gazelle optimization (MGO) algorithm is proposed to optimize the gated recurrent unit (GRU) and long short-term memory networks (LSTM). Firstly, the time series of pH , DO, CODMn and NH3—N are stabilized by WPT, by which several regular subsequence components are obtained. Secondly, the CSA, CO and MGO algorithms are briefly introduced and then applied to the optimization of the hyper-rparameters of GRU and LSTM, by which the WPT-CSA-GRU, WPT-CO-GRU, WPT-MGO-GRU, WPT-CSA-LSTM, WPT-CO-LSTM, WPT-MGO-LSTM models are established. Finally, the established models are used to predict and reconstruct the components of pH, DO, CODMn, NH3—N, meanwhile, WPT-GRU, WPT-LSTM and WPT-CSA-SVM, WPT-CO-SVM, WPT-MGO-SVM models are established for comparative analysis. Then the models are verified by the prediction of pH, DO, CODMn, NH3—N of Guanyinshan section in Kunming, Yunnan Province. The results show that the prediction accuracy of WPT-CSA-GRU, WPT-CO-GRU, WPT-MGO-GRU, WPT-CSA-LSTM, WPT-CO-LSTM, WPT-MGO-LSTM models for pH, DO, CODMn, NH3—N of the case section are better than the comparison models with better prediction performance, of which WPT-CSA-GRU, WPT-CO-GRU, WPT-MGO-GRU models have the highest prediction accuracy; CSA, CO and MGO can effectively tune the hyper-parameters of GRU and LSTM, and significantly improve the prediction performance of GRU and LSTM; the six proposed models have high prediction accuracy and small calculation scale, which can be recognized as effective prediction models for water quality time series. This study can provide some reference for relevant water quality prediction research.