defeval_classifier(x,alphas,data,label,gamma,b=0):# evaluates the distance to the hyper plane according to 16.5.32 on p. 891 (Numerical Recipes); sign is the assigned class; x.shape = ...xD
defeval_offset_MM(alphas,data,label,gamma,C,useavgforb=True):# evaluates offset b according to 16.5.37 (Mangasarian-Musicant variant) NOTE: does not seem to work with integer/very coarsely spaced alpha!
returnnp.sum(alphas*label)
defeval_offset_avg(alphas,data,label,gamma,C,useavgforb=True):# evaluates offset b according to 16.5.33
cross=eval_classifier(data,alphas,data,label,gamma)# cross[i] = sum_j aj yj K(xj, xi) (error in Numerical Recipes)