scikit-dimension is a Python module for intrinsic dimension estimation built according to the scikit-learn API and distributed under the 3-Clause BSD license.
Please refer to the documentation and the paper for detailed API, examples and references
Using pip:
pip install scikit-dimensionFrom source:
git clone https://github.com/scikit-learn-contrib/scikit-dimension
cd scikit-dimension
pip install .Local and global estimators can be used in this way:
import skdim
import numpy as np
#generate data : np.array (n_points x n_dim). Here a uniformly sampled 5-ball embedded in 10 dimensions
data = np.zeros((1000,10))
data[:,:5] = skdim.datasets.hyperBall(n = 1000, d = 5, radius = 1, random_state = 0)
#estimate global intrinsic dimension
danco = skdim.id.DANCo().fit(data)
#estimate local intrinsic dimension (dimension in k-nearest-neighborhoods around each point):
lpca = skdim.id.lPCA().fit_pw(data,
n_neighbors = 100,
n_jobs = 1)
#get estimated intrinsic dimension
print(danco.dimension_, np.mean(lpca.dimension_pw_)) Please cite Bac et al. (2021), Scikit-Dimension: A Python Package for Intrinsic Dimension Estimation, Entropy 23(10):1368, doi:10.3390/e23101368 (see CITATION.cff), together with the paper of each method you use (listed in its docstring).
Contributors are listed in AUTHORS.md; code adapted from other projects and its licences are listed in LICENSES_bundled.txt.
Related packages: DADApy (Glielmo et al., Patterns 2022), intrinsicDimension, Rdimtools, PCAtools.