In this study, a hybrid of the artificial neural network-imperialist competitive algorithm (ANN-ICA) has been applied for prediction and optimization of the molecularly imprinted solid phase extraction method. This method has been used for the pre-concentration of methylene blue (MB) from environmental water samples prior to UV-Vis spectrophotometry. Molecular imprinted polymer sorbents were synthesized using radical polymerization by MB, 4-vinylpyridine, ethylene-glycol-dimethacrylate, 2,2′-azobisisobutyronitrile and methanol as a template, functional monomer, cross-linker, initiator, and porogen, respectively. The imprinted polymer was characterized by Fourier transform infrared spectroscopy and scanning electron microscopy. The pH, adsorbent mass, adsorption time, eluent volume, and extraction time were been selected as input parameters and the recovery of MB was considered as an output variable of the ANN model. The results were then compared according to the performance function and determination coefficient. The Freundlich and Langmuir adsorption models were used to explain the isotherm constant. The maximum adsorption capacity was 417 mg g -1 . At the optimized conditions, the limit of detection and relative standard deviation was found to be 0.31 μg l -1 and <1.7%, respectively. This method was applied to analysis the MB in various water samples.