def estimate_ls(self, X):
Ntrain = X.shape[0]
if Ntrain < 10000:
X1 = np.copy(X)
else:
randind = np.random.permutation(Ntrain)
X1 = X[randind[0:(5*self.no_pseudos[0])], :]
# d2 = compute_distance_matrix(X1)
D = X1.shape[1]
N = X1.shape[0]
triu_ind = np.triu_indices(N)
ls = np.zeros((D, ))
for i in range(D):
X1i = np.reshape(X1[:, i], (N, 1))
d2i = cdist(X1i, X1i, 'euclidean')
# d2i = d2[:, :, i]
d2imed = np.median(d2i[triu_ind])
# d2imed = 0.01
# print d2imed,
ls[i] = np.log(d2imed + 1e-16)
return ls
评论列表
文章目录