Optimization of synchrotron light sources using machine learning