Metrics Manifold#
manifold
#
| FUNCTION | DESCRIPTION |
|---|---|
intrinsic_dimension |
Estimate intrinsic dimension of data manifold. |
Functions#
intrinsic_dimension(X: torch.Tensor, method: str = 'twonn', k_neighbor: int = 50, eps: float = torch.finfo(torch.float32).eps) -> torch.Tensor
#
Estimate intrinsic dimension of data manifold.
Intrinsic dimension is the minimum number of parameters needed to describe the data.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Data matrix, shape (n_samples, in_features).
TYPE:
|
method
|
Estimation method:
TYPE:
|
k_neighbor
|
Number of neighbors for MLE estimation. Ignored for TwoNN.
TYPE:
|
eps
|
Small constant to avoid numerical issues.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Estimated intrinsic dimension (scalar). |
Examples:
Estimate intrinsic dimension of Swiss roll (2D manifold):
>>> from sklearn.datasets import make_swiss_roll
>>> X = torch.from_numpy(make_swiss_roll(n_samples=500, noise=0.0)[0])
>>> intrinsic_dimension(torch.from_numpy(X), method="twonn")
2.05
Compare different estimators:
>>> id_twonn = intrinsic_dimension(X, method="twonn")
>>> id_mle = intrinsic_dimension(X, method="mle", k_neighbor=20)
>>> print(f"TwoNN: {id_twonn:.2f}, MLE: {id_mle:.2f}")
TwoNN: 2.05, MLE: 1.98