I would like to do a grid-search through cross-validation for a custom kernel SVM using scikit-learn. More precisely following this example I want to define a kernel function like
def my_kernel(x, y):
"""
We create a custom kernel:
k(x, y) = x * M *y.T
"""
return np.dot(np.dot(x, M), y.T)
where M is a parameter of the kernel (like the gamma in the gaussian kernel).
I want to feed this parameter M through GridSearchCV, with something like
parameters = {'kernel':('my_kernel'), 'C':[1, 10], 'M':[M1,M2]}
svr = svm.SVC()
clf = grid_search.GridSearchCV(svr, parameters)
So my question is : how to define the my_kernel so that the M variable will be given by GridSearchCV ?