, , , . , .
, :
A - . , . Scikit-learn SVM . , (, , , , ), .
:
def my_kernel(x, y):
"""Compute My Kernel
Parameters
----------
x : array, shape=(N, D)
y : array, shape=(M, D)
input vectors for kernel similarity
Returns
-------
K : array, shape=(N, M)
matrix of similarities between x and y
"""
return similarity_matrix
, , :
def linear_kernel(x, y):
return np.dot(x, y.T)
,
def linear_kernel_2(x, y):
M = np.array([[1, 0],
[0, 1]])
return np.dot(x, np.dot(M, y.T))
M
, . ; M
, .
, : ( ) SVM .