Electronic Excited States from Physically Constrained Machine Learning