Spectral analysis of light is one of the oldest and most versatile scientific methods and the basis of countless techniques and instruments. Miniaturized spectrometers have recently seen great advances, but challenges remain before they are widely deployed. We report an integrated photonic spectrometer that achieves high performance with minimal component complexity by combining imaging of light propagation patterns in multi-mode interference waveguides with machine learning analysis. We demonstrate broadband operation in the visible and near-infrared, 0.05 nm spectral resolution, and an array of four spectrometers on a single chip. Two canonical applications are implemented: spectral analysis of the solar spectrum with neural network reconstruction and detection of Rayleigh scattering from microbeads on an optofluidic chip using principal component classification. These results illustrate the potential of this approach for high-performance spectroscopy across disciplines.