Metrics Embedding#
embedding
#
| FUNCTION | DESCRIPTION |
|---|---|
trustworthiness |
Compute trustworthiness of low-dimensional embedding. |
continuity |
Compute continuity of low-dimensional embedding Z. |
local_structure_preservation |
Measure preservation of local pairwise distance structure. |
Functions#
trustworthiness(X: torch.Tensor, Z: torch.Tensor, k_neighbor: int = 5) -> torch.Tensor
#
Compute trustworthiness of low-dimensional embedding.
Trustworthiness measures how well the local neighborhood structure from high-dimensional space is preserved in low-dimensional space. It penalizes points that appear as neighbors in Z but are far apart in X [1].
Higher values (closer to 1) indicate better preservation of local neighborhoods from high to low dimensional space.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
High-dimensional data, shape (n_samples, n_features).
TYPE:
|
Z
|
Low-dimensional embedding, shape (n_samples, m_features).
TYPE:
|
k_neighbor
|
Number of neighbors.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Trustworthiness score. |
Source code in spectre/metrics/embedding.py
continuity(X: torch.Tensor, Z: torch.Tensor, k_neighbor: int = 5) -> torch.Tensor
#
Compute continuity of low-dimensional embedding Z.
Continuity measures how well the local neighborhood structure from low-dimensional space is preserved when mapping back to high-dimensional space. It penalizes points that appear as neighbors in X but are far apart in Z [1].
Higher values (closer to 1) indicate better preservation of local neighborhoods from low to high dimensional space.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
High-dimensional data, shape (n_samples, n_features).
TYPE:
|
Z
|
Low-dimensional embedding, shape (n_samples, m_features).
TYPE:
|
k_neighbor
|
Number of neighbors to consider.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Continuity score in [0, 1]. |
Source code in spectre/metrics/embedding.py
local_structure_preservation(X: torch.Tensor, Z: torch.Tensor, k_neighbor: int = 5, metric: str = 'spearman') -> torch.Tensor
#
Measure preservation of local pairwise distance structure.
Computes correlation between pairwise distances in high and low dimensional spaces, focusing on local neighborhoods.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
High-dimensional data, shape (n_samples, n_features).
TYPE:
|
Z
|
Low-dimensional embedding, shape (n_samples, m_features).
TYPE:
|
k_neighbor
|
Number of neighbors to consider for local structure.
TYPE:
|
metric
|
Correlation metric: "spearman", "pearson".
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Correlation coefficient in [-1, 1]. Higher values indicate better preservation of local distances. |
Source code in spectre/metrics/embedding.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |