(X, sigma=1.0, check_arr=True)
return np.exp((-tmp.T.dot(np.ones((1, n))) - np.ones((n, 1)).dot(tmp) + 2 * (X.dot(X.T))) / (2 * (sigma ** 2)))
Calculate kernel matrix between X and X.

    Parameters
    ----------
    X: np.ndarray
        data matrix with [n_samples, n_features]

    sigma: float, optional (default=1.0)
        the width in gaussian kernel.

    check_arr: bool, optional (default=True)
        whether to check the given feature matrix.

    Returns
    -------
    K: np.ndarray
        Kernel matrix between X and X.
Calculate kernel matrix between X and X.
Calculate kernel matrix between X and X .
def get_gaussian_kernel_mat(X, sigma=1.0, check_arr=True):
    """Calculate kernel matrix between X and X.

    Parameters
    ----------
    X: np.ndarray
        data matrix with [n_samples, n_features]

    sigma: float, optional (default=1.0)
        the width in gaussian kernel.

    check_arr: bool, optional (default=True)
        whether to check the given feature matrix.

    Returns
    -------
    K: np.ndarray
        Kernel matrix between X and X.
    """
    if check_arr:
        X = check_array(X, accept_sparse='csr', ensure_2d=True, order='C')
    else:
        if not isinstance(X, np.ndarray):
            X = np.asarray(X)
    n = X.shape[0]
    tmp = np.sum(X ** 2, axis=1).reshape(1, -1)
    return np.exp((-tmp.T.dot(np.ones((1, n))) - np.ones((n, 1)).dot(tmp) + 2 * (X.dot(X.T))) / (2 * (sigma ** 2)))
def get_gaussian_kernel_mat ( X , sigma = 1.0 , check_arr = True ) : if check_arr : X = check_array ( X , accept_sparse = 'csr' , ensure_2d = True , order = 'C' ) else : if not isinstance ( X , np . ndarray ) : X = np . asarray ( X ) n = X . shape [ 0 ] tmp = np . sum ( X ** 2 , axis = 1 ) . reshape ( 1 , - 1 ) return np . exp ( ( - tmp . T . dot ( np . ones ( ( 1 , n ) ) ) - np . ones ( ( n , 1 ) ) . dot ( tmp ) + 2 * ( X . dot ( X . T ) ) ) / ( 2 * ( sigma ** 2 ) ) )