API Reference
Main Interface
compute(data, method='participation_ratio', **kwargs)
Computes effective dimension using the specified method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[ndarray, Any]
|
Input data. |
required |
method
|
str
|
Method name. |
'participation_ratio'
|
**kwargs
|
Arguments passed to the estimator. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Estimated effective dimension. |
Source code in src/effdim/api.py
analyze(data, methods=None, **kwargs)
Computes multiple effective dimension metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[ndarray, Any]
|
Input data. |
required |
methods
|
Optional[List[str]]
|
List of methods to compute. Defaults to generic set. |
None
|
**kwargs
|
Shared kwargs (e.g. threshold=0.95). Note: Specific kwargs for specific methods not easily supported in this simple API. |
{}
|
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dict[str, float]: Dictionary of results. |
Source code in src/effdim/api.py
Metrics (Spectral)
effective_rank(spectrum)
Computes Effective Rank (Roy & Vetterli, 2007). This is effectively the Shannon Effective Dimension of the normalized spectrum. Alias for shannon_effective_dimension.
Source code in src/effdim/metrics.py
geometric_mean_dimension(spectrum)
Computes a dimension based on the ratio of arithmetic mean to geometric mean.
Source code in src/effdim/metrics.py
participation_ratio(spectrum)
Computes the Participation Ratio (PR). PR = (Sum lambda)^2 / Sum (lambda^2)
Ref: Recanatesi et al.
Source code in src/effdim/metrics.py
pca_explained_variance(spectrum, threshold=0.95)
Returns the number of components needed to explain threshold fraction of variance.
Note: For singular values s, variance is proportional to s^2.
Source code in src/effdim/metrics.py
renyi_effective_dimension(spectrum, alpha=2.0)
Computes Rényi Effective Dimension (Generalized). For alpha=1 -> Shannon. For alpha=2 -> Connected to Participation Ratio? R_2 = 1/(1-2) * log(sum p^2) = -log(sum p^2) Exp(R_2) = 1 / sum p^2. PR = (sum lambda)^2 / sum lambda^2 = 1 / sum (lambda/sum lambda)^2 = 1 / sum p^2. So Exp(Renyi_2) is exactly Participation Ratio!
Source code in src/effdim/metrics.py
shannon_effective_dimension(spectrum)
Computes Shannon Effective Dimension: exp(Entropy). H = - sum p_i log p_i where p_i = lambda_i / sum(lambda)
Source code in src/effdim/metrics.py
Geometry (Spatial)
knn_intrinsic_dimension(data, k=5)
Computes Intrinsic Dimension using Levina-Bickel MLE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
(N, D) array of points. |
required |
k
|
int
|
Number of neighbors. |
5
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Estimated dimension. |
Source code in src/effdim/geometry.py
two_nn_intrinsic_dimension(data)
Computes ID using Two-NN method (Facco et al., 2017). Uses ratio of 2nd to 1st neighbor distances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
(N, D) array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Estimated dimension. |
Source code in src/effdim/geometry.py
Adapters
get_singular_values(data)
Standardizes input data into Singular Values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[ndarray, spmatrix]
|
Input data. - (N, D) array: Interpreted as raw data. Returns singular values. - (N, N) symmetric matrix: Interpreted as Covariance. Returns sqrt(abs(eigenvalues)). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: 1D array of singular values, sorted descending. |