I have a dataset from custom abstract objects and a custom distance function. Is there any good SVM libraries that allows me to train on my custom objects (not 2d points) and my custom distance function?
I searched the answers in this similar stackoverflow question , but none of them allows me to use custom objects and distance functions.
First things first.
SVM does not work on distance functions , it only accepts dot products . So your distance function (actually similarity, but usually 1-distance is similarity) has to:
s(a,b)=s(b,a)
s(a,a)>=0, s(a,a)=0 <=> a=0
s(ka, b) = ks(a,b)
and s(a+b,c) = s(a,c) + s(b,c)
This can be tricky to check, as you actually ask "is there a function from my objects to some vector space, phi such that s(phi(x), phi(y))
" is a dot-product, thus leading to definition of so called kernel , K(x,y)=s(phi(x), phi(y))
. If your objects are themselves elements of vector space, then sometimes it is enough to put phi(x)=x
thus K=s
, but it is not true in general.
Once you have this kind of similarity nearly any SVM library (for example libSVM
) works with providing Gram matrix . Which is simply defined as
G_ij = K(x_i, x_j)
Thus requiring O(N^2)
memory and time. Consequently it does not matter what are your objects, as SVM only works on pairwise dot-products , nothing more.
If you look appropriate mathematical tools to show this property, what can be done is to look for kernel learning from similarity . These methods are able to create valid kernel which behaves similarly to your similarity.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.