机器学习概念 —— 样本距离矩阵

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lanchunhui/article/details/82532555
  • 样本( X N d )之间的距离矩阵

    N, d = X.shape
    X_square = np.sum(X*X, axis=1).reshape(N, 1)
    dist_mat = 2*X_square - 2*X.dot(X.T)

    p j | i = exp ( x i x j 2 / 2 σ i 2 ) k i exp ( x i x k 2 / 2 σ i 2 )

    def _joint_distribution_matrix(D, sigma):
        P = np.exp(-D*D/2/sigma**2)
        P /= np.sum(P, axis=1)
        return P

猜你喜欢

转载自blog.csdn.net/lanchunhui/article/details/82532555