Clusterability
Clusterability
Compute clusterability metric.
Clusterability measures how strongly a dataset tends to form clusters rather than being randomly distributed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_neighbors
|
int
|
Number of nearest neighbors used in the Hopkins statistic computation. |
required |
Notes
The Hopkins statistic is a commonly used measure of clusterability. It compares the distances of points in the dataset to their nearest neighbors with distances from uniformly distributed random points to their nearest neighbors in the dataset.
If points are aggregated, Clusterability approached 1, whereas a value close to 0.5 suggests randomness.
Read more in the User Guide
References
Lawson, R. G., & Jurs, P. C. (1990). New index for clustering tendency and its application to chemical problems. Journal of chemical information and computer sciences, 30(1), 36-41.
Source code in pyeyesweb/analysis_primitives/clusterability.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
__call__(sliding_window)
Callable interface to compute clusterability directly on a SlidingWindow instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sliding_window
|
SlidingWindow
|
The sliding window object containing the data. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Output of |
Source code in pyeyesweb/analysis_primitives/clusterability.py
__init__(n_neighbors)
Initialize the Clusterability object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_neighbors
|
int
|
Number of nearest neighbors to use in the Hopkins statistic computation. |
required |
random_state
|
int
|
Random seed for reproducibility. Default is None. |
required |
Source code in pyeyesweb/analysis_primitives/clusterability.py
compute_clusterability(signals)
Compute the clusterability of a sliding window of signals using the Hopkins statistic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signals
|
SlidingWindow
|
A sliding window object containing signal data. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing: - 'hopkins_statistic' (float): Computed Hopkins statistic. Returns NaN if the window is not full or computation fails. |
Source code in pyeyesweb/analysis_primitives/clusterability.py
compute_hopkins_statistic(data)
Compute the Hopkins statistic for a given dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Input data of shape (n_samples, n_features). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Hopkins statistic value. Returns NaN if data is insufficient or invalid. |