def rbf_kernel(X, Y=None, gamma=None):
 (X, Y) = check_pairwise_arrays(X, Y)
 if (gamma is None):
  gamma = (1.0 / X.shape[1])
 K = euclidean_distances(X, Y, squared=True)
 K *= (- gamma)
 np.exp(K, K)
 return K

def rbf_kernel ( X , Y = None , gamma = None ) : ( X , Y ) = check_pairwise_arrays ( X , Y ) if ( gamma is None ) : gamma = ( 1.0 / X . shape [ 1 ] ) K = euclidean_distances ( X , Y , squared = True ) K *= ( - gamma ) np . exp ( K , K ) return K
compute the rbf kernel between x and y:: k = exp for each pair of rows x in x and y in y .