The aim of the present study is to develop an efficient algorithm for simulating nonequilibrium gas-dynamic problems using the detailed state-to-state approach for vibrationalchemical kinetics. Optimization of the vibrational relaxation rate computation using machine learning algorithms is discussed. Since traditional calculation methods require a large number of operations, time and memory, it is proposed to predict the relaxation rates instead of explicit calculations. K-nearest neighbour and histogram based gradient boosting algorithms are applied. The algorithms were trained on datasets obtained using two classical models for the rate coefficients: the forced harmonic oscillator model and that of Schwartz-Slawsky-Herzfeld. Trained algorithms were used to solve the problem of spatially homogeneous relaxation of the O2-O mixture. Comparison of accuracy and calculation time by different methods is carried out. It is shown that the proposed algorithms allow one to predict the relaxation rates with good accuracy and to solve approximately the set of governing equations for the fluid-dynamic variables. Thus, we can recommend the use of machine learning methods in nonequilibrium gas dynamics coupled with detailed vibrational-chemical kinetics. The ways of further optimization of the considered methods are discussed.