def polynomial_kernel(X, Y=None, degree=3, gamma=None, coef0=1):
 (X, Y) = check_pairwise_arrays(X, Y)
 if (gamma is None):
  gamma = (1.0 / X.shape[1])
 K = safe_sparse_dot(X, Y.T, dense_output=True)
 K *= gamma
 K += coef0
 K **= degree
 return K

def polynomial_kernel ( X , Y = None , degree = 3 , gamma = None , coef0 = 1 ) : ( X , Y ) = check_pairwise_arrays ( X , Y ) if ( gamma is None ) : gamma = ( 1.0 / X . shape [ 1 ] ) K = safe_sparse_dot ( X , Y . T , dense_output = True ) K *= gamma K += coef0 K **= degree return K
compute the polynomial kernel between x and y:: k = ^degree read more in the :ref:user guide <polynomial_kernel> .