Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polynomial kernel, d=2, c=1 #17

Closed
yamauchilab opened this issue Apr 4, 2023 · 2 comments
Closed

polynomial kernel, d=2, c=1 #17

yamauchilab opened this issue Apr 4, 2023 · 2 comments

Comments

@yamauchilab
Copy link

polynomial kernel of Rdimtools and kernlab return different values. Isn't this a bug?

e.g.,

(x = matrix(c(1:6), 2, 3))
 [,1] [,2] [,3]

[1,] 1 3 5
[2,] 2 4 6

library(Rdimtools)
(x_kpoly_Rdim_d2 = aux.kernelcov(x, ktype = c("polynomial", d=2, c=1)))

$K
[,1] [,2]
[1,] 37 46
[2,] 46 58

$Kcenter
[,1] [,2]
[1,] 0.75 -0.75
[2,] -0.75 0.75

library(kernlab)
linear_kern <- polydot(degree = 2, scale = 1, offset=1)
(x_kpoly_d2_kernlab = kernelMatrix(kernel = linear_kern, x=x))

An object of class "kernelMatrix"
[,1] [,2]
[1,] 1296 2025
[2,] 2025 3249

@kisungyou
Copy link
Owner

@yamauchilab thanks for your input. The aux.kernelcov takes a parameter in ktype in order, not by assigning in a vector. Hence, in this case, you should use ktype=c("polynomial",1,2) in an order of the parameters as described.

@yamauchilab
Copy link
Author

yamauchilab commented Apr 9, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants