The Hopkins statistic, is a statistic which gives a value which indicates the cluster tendency, in other words: how well the data can be clustered.If the value is between {0.01, ...,0.3}, the data is regularly spaced.If the value is around 0.5, it is random.If the value is between {0.7, ..., 0.99}, it has a high tendency to cluster.I have a question about my implementation of the Hopkins statistic.Is it correct? If so, other people can use it :)X is the data with shape (n,m).d = len(vars) # columnsn = len(X) # rowsm = int(0.1 * n) # heuristic from article [1]from sklearn.neighbors import NearestNeighborsnbrs = NearestNeighbors(n_neighbors=1, algorithm='brute').fit(X)from random import samplerand_X = sample(range(0, n, 1), m)ujd = []wjd = []for j in range(0, m):    u_dist, _ = nbrs.kneighbors(np.random.normal(size=(1, d)).reshape(1, -1), 2, return_distance=True)    ujd.append(u_dist[0][1])    w_dist, _ = nbrs.kneighbors(X[rand_X[j]].reshape(1, -1), 2, return_distance=True)    wjd.append(w_dist[0][1])H = sum(ujd) / (sum(ujd) + sum(wjd))print HAny recommendations are much appreciated.[1] Validating Clusters using the Hopkins Statistic from IEEE 2004.
Cluster tendency using Hopkins statistic implementation in Python
machine learning;python;clustering;statistics;unsupervised learning