pyhton implementation of spectral learning