R/utils.R

# Linear kernel
linear_kernel <- function(x1, x2, param = NULL)
{
  return (t(x1) %*% x2)
}


# Polynomial kernel
poly_kernel <- function(x1, x2, param = 2)
{
  return ((1 +  t(x1) %*% x2) ^ param)
}



# Radial basis kernel
rbf_kernel <- function(x1, x2, param = 1)
{
  return (exp(-(norm((x1 - x2), type="2") ^ 2) * param))
}

Try the svmplus package in your browser

Any scripts or data that you put into this service are public.

svmplus documentation built on May 2, 2019, 3:40 p.m.