A reliable activity proxy in SPIRou spectra of M dwarfs using machine learning