opencv - SVM : How to calculate the distance of a point to the margin? -


hello i'm developing cbir using opencv features extraction , svm.

my issues : i'm using one_class classifier rbf kernel. i'm using function predict of opencvsvm last parameter @ true ( means if classifieur binary return signed distance margin ) in order classify data.

but if parameters set true it's return label ( not helpful in case).

so question : equation ( knowing vector support) calcul distance of data marge ?

thanks

in general, distance separating hyperplane exact same thing svm using classification. in other words classification equation sign of signed distance asking for.

given kernel k, support vectors sv_i, , alpha coefficients alpha_i (lagrange multipliers) , threshold (bias) b equation simply, given labels associated each support vector y_i:

sgn_dist(x) = sum_i alpha_i y_i k(x, sv_i) - b 

this signed distance, positive value when on positive side , negative otherwise, if want "true" distance (without label) divide label or take absolute value

dist(x) = |sgn_dist(x)| = |sum_i alpha_i y_i k(x, sv_i) - b| 

Comments