Estimating the mass of galactic components using machine learning algorithms