Overview
Here I share Python codes for hyperparameter optimization using metaheuristics, including Genetic Algorithm (GA), Particle Swarm Optimization (PSO), and Grey Wolf Optimization (GWO). If any of the code benefits your research, please give a credit by citing Zhu et al. (2022): Zhu, J. J., Borzooei, S., Sun, J., & Ren, Z. J. (2022). Deep Learning Optimization for soft sensing of hard-to-measure wastewater key variables. ACS ES&T Engineering, 2(7), 1341-1355. https://doi.org/10.1021/acsestengg.1c00469
Trouble shooting
The sample codes were designed for 2 hidden layers multilayer perceptrons (MLPs). You can change the hyperparameter ranges based on your preferences.
If the code doesn't work for you, please check the following list:
• The codes were created in 2019 and tested till 2022 in both Windows 7/10 and ubuntu 16.04, but it may not fit your Python environment or OS environment.
• You may want to check the packages and their version if any compatible problem exist.
• The sample codes skip some unnessary data processing steps, so check if any issues associated with data preprocessing.
• The sample codes assume that you use parallel computing (i.e. multiple CPU cores). If you use single CPU core, please change the codes accordingly.
• Check the above paper and its SI for more information.
Code running examples
PSO
GA
GW
Additional credits
Most of the codes were obtained or modified from other sources, additional credits to Hossam Faris and Jiachun Sun.