Random feature approximation for general spectral methods