1

I am experimenting with gaussian process model and in particular the implementation in the kernlab R package. I found the model fitting hangs when excised with linear kernels. Profiling shows it is busy doing matrix multiplication via operator "%*%". A reproducible example is given below:

data(iris)
#this doesn't hang
test <- kernlab::gausspr(Species~.,data=iris,type="classification",kernel="rbfdot")
#this hangs with message "Setting default kernel parameters"
test <- kernlab::gausspr(Species~.,data=iris,type="classification",kernel="vanilladot")
#this also hangs
test <- kernlab::gausspr(Species~.,data=iris,type="classification",kernel="polydot", kpar=list(degree=1))
#this doesn't hang
test <- kernlab::gausspr(Species~.,data=iris,type="classification",kernel="polydot", kpar=list(degree=2))

Any idea what is going on here? Many thanks!

pacifly
  • 51
  • 1
  • 4
  • update: the problem is traced down to the `while` loop solving for `alphag`, where the `gradnorm` oscillates between 0.01 and 0.02 after 6 loops, not vanishing to zero... – pacifly Nov 14 '17 at 20:21

1 Answers1

1

You need to specify different tuning hyperparameters kpar for each kernel type. The default option is kpar = list(sigma = 0.1), which works only for the Gaussian kernel.

The list of hyperparameters for each kernel kpar is below:

  • sigma inverse kernel width for the Radial Basis kernel function "rbfdot" and the Laplacian kernel "laplacedot".

  • degree, scale, offset for the Polynomial kernel "polydot".

  • scale, offset for the Hyperbolic tangent kernel function "tanhdot".

  • sigma, order, degree for the Bessel kernel "besseldot".

  • sigma, degree for the ANOVA kernel "anovadot".

If you want to understand better why, check the kernel functions in this pdf, on page 9.

However things are a bit trickier for the simple LINEAR kernel, i.e. kernel = vanilladot. There are NO hyperparameters to be specified. I tried kpar = NA, but it did not work. I figured out a way to get the LINEAR kernel results using the polynomial one with special tuning:

test <- kernlab::gausspr(Species~.,data=iris,type="classification",
                     kernel="polydot", kpar=list(degree =1, scale =1, offset =0))