This is the python version SMO algorithm