Spectral learning of dynamic systems from nonequilibrium data