For the built-in kernels you supply the data and the kernel you want to use, i.e.
model = svmtrain(Xtrain, ytrain, kernel=Kernel.Polynomial)
svmpredict(model, Xtest)
For a custom kernel you need to calculate the gram matrix manually:
K = make_gram(Xtrain, my_kernel)
model = svmtrain(K, ytrain, kernel=Kernel.Precomputed)
KK = make_gram(Xtrain, Xtest, my_kernel)
svmpredict(model, KK)
I think a more desirable way to do this would be to allow a callable as kernel argument (and calculate the gram matrix internally), i.e.
model = svmtrain(Xtrain, ytrain, kernel=my_kernel)
svmpredict(model, Xtest)
which is more syntactically consistent with the way the built-in kernels are used. Scikit-learn, for example, allows this in addition to precomputed gram matrices.
For the built-in kernels you supply the data and the kernel you want to use, i.e.
For a custom kernel you need to calculate the gram matrix manually:
I think a more desirable way to do this would be to allow a callable as
kernel
argument (and calculate the gram matrix internally), i.e.which is more syntactically consistent with the way the built-in kernels are used. Scikit-learn, for example, allows this in addition to precomputed gram matrices.