Hello everybody,
I'm encountering a trouble fact dealing with sklearn.svm user
defined kernel. Here is a minimal example :
from sklearn.datasets import load_digits
from sklearn.svm import SVC
import numpy as np
digits = load_digits(2)
X, y = digits.data, digits.target
x = X[1,:]
m1 = SVC(kernel='rbf',gamma=1)
m1.fit(X, y)
print (m1.predict(x))
def my_kernel(x,y):
d = x - y
c = d.dot(d.T)
return np.exp(-c)
m2 = SVC(kernel=my_kernel)
m2.fit(X, y)
print (m2.predict(x))
m1 is the standard RBF kernel, x is a data and m1.predict(x) return a +1/-1
value
as intended.
m2 is the same kernel but user implemented, and if m2.fit(X) run,
m2.predict(x)
gives an array of +1/-1...
Along the same way m2.predict(X) doesn't work and gives a broadcasting error.
I have also exposed the problem on stackoverflow.
I would be glad for any help.
--
Vincent Leclère
------------------------------------------------------------------------------
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general