A machine learning approach to exoplanet spectroscopy