The development of reliable, yet computationally efficient interatomic forcefields is key to facilitate the modeling of glasses. However, the parametrization of novel forcefields is challenging as the high number of parameters renders traditional optimization methods inefficient or subject to bias. Here, we present a new parameterization method based on machine learning, which combines ab initio molecular dynamics simulations and Bayesian optimization. By taking the examples of silicate and chalcogenide glasses, we show that our method yields new interatomic forcefields that offers an unprecedented agreement with ab initio simulations. This method offers a new route to efficiently parametrize new interatomic forcefields for disordered solids in a non-biased fashion.