├── MANIFEST.in ├── requirements.txt ├── setup.cfg ├── environment.yml ├── skdim ├── id │ ├── DANCoFit │ │ ├── DANCo_spline_dhat.pkl │ │ ├── DANCo_spline_mu.pkl │ │ └── DANCo_spline_tau.pkl │ ├── __init__.py │ ├── _MOM.py │ ├── _MADA.py │ ├── _CorrInt.py │ ├── _MiND_ML.py │ ├── _KNN.py │ ├── _TLE.py │ ├── _DANCoUtils.py │ ├── _TwoNN.py │ └── _PCA.py ├── tests │ ├── __init__.py │ ├── test_all_params.py │ └── test_results.py ├── _version.py └── __init__.py ├── doc ├── _templates │ └── autosummary │ │ ├── base.rst │ │ └── class.rst ├── skdim.id.ESS.fit.rst ├── skdim.id.KNN.fit.rst ├── skdim.id.MLE.fit.rst ├── skdim.id.MOM.fit.rst ├── skdim.id.TLE.fit.rst ├── skdim.id.MADA.fit.rst ├── skdim.id.lPCA.fit.rst ├── requirements.txt ├── skdim.id.DANCo.fit.rst ├── skdim.id.ESS.predict.rst ├── skdim.id.KNN.predict.rst ├── skdim.id.MLE.predict.rst ├── skdim.id.MOM.predict.rst ├── skdim.id.TLE.predict.rst ├── skdim.id.TwoNN.fit.rst ├── skdim.id.KNN.fit_pw.rst ├── skdim.id.MADA.predict.rst ├── skdim.id.lPCA.predict.rst ├── skdim.id.CorrInt.fit.rst ├── skdim.id.DANCo.predict.rst ├── skdim.id.ESS.fit_once.rst ├── skdim.id.FisherS.fit.rst ├── skdim.id.MLE.fit_once.rst ├── skdim.id.MiND_ML.fit.rst ├── skdim.id.TwoNN.predict.rst ├── skdim.id.lPCA.fit_pw.rst ├── skdim.id.DANCo.fit_pw.rst ├── skdim.id.ESS.fit_predict.rst ├── skdim.id.ESS.predict_pw.rst ├── skdim.id.ESS.transform.rst ├── skdim.id.KNN.fit_predict.rst ├── skdim.id.KNN.predict_pw.rst ├── skdim.id.KNN.transform.rst ├── skdim.id.MLE.predict_pw.rst ├── skdim.id.MLE.transform.rst ├── skdim.id.MOM.fit_predict.rst ├── skdim.id.MOM.predict_pw.rst ├── skdim.id.MOM.transform.rst ├── skdim.id.TLE.fit_predict.rst ├── skdim.id.TLE.predict_pw.rst ├── skdim.id.TLE.transform.rst ├── skdim.id.TwoNN.fit_pw.rst ├── skdim.id.lPCA.predict_pw.rst ├── skdim.id.CorrInt.predict.rst ├── skdim.id.ESS.get_params.rst ├── skdim.id.ESS.set_params.rst ├── skdim.id.FisherS.predict.rst ├── skdim.id.KNN.get_params.rst ├── skdim.id.KNN.set_params.rst ├── skdim.id.MADA.fit_predict.rst ├── skdim.id.MADA.predict_pw.rst ├── skdim.id.MADA.transform.rst ├── skdim.id.MLE.get_params.rst ├── skdim.id.MLE.set_params.rst ├── skdim.id.MOM.get_params.rst ├── skdim.id.MOM.set_params.rst ├── skdim.id.MiND_ML.predict.rst ├── skdim.id.TLE.get_params.rst ├── skdim.id.TLE.set_params.rst ├── skdim.id.lPCA.fit_predict.rst ├── skdim.id.lPCA.transform.rst ├── skdim.datasets.hyperBall.rst ├── skdim.id.CorrInt.fit_pw.rst ├── skdim.id.DANCo.fit_predict.rst ├── skdim.id.DANCo.predict_pw.rst ├── skdim.id.DANCo.transform.rst ├── skdim.id.FisherS.fit_pw.rst ├── skdim.id.MADA.get_params.rst ├── skdim.id.MADA.set_params.rst ├── skdim.id.MLE.fit_predict.rst ├── skdim.id.MiND_ML.fit_pw.rst ├── skdim.id.TwoNN.fit_predict.rst ├── skdim.id.TwoNN.predict_pw.rst ├── skdim.id.TwoNN.transform.rst ├── skdim.id.lPCA.get_params.rst ├── skdim.id.lPCA.set_params.rst ├── skdim.datasets.hyperSphere.rst ├── skdim.id.DANCo.get_params.rst ├── skdim.id.DANCo.set_params.rst ├── skdim.id.ESS.fit_predict_pw.rst ├── skdim.id.ESS.fit_transform.rst ├── skdim.id.ESS.transform_pw.rst ├── skdim.id.KNN.fit_predict_pw.rst ├── skdim.id.KNN.fit_transform.rst ├── skdim.id.KNN.transform_pw.rst ├── skdim.id.MLE.fit_predict_pw.rst ├── skdim.id.MLE.fit_transform.rst ├── skdim.id.MLE.transform_pw.rst ├── skdim.id.MOM.fit_predict_pw.rst ├── skdim.id.MOM.fit_transform.rst ├── skdim.id.MOM.transform_pw.rst ├── skdim.id.TLE.fit_predict_pw.rst ├── skdim.id.TLE.fit_transform.rst ├── skdim.id.TLE.transform_pw.rst ├── skdim.id.TwoNN.get_params.rst ├── skdim.id.TwoNN.set_params.rst ├── skdim.id.lPCA.transform_pw.rst ├── skdim.datasets.lineDiskBall.rst ├── skdim.id.CorrInt.fit_predict.rst ├── skdim.id.CorrInt.predict_pw.rst ├── skdim.id.CorrInt.transform.rst ├── skdim.id.FisherS.fit_predict.rst ├── skdim.id.FisherS.predict_pw.rst ├── skdim.id.FisherS.transform.rst ├── skdim.id.MADA.fit_predict_pw.rst ├── skdim.id.MADA.fit_transform.rst ├── skdim.id.MADA.transform_pw.rst ├── skdim.id.MiND_ML.predict_pw.rst ├── skdim.id.MiND_ML.transform.rst ├── skdim.id.lPCA.fit_predict_pw.rst ├── skdim.id.lPCA.fit_transform.rst ├── skdim.datasets.swissRoll3Sph.rst ├── skdim.id.CorrInt.get_params.rst ├── skdim.id.CorrInt.set_params.rst ├── skdim.id.DANCo.fit_predict_pw.rst ├── skdim.id.DANCo.fit_transform.rst ├── skdim.id.DANCo.transform_pw.rst ├── skdim.id.FisherS.get_params.rst ├── skdim.id.FisherS.set_params.rst ├── skdim.id.MiND_ML.fit_predict.rst ├── skdim.id.MiND_ML.get_params.rst ├── skdim.id.MiND_ML.set_params.rst ├── skdim.id.TwoNN.fit_predict_pw.rst ├── skdim.id.TwoNN.fit_transform.rst ├── skdim.id.TwoNN.transform_pw.rst ├── skdim.datasets.hyperTwinPeaks.rst ├── skdim.id.ESS.fit_transform_pw.rst ├── skdim.id.KNN.fit_transform_pw.rst ├── skdim.id.MLE.fit_transform_pw.rst ├── skdim.id.MOM.fit_transform_pw.rst ├── skdim.id.TLE.fit_transform_pw.rst ├── skdim.id.CorrInt.fit_predict_pw.rst ├── skdim.id.CorrInt.fit_transform.rst ├── skdim.id.CorrInt.transform_pw.rst ├── skdim.id.FisherS.fit_predict_pw.rst ├── skdim.id.FisherS.fit_transform.rst ├── skdim.id.FisherS.transform_pw.rst ├── skdim.id.MADA.fit_transform_pw.rst ├── skdim.id.MiND_ML.transform_pw.rst ├── skdim.id.lPCA.fit_transform_pw.rst ├── skdim.id.DANCo.fit_transform_pw.rst ├── skdim.id.MiND_ML.fit_predict_pw.rst ├── skdim.id.MiND_ML.fit_transform.rst ├── skdim.id.TwoNN.fit_transform_pw.rst ├── skdim.id.FisherS.check_symmetric.rst ├── skdim.id.CorrInt.fit_transform_pw.rst ├── skdim.id.FisherS.fit_transform_pw.rst ├── skdim.id.MiND_ML.fit_transform_pw.rst ├── skdim.id.FisherS.getSeparabilityGraph.rst ├── skdim.id.FisherS.plotSeparabilityGraph.rst ├── skdim.id.FisherS.buildSeparabilityGraph.rst ├── release_notes.rst ├── skdim.datasets.BenchmarkManifolds.generate.rst ├── _static │ └── css │ │ ├── project-template.css │ │ └── custom.css ├── skdim.id.FisherS.point_inseparability_to_pointID.rst ├── skdim.datasets.BenchmarkManifolds.rst ├── skdim.id.MOM.rst ├── skdim.id.TLE.rst ├── skdim.id.MADA.rst ├── skdim.id.ESS.rst ├── skdim.id.KNN.rst ├── skdim.id.lPCA.rst ├── skdim.id.DANCo.rst ├── skdim.id.TwoNN.rst ├── skdim.id.MLE.rst ├── skdim.id.CorrInt.rst ├── skdim.id.MiND_ML.rst ├── api.rst ├── skdim.id.FisherS.rst ├── quick_start.rst ├── installation.rst ├── index.rst ├── references.rst ├── contributing.rst ├── Makefile └── make.bat ├── .coveragerc ├── .readthedocs.yml ├── .github └── workflows │ └── python-publish.yml ├── .gitignore ├── appveyor.yml ├── examples └── plot_separabilityGraph.py ├── LICENSE ├── .circleci └── config.yml ├── .travis.yml ├── README.md └── setup.py /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include requirements.txt 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | scipy 3 | scikit-learn 4 | numba 5 | matplotlib 6 | pandas 7 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [aliases] 2 | test = pytest 3 | 4 | [tool:pytest] 5 | addopts = --doctest-modules 6 | -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | name: skdim 2 | dependencies: 3 | - numpy 4 | - scipy 5 | - scikit-learn 6 | - numba 7 | - matplotlib 8 | - pandas 9 | -------------------------------------------------------------------------------- /skdim/id/DANCoFit/DANCo_spline_dhat.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scikit-learn-contrib/scikit-dimension/master/skdim/id/DANCoFit/DANCo_spline_dhat.pkl -------------------------------------------------------------------------------- /skdim/id/DANCoFit/DANCo_spline_mu.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scikit-learn-contrib/scikit-dimension/master/skdim/id/DANCoFit/DANCo_spline_mu.pkl -------------------------------------------------------------------------------- /skdim/id/DANCoFit/DANCo_spline_tau.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scikit-learn-contrib/scikit-dimension/master/skdim/id/DANCoFit/DANCo_spline_tau.pkl -------------------------------------------------------------------------------- /doc/_templates/autosummary/base.rst: -------------------------------------------------------------------------------- 1 | :github_url: {{ fullname | modurl }} 2 | 3 | {{ fullname | api_image }} 4 | 5 | {% extends "!autosummary/base.rst" %} 6 | 7 | .. http://www.sphinx-doc.org/en/stable/ext/autosummary.html#customizing-templates 8 | -------------------------------------------------------------------------------- /doc/skdim.id.ESS.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_ESS.py#L362-L434 2 | 3 | 4 | 5 | skdim.id.ESS.fit 6 | ================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.fit -------------------------------------------------------------------------------- /doc/skdim.id.KNN.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_KNN.py#L65-L91 2 | 3 | 4 | 5 | skdim.id.KNN.fit 6 | ================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.fit -------------------------------------------------------------------------------- /doc/skdim.id.MLE.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MLE.py#L90-L180 2 | 3 | 4 | 5 | skdim.id.MLE.fit 6 | ================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.fit -------------------------------------------------------------------------------- /doc/skdim.id.MOM.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MOM.py#L362-L434 2 | 3 | 4 | 5 | skdim.id.MOM.fit 6 | ================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.fit -------------------------------------------------------------------------------- /doc/skdim.id.TLE.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TLE.py#L362-L434 2 | 3 | 4 | 5 | skdim.id.TLE.fit 6 | ================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.fit -------------------------------------------------------------------------------- /doc/skdim.id.MADA.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MADA.py#L362-L434 2 | 3 | 4 | 5 | skdim.id.MADA.fit 6 | ================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.fit -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_PCA.py#L89-L111 2 | 3 | 4 | 5 | skdim.id.lPCA.fit 6 | ================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.fit -------------------------------------------------------------------------------- /doc/requirements.txt: -------------------------------------------------------------------------------- 1 | setuptools 2 | setuptools_scm 3 | typing_extensions 4 | importlib_metadata 5 | sphinx_rtd_theme==0.5.0rc1 6 | sphinx_autodoc_typehints<=1.6 7 | ipykernel 8 | nbsphinx>=0.7 9 | numpy<=1.20 10 | numpydoc 11 | pandoc 12 | sphinx==1.8.5 13 | -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_DANCo.py#L89-L132 2 | 3 | 4 | 5 | skdim.id.DANCo.fit 6 | ================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.fit -------------------------------------------------------------------------------- /doc/skdim.id.ESS.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_ESS.py#L374-L387 2 | 3 | 4 | 5 | skdim.id.ESS.predict 6 | ==================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.predict -------------------------------------------------------------------------------- /doc/skdim.id.KNN.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_KNN.py#L126-L139 2 | 3 | 4 | 5 | skdim.id.KNN.predict 6 | ==================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.predict -------------------------------------------------------------------------------- /doc/skdim.id.MLE.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MLE.py#L374-L387 2 | 3 | 4 | 5 | skdim.id.MLE.predict 6 | ==================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.predict -------------------------------------------------------------------------------- /doc/skdim.id.MOM.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MOM.py#L374-L387 2 | 3 | 4 | 5 | skdim.id.MOM.predict 6 | ==================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.predict -------------------------------------------------------------------------------- /doc/skdim.id.TLE.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_TLE.py#L374-L387 2 | 3 | 4 | 5 | skdim.id.TLE.predict 6 | ==================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.predict -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L85-L104 2 | 3 | 4 | 5 | skdim.id.TwoNN.fit 6 | ================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.fit -------------------------------------------------------------------------------- /doc/skdim.id.KNN.fit_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_KNN.py#L207-L253 2 | 3 | 4 | 5 | skdim.id.KNN.fit\_pw 6 | ==================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.fit_pw -------------------------------------------------------------------------------- /doc/skdim.id.MADA.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MADA.py#L374-L387 2 | 3 | 4 | 5 | skdim.id.MADA.predict 6 | ===================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.predict -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_PCA.py#L126-L139 2 | 3 | 4 | 5 | skdim.id.lPCA.predict 6 | ===================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.predict -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L57-L83 2 | 3 | 4 | 5 | skdim.id.CorrInt.fit 6 | ==================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.fit -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_DANCo.py#L126-L139 2 | 3 | 4 | 5 | skdim.id.DANCo.predict 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.predict -------------------------------------------------------------------------------- /doc/skdim.id.ESS.fit_once.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_ESS.py#L80-L100 2 | 3 | 4 | 5 | skdim.id.ESS.fit\_once 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.fit_once -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L82-L127 2 | 3 | 4 | 5 | skdim.id.FisherS.fit 6 | ==================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.fit -------------------------------------------------------------------------------- /doc/skdim.id.MLE.fit_once.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MLE.py#L243-L250 2 | 3 | 4 | 5 | skdim.id.MLE.fit\_once 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.fit_once -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.fit.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L56-L79 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.fit 6 | ===================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.fit -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L126-L139 2 | 3 | 4 | 5 | skdim.id.TwoNN.predict 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.predict -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.fit_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_PCA.py#L207-L253 2 | 3 | 4 | 5 | skdim.id.lPCA.fit\_pw 6 | ===================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.fit_pw -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.fit_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_DANCo.py#L207-L253 2 | 3 | 4 | 5 | skdim.id.DANCo.fit\_pw 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.fit_pw -------------------------------------------------------------------------------- /doc/skdim.id.ESS.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_ESS.py#L389-L429 2 | 3 | 4 | 5 | skdim.id.ESS.fit\_predict 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.ESS.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_ESS.py#L431-L458 2 | 3 | 4 | 5 | skdim.id.ESS.predict\_pw 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.ESS.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_ESS.py#L436-L449 2 | 3 | 4 | 5 | skdim.id.ESS.transform 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.transform -------------------------------------------------------------------------------- /doc/skdim.id.KNN.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_KNN.py#L141-L153 2 | 3 | 4 | 5 | skdim.id.KNN.fit\_predict 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.KNN.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_KNN.py#L203-L230 2 | 3 | 4 | 5 | skdim.id.KNN.predict\_pw 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.KNN.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_KNN.py#L177-L190 2 | 3 | 4 | 5 | skdim.id.KNN.transform 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.transform -------------------------------------------------------------------------------- /doc/skdim.id.MLE.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MLE.py#L431-L458 2 | 3 | 4 | 5 | skdim.id.MLE.predict\_pw 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.MLE.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MLE.py#L436-L449 2 | 3 | 4 | 5 | skdim.id.MLE.transform 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.transform -------------------------------------------------------------------------------- /doc/skdim.id.MOM.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MOM.py#L389-L429 2 | 3 | 4 | 5 | skdim.id.MOM.fit\_predict 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.MOM.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MOM.py#L431-L458 2 | 3 | 4 | 5 | skdim.id.MOM.predict\_pw 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.MOM.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MOM.py#L436-L449 2 | 3 | 4 | 5 | skdim.id.MOM.transform 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.transform -------------------------------------------------------------------------------- /doc/skdim.id.TLE.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_TLE.py#L389-L429 2 | 3 | 4 | 5 | skdim.id.TLE.fit\_predict 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.TLE.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_TLE.py#L431-L458 2 | 3 | 4 | 5 | skdim.id.TLE.predict\_pw 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.TLE.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TLE.py#L436-L449 2 | 3 | 4 | 5 | skdim.id.TLE.transform 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.transform -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.fit_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L207-L253 2 | 3 | 4 | 5 | skdim.id.TwoNN.fit\_pw 6 | ====================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.fit_pw -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_PCA.py#L203-L230 2 | 3 | 4 | 5 | skdim.id.lPCA.predict\_pw 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L126-L139 2 | 3 | 4 | 5 | skdim.id.CorrInt.predict 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.predict -------------------------------------------------------------------------------- /doc/skdim.id.ESS.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_ESS.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.ESS.get\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.get_params -------------------------------------------------------------------------------- /doc/skdim.id.ESS.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_ESS.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.ESS.set\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.set_params -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_FisherS.py#L126-L139 2 | 3 | 4 | 5 | skdim.id.FisherS.predict 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.predict -------------------------------------------------------------------------------- /doc/skdim.id.KNN.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_KNN.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.KNN.get\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.get_params -------------------------------------------------------------------------------- /doc/skdim.id.KNN.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_KNN.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.KNN.set\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.set_params -------------------------------------------------------------------------------- /doc/skdim.id.MADA.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MADA.py#L389-L429 2 | 3 | 4 | 5 | skdim.id.MADA.fit\_predict 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.MADA.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MADA.py#L431-L458 2 | 3 | 4 | 5 | skdim.id.MADA.predict\_pw 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.MADA.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MADA.py#L436-L449 2 | 3 | 4 | 5 | skdim.id.MADA.transform 6 | ======================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.transform -------------------------------------------------------------------------------- /doc/skdim.id.MLE.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MLE.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.MLE.get\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.get_params -------------------------------------------------------------------------------- /doc/skdim.id.MLE.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MLE.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.MLE.set\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.set_params -------------------------------------------------------------------------------- /doc/skdim.id.MOM.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MOM.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.MOM.get\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.get_params -------------------------------------------------------------------------------- /doc/skdim.id.MOM.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MOM.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.MOM.set\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.set_params -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L126-L139 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.predict 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.predict -------------------------------------------------------------------------------- /doc/skdim.id.TLE.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TLE.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.TLE.get\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.get_params -------------------------------------------------------------------------------- /doc/skdim.id.TLE.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TLE.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.TLE.set\_params 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.set_params -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_PCA.py#L141-L153 2 | 3 | 4 | 5 | skdim.id.lPCA.fit\_predict 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_PCA.py#L177-L190 2 | 3 | 4 | 5 | skdim.id.lPCA.transform 6 | ======================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.transform -------------------------------------------------------------------------------- /doc/skdim.datasets.hyperBall.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/datasets.py#L38-L69 2 | 3 | 4 | 5 | skdim.datasets.hyperBall 6 | ======================== 7 | 8 | .. currentmodule:: skdim.datasets 9 | 10 | .. autofunction:: hyperBall -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.fit_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L207-L253 2 | 3 | 4 | 5 | skdim.id.CorrInt.fit\_pw 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.fit_pw -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_DANCo.py#L141-L153 2 | 3 | 4 | 5 | skdim.id.DANCo.fit\_predict 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_DANCo.py#L203-L230 2 | 3 | 4 | 5 | skdim.id.DANCo.predict\_pw 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_DANCo.py#L177-L190 2 | 3 | 4 | 5 | skdim.id.DANCo.transform 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.transform -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.fit_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L207-L253 2 | 3 | 4 | 5 | skdim.id.FisherS.fit\_pw 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.fit_pw -------------------------------------------------------------------------------- /doc/skdim.id.MADA.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MADA.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.MADA.get\_params 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.get_params -------------------------------------------------------------------------------- /doc/skdim.id.MADA.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MADA.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.MADA.set\_params 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.set_params -------------------------------------------------------------------------------- /doc/skdim.id.MLE.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MLE.py#L182-L222 2 | 3 | 4 | 5 | skdim.id.MLE.fit\_predict 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.fit_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L207-L253 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.fit\_pw 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.fit_pw -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L141-L153 2 | 3 | 4 | 5 | skdim.id.TwoNN.fit\_predict 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L203-L230 2 | 3 | 4 | 5 | skdim.id.TwoNN.predict\_pw 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L177-L190 2 | 3 | 4 | 5 | skdim.id.TwoNN.transform 6 | ======================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.transform -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_PCA.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.lPCA.get\_params 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.get_params -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_PCA.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.lPCA.set\_params 6 | ========================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.set_params -------------------------------------------------------------------------------- /doc/skdim.datasets.hyperSphere.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/datasets.py#L72-L95 2 | 3 | 4 | 5 | skdim.datasets.hyperSphere 6 | ========================== 7 | 8 | .. currentmodule:: skdim.datasets 9 | 10 | .. autofunction:: hyperSphere -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_DANCo.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.DANCo.get\_params 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.get_params -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_DANCo.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.DANCo.set\_params 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.set_params -------------------------------------------------------------------------------- /doc/skdim.id.ESS.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_ESS.py#L460-L500 2 | 3 | 4 | 5 | skdim.id.ESS.fit\_predict\_pw 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.ESS.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_ESS.py#L451-L492 2 | 3 | 4 | 5 | skdim.id.ESS.fit\_transform 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.ESS.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_ESS.py#L494-L521 2 | 3 | 4 | 5 | skdim.id.ESS.transform\_pw 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.KNN.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_KNN.py#L232-L284 2 | 3 | 4 | 5 | skdim.id.KNN.fit\_predict\_pw 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.KNN.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_KNN.py#L192-L205 2 | 3 | 4 | 5 | skdim.id.KNN.fit\_transform 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.KNN.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_KNN.py#L255-L282 2 | 3 | 4 | 5 | skdim.id.KNN.transform\_pw 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.MLE.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MLE.py#L460-L500 2 | 3 | 4 | 5 | skdim.id.MLE.fit\_predict\_pw 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.MLE.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MLE.py#L451-L492 2 | 3 | 4 | 5 | skdim.id.MLE.fit\_transform 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.MLE.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MLE.py#L494-L521 2 | 3 | 4 | 5 | skdim.id.MLE.transform\_pw 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.MOM.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MOM.py#L460-L500 2 | 3 | 4 | 5 | skdim.id.MOM.fit\_predict\_pw 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.MOM.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MOM.py#L451-L492 2 | 3 | 4 | 5 | skdim.id.MOM.fit\_transform 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.MOM.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MOM.py#L494-L521 2 | 3 | 4 | 5 | skdim.id.MOM.transform\_pw 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.TLE.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_TLE.py#L460-L500 2 | 3 | 4 | 5 | skdim.id.TLE.fit\_predict\_pw 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.TLE.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TLE.py#L451-L492 2 | 3 | 4 | 5 | skdim.id.TLE.fit\_transform 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.TLE.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TLE.py#L494-L521 2 | 3 | 4 | 5 | skdim.id.TLE.transform\_pw 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.TwoNN.get\_params 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.get_params -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.TwoNN.set\_params 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.set_params -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_PCA.py#L255-L282 2 | 3 | 4 | 5 | skdim.id.lPCA.transform\_pw 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.transform_pw -------------------------------------------------------------------------------- /doc/skdim.datasets.lineDiskBall.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/datasets.py#L125-L187 2 | 3 | 4 | 5 | skdim.datasets.lineDiskBall 6 | =========================== 7 | 8 | .. currentmodule:: skdim.datasets 9 | 10 | .. autofunction:: lineDiskBall -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L141-L153 2 | 3 | 4 | 5 | skdim.id.CorrInt.fit\_predict 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L203-L230 2 | 3 | 4 | 5 | skdim.id.CorrInt.predict\_pw 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L177-L190 2 | 3 | 4 | 5 | skdim.id.CorrInt.transform 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.transform -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_FisherS.py#L141-L153 2 | 3 | 4 | 5 | skdim.id.FisherS.fit\_predict 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_FisherS.py#L203-L230 2 | 3 | 4 | 5 | skdim.id.FisherS.predict\_pw 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L177-L190 2 | 3 | 4 | 5 | skdim.id.FisherS.transform 6 | ========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.transform -------------------------------------------------------------------------------- /doc/skdim.id.MADA.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MADA.py#L460-L500 2 | 3 | 4 | 5 | skdim.id.MADA.fit\_predict\_pw 6 | ============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.MADA.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MADA.py#L451-L492 2 | 3 | 4 | 5 | skdim.id.MADA.fit\_transform 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.MADA.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MADA.py#L494-L521 2 | 3 | 4 | 5 | skdim.id.MADA.transform\_pw 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L203-L230 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.predict\_pw 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L177-L190 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.transform 6 | =========================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.transform -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_PCA.py#L232-L284 2 | 3 | 4 | 5 | skdim.id.lPCA.fit\_predict\_pw 6 | ============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_PCA.py#L192-L205 2 | 3 | 4 | 5 | skdim.id.lPCA.fit\_transform 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.fit_transform -------------------------------------------------------------------------------- /doc/skdim.datasets.swissRoll3Sph.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/datasets.py#L190-L245 2 | 3 | 4 | 5 | skdim.datasets.swissRoll3Sph 6 | ============================ 7 | 8 | .. currentmodule:: skdim.datasets 9 | 10 | .. autofunction:: swissRoll3Sph -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.CorrInt.get\_params 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.get_params -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.CorrInt.set\_params 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.set_params -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_DANCo.py#L232-L284 2 | 3 | 4 | 5 | skdim.id.DANCo.fit\_predict\_pw 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_DANCo.py#L192-L205 2 | 3 | 4 | 5 | skdim.id.DANCo.fit\_transform 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_DANCo.py#L255-L282 2 | 3 | 4 | 5 | skdim.id.DANCo.transform\_pw 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.FisherS.get\_params 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.get_params -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.FisherS.set\_params 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.set_params -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.fit_predict.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L141-L153 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.fit\_predict 6 | ============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.fit_predict -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.get_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L178-L200 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.get\_params 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.get_params -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.set_params.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L202-L244 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.set\_params 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.set_params -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L232-L284 2 | 3 | 4 | 5 | skdim.id.TwoNN.fit\_predict\_pw 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L192-L205 2 | 3 | 4 | 5 | skdim.id.TwoNN.fit\_transform 6 | ============================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L255-L282 2 | 3 | 4 | 5 | skdim.id.TwoNN.transform\_pw 6 | ============================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.transform_pw -------------------------------------------------------------------------------- /doc/skdim.datasets.hyperTwinPeaks.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/datasets.py#L98-L122 2 | 3 | 4 | 5 | skdim.datasets.hyperTwinPeaks 6 | ============================= 7 | 8 | .. currentmodule:: skdim.datasets 9 | 10 | .. autofunction:: hyperTwinPeaks -------------------------------------------------------------------------------- /doc/skdim.id.ESS.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_ESS.py#L523-L563 2 | 3 | 4 | 5 | skdim.id.ESS.fit\_transform\_pw 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: ESS.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.KNN.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_KNN.py#L284-L335 2 | 3 | 4 | 5 | skdim.id.KNN.fit\_transform\_pw 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: KNN.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.MLE.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MLE.py#L523-L563 2 | 3 | 4 | 5 | skdim.id.MLE.fit\_transform\_pw 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MLE.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.MOM.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MOM.py#L523-L563 2 | 3 | 4 | 5 | skdim.id.MOM.fit\_transform\_pw 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MOM.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.TLE.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TLE.py#L523-L563 2 | 3 | 4 | 5 | skdim.id.TLE.fit\_transform\_pw 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TLE.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L232-L284 2 | 3 | 4 | 5 | skdim.id.CorrInt.fit\_predict\_pw 6 | ================================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L192-L205 2 | 3 | 4 | 5 | skdim.id.CorrInt.fit\_transform 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L255-L282 2 | 3 | 4 | 5 | skdim.id.CorrInt.transform\_pw 6 | ============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_FisherS.py#L232-L284 2 | 3 | 4 | 5 | skdim.id.FisherS.fit\_predict\_pw 6 | ================================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L192-L205 2 | 3 | 4 | 5 | skdim.id.FisherS.fit\_transform 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L255-L282 2 | 3 | 4 | 5 | skdim.id.FisherS.transform\_pw 6 | ============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.MADA.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MADA.py#L523-L563 2 | 3 | 4 | 5 | skdim.id.MADA.fit\_transform\_pw 6 | ================================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MADA.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L255-L282 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.transform\_pw 6 | =============================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_PCA.py#L284-L335 2 | 3 | 4 | 5 | skdim.id.lPCA.fit\_transform\_pw 6 | ================================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: lPCA.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_DANCo.py#L284-L335 2 | 3 | 4 | 5 | skdim.id.DANCo.fit\_transform\_pw 6 | ================================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: DANCo.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.fit_predict_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/theislab/scvelo/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L232-L284 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.fit\_predict\_pw 6 | ================================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.fit_predict_pw -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.fit_transform.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L192-L205 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.fit\_transform 6 | ================================ 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.fit_transform -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_TwoNN.py#L284-L335 2 | 3 | 4 | 5 | skdim.id.TwoNN.fit\_transform\_pw 6 | ================================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: TwoNN.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.check_symmetric.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L580-L582 2 | 3 | 4 | 5 | skdim.id.FisherS.check\_symmetric 6 | ================================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.check_symmetric -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_CorrInt.py#L284-L335 2 | 3 | 4 | 5 | skdim.id.CorrInt.fit\_transform\_pw 6 | =================================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: CorrInt.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L284-L335 2 | 3 | 4 | 5 | skdim.id.FisherS.fit\_transform\_pw 6 | =================================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.fit_transform_pw.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_MiND_ML.py#L284-L335 2 | 3 | 4 | 5 | skdim.id.MiND\_ML.fit\_transform\_pw 6 | ==================================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: MiND_ML.fit_transform_pw -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.getSeparabilityGraph.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L471-L482 2 | 3 | 4 | 5 | skdim.id.FisherS.getSeparabilityGraph 6 | ===================================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.getSeparabilityGraph -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.plotSeparabilityGraph.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L484-L489 2 | 3 | 4 | 5 | skdim.id.FisherS.plotSeparabilityGraph 6 | ====================================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.plotSeparabilityGraph -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.buildSeparabilityGraph.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L491-L578 2 | 3 | 4 | 5 | skdim.id.FisherS.buildSeparabilityGraph 6 | ======================================= 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.buildSeparabilityGraph -------------------------------------------------------------------------------- /doc/release_notes.rst: -------------------------------------------------------------------------------- 1 | .. role:: small 2 | .. role:: smaller 3 | 4 | Release Notes 5 | ============= 6 | 7 | Version 0.3 :small:`April 2021` 8 | ----------------------------------- 9 | API change: predict methods changed to transform 10 | 11 | Version 0.2 :small:`December 2020` 12 | ----------------------------------- 13 | First release of skdim. -------------------------------------------------------------------------------- /doc/skdim.datasets.BenchmarkManifolds.generate.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/datasets.py#L374-L427 2 | 3 | 4 | 5 | skdim.datasets.BenchmarkManifolds.generate 6 | ========================================== 7 | 8 | .. currentmodule:: skdim.datasets 9 | 10 | .. automethod:: BenchmarkManifolds.generate -------------------------------------------------------------------------------- /doc/_static/css/project-template.css: -------------------------------------------------------------------------------- 1 | @import url("theme.css"); 2 | 3 | .highlight a { 4 | text-decoration: underline; 5 | } 6 | 7 | .deprecated p { 8 | padding: 10px 7px 10px 10px; 9 | color: #b94a48; 10 | background-color: #F3E5E5; 11 | border: 1px solid #eed3d7; 12 | } 13 | 14 | .deprecated p span.versionmodified { 15 | font-weight: bold; 16 | } 17 | -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.point_inseparability_to_pointID.rst: -------------------------------------------------------------------------------- 1 | :github_url: https://github.com/j-bac/scikit-dimension/tree/master/scikit-dimension/skdim/id/_FisherS.py#L397-L469 2 | 3 | 4 | 5 | skdim.id.FisherS.point\_inseparability\_to\_pointID 6 | =================================================== 7 | 8 | .. currentmodule:: skdim.id 9 | 10 | .. automethod:: FisherS.point_inseparability_to_pointID -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | # Configuration for coverage.py 2 | 3 | [run] 4 | branch = True 5 | source = skdim 6 | include = */skdim/* 7 | omit = 8 | */setup.py 9 | 10 | [report] 11 | exclude_lines = 12 | pragma: no cover 13 | def __repr__ 14 | if self.debug: 15 | if settings.DEBUG 16 | raise AssertionError 17 | raise NotImplementedError 18 | if 0: 19 | if __name__ == .__main__.: 20 | if self.verbose: 21 | show_missing = True -------------------------------------------------------------------------------- /doc/skdim.datasets.BenchmarkManifolds.rst: -------------------------------------------------------------------------------- 1 | skdim.datasets.BenchmarkManifolds 2 | ================================= 3 | 4 | .. currentmodule:: skdim.datasets 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: BenchmarkManifolds 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.datasets.BenchmarkManifolds.generate 22 | 23 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | # Set the version of Python and other tools you might need 4 | build: 5 | os: ubuntu-22.04 6 | tools: 7 | python: "3.7" 8 | 9 | # Build documentation in the docs/ directory with Sphinx 10 | sphinx: 11 | configuration: doc/conf.py 12 | 13 | python: 14 | install: 15 | - requirements: doc/requirements.txt 16 | - requirements: requirements.txt 17 | - method: pip 18 | path: . 19 | extra_requirements: 20 | - doc 21 | -------------------------------------------------------------------------------- /doc/skdim.id.MOM.rst: -------------------------------------------------------------------------------- 1 | skdim.id.MOM 2 | ============ 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: MOM 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.MOM.fit 22 | ~skdim.id.MOM.fit_transform 23 | ~skdim.id.MOM.fit_transform_pw 24 | ~skdim.id.MOM.get_params 25 | ~skdim.id.MOM.set_params 26 | ~skdim.id.MOM.transform 27 | ~skdim.id.MOM.transform_pw 28 | 29 | -------------------------------------------------------------------------------- /doc/skdim.id.TLE.rst: -------------------------------------------------------------------------------- 1 | skdim.id.TLE 2 | ============ 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: TLE 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.TLE.fit 22 | ~skdim.id.TLE.fit_transform 23 | ~skdim.id.TLE.fit_transform_pw 24 | ~skdim.id.TLE.get_params 25 | ~skdim.id.TLE.set_params 26 | ~skdim.id.TLE.transform 27 | ~skdim.id.TLE.transform_pw 28 | 29 | -------------------------------------------------------------------------------- /doc/skdim.id.MADA.rst: -------------------------------------------------------------------------------- 1 | skdim.id.MADA 2 | ============= 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: MADA 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.MADA.fit 22 | ~skdim.id.MADA.fit_transform 23 | ~skdim.id.MADA.fit_transform_pw 24 | ~skdim.id.MADA.get_params 25 | ~skdim.id.MADA.set_params 26 | ~skdim.id.MADA.transform 27 | ~skdim.id.MADA.transform_pw 28 | 29 | -------------------------------------------------------------------------------- /doc/skdim.id.ESS.rst: -------------------------------------------------------------------------------- 1 | skdim.id.ESS 2 | ============ 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: ESS 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.ESS.fit 22 | ~skdim.id.ESS.fit_once 23 | ~skdim.id.ESS.fit_transform 24 | ~skdim.id.ESS.fit_transform_pw 25 | ~skdim.id.ESS.get_params 26 | ~skdim.id.ESS.set_params 27 | ~skdim.id.ESS.transform 28 | ~skdim.id.ESS.transform_pw 29 | 30 | -------------------------------------------------------------------------------- /doc/skdim.id.KNN.rst: -------------------------------------------------------------------------------- 1 | skdim.id.KNN 2 | ============ 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: KNN 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.KNN.fit 22 | ~skdim.id.KNN.fit_pw 23 | ~skdim.id.KNN.fit_transform 24 | ~skdim.id.KNN.fit_transform_pw 25 | ~skdim.id.KNN.get_params 26 | ~skdim.id.KNN.set_params 27 | ~skdim.id.KNN.transform 28 | ~skdim.id.KNN.transform_pw 29 | 30 | -------------------------------------------------------------------------------- /doc/skdim.id.lPCA.rst: -------------------------------------------------------------------------------- 1 | skdim.id.lPCA 2 | ============= 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: lPCA 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.lPCA.fit 22 | ~skdim.id.lPCA.fit_pw 23 | ~skdim.id.lPCA.fit_transform 24 | ~skdim.id.lPCA.fit_transform_pw 25 | ~skdim.id.lPCA.get_params 26 | ~skdim.id.lPCA.set_params 27 | ~skdim.id.lPCA.transform 28 | ~skdim.id.lPCA.transform_pw 29 | 30 | -------------------------------------------------------------------------------- /doc/skdim.id.DANCo.rst: -------------------------------------------------------------------------------- 1 | skdim.id.DANCo 2 | ============== 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: DANCo 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.DANCo.fit 22 | ~skdim.id.DANCo.fit_pw 23 | ~skdim.id.DANCo.fit_transform 24 | ~skdim.id.DANCo.fit_transform_pw 25 | ~skdim.id.DANCo.get_params 26 | ~skdim.id.DANCo.set_params 27 | ~skdim.id.DANCo.transform 28 | ~skdim.id.DANCo.transform_pw 29 | 30 | -------------------------------------------------------------------------------- /doc/skdim.id.TwoNN.rst: -------------------------------------------------------------------------------- 1 | skdim.id.TwoNN 2 | ============== 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: TwoNN 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.TwoNN.fit 22 | ~skdim.id.TwoNN.fit_pw 23 | ~skdim.id.TwoNN.fit_transform 24 | ~skdim.id.TwoNN.fit_transform_pw 25 | ~skdim.id.TwoNN.get_params 26 | ~skdim.id.TwoNN.set_params 27 | ~skdim.id.TwoNN.transform 28 | ~skdim.id.TwoNN.transform_pw 29 | 30 | -------------------------------------------------------------------------------- /doc/skdim.id.MLE.rst: -------------------------------------------------------------------------------- 1 | skdim.id.MLE 2 | ============ 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: MLE 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.MLE.fit 22 | ~skdim.id.MLE.fit_once 23 | ~skdim.id.MLE.fit_predict 24 | ~skdim.id.MLE.fit_transform 25 | ~skdim.id.MLE.fit_transform_pw 26 | ~skdim.id.MLE.get_params 27 | ~skdim.id.MLE.set_params 28 | ~skdim.id.MLE.transform 29 | ~skdim.id.MLE.transform_pw 30 | 31 | -------------------------------------------------------------------------------- /doc/skdim.id.CorrInt.rst: -------------------------------------------------------------------------------- 1 | skdim.id.CorrInt 2 | ================ 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: CorrInt 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.CorrInt.fit 22 | ~skdim.id.CorrInt.fit_pw 23 | ~skdim.id.CorrInt.fit_transform 24 | ~skdim.id.CorrInt.fit_transform_pw 25 | ~skdim.id.CorrInt.get_params 26 | ~skdim.id.CorrInt.set_params 27 | ~skdim.id.CorrInt.transform 28 | ~skdim.id.CorrInt.transform_pw 29 | 30 | -------------------------------------------------------------------------------- /doc/skdim.id.MiND_ML.rst: -------------------------------------------------------------------------------- 1 | skdim.id.MiND\_ML 2 | ================= 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: MiND_ML 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.MiND_ML.fit 22 | ~skdim.id.MiND_ML.fit_pw 23 | ~skdim.id.MiND_ML.fit_transform 24 | ~skdim.id.MiND_ML.fit_transform_pw 25 | ~skdim.id.MiND_ML.get_params 26 | ~skdim.id.MiND_ML.set_params 27 | ~skdim.id.MiND_ML.transform 28 | ~skdim.id.MiND_ML.transform_pw 29 | 30 | -------------------------------------------------------------------------------- /doc/api.rst: -------------------------------------------------------------------------------- 1 | .. automodule:: skdim 2 | 3 | API 4 | === 5 | 6 | Import skdim as:: 7 | 8 | import skdim 9 | 10 | ID estimators 11 | ------------- 12 | 13 | .. autosummary:: 14 | :toctree: . 15 | 16 | id.CorrInt 17 | id.DANCo 18 | id.ESS 19 | id.FisherS 20 | id.KNN 21 | id.lPCA 22 | id.MADA 23 | id.MiND_ML 24 | id.MLE 25 | id.MOM 26 | id.TLE 27 | id.TwoNN 28 | 29 | 30 | Datasets 31 | -------- 32 | 33 | .. autosummary:: 34 | :toctree: . 35 | 36 | datasets.hyperSphere 37 | datasets.hyperBall 38 | datasets.hyperTwinPeaks 39 | datasets.lineDiskBall 40 | datasets.swissRoll3Sph 41 | datasets.BenchmarkManifolds -------------------------------------------------------------------------------- /doc/_templates/autosummary/class.rst: -------------------------------------------------------------------------------- 1 | {{ fullname | escape | underline}} 2 | 3 | .. currentmodule:: {{ module }} 4 | 5 | .. add toctree option to make autodoc generate the pages 6 | 7 | .. autoclass:: {{ objname }} 8 | 9 | {% block attributes %} 10 | {% if attributes %} 11 | .. rubric:: Attributes 12 | 13 | .. autosummary:: 14 | :toctree: . 15 | {% for item in attributes %} 16 | ~{{ fullname }}.{{ item }} 17 | {%- endfor %} 18 | {% endif %} 19 | {% endblock %} 20 | 21 | {% block methods %} 22 | {% if methods %} 23 | .. rubric:: Methods 24 | 25 | .. autosummary:: 26 | :toctree: . 27 | {% for item in methods %} 28 | {%- if item != '__init__' %} 29 | ~{{ fullname }}.{{ item }} 30 | {%- endif -%} 31 | {%- endfor %} 32 | {% endif %} 33 | {% endblock %} -------------------------------------------------------------------------------- /doc/skdim.id.FisherS.rst: -------------------------------------------------------------------------------- 1 | skdim.id.FisherS 2 | ================ 3 | 4 | .. currentmodule:: skdim.id 5 | 6 | .. add toctree option to make autodoc generate the pages 7 | 8 | .. autoclass:: FisherS 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | .. rubric:: Methods 17 | 18 | .. autosummary:: 19 | :toctree: . 20 | 21 | ~skdim.id.FisherS.buildSeparabilityGraph 22 | ~skdim.id.FisherS.check_symmetric 23 | ~skdim.id.FisherS.fit 24 | ~skdim.id.FisherS.fit_pw 25 | ~skdim.id.FisherS.fit_transform 26 | ~skdim.id.FisherS.fit_transform_pw 27 | ~skdim.id.FisherS.getSeparabilityGraph 28 | ~skdim.id.FisherS.get_params 29 | ~skdim.id.FisherS.plotSeparabilityGraph 30 | ~skdim.id.FisherS.point_inseparability_to_pointID 31 | ~skdim.id.FisherS.set_params 32 | ~skdim.id.FisherS.transform 33 | ~skdim.id.FisherS.transform_pw 34 | 35 | -------------------------------------------------------------------------------- /doc/quick_start.rst: -------------------------------------------------------------------------------- 1 | Quick Start 2 | =========== 3 | 4 | Local and global estimators can be used in this way: 5 | 6 | .. code-block:: python 7 | 8 | import skdim 9 | import numpy as np 10 | 11 | #generate data : np.array (n_points x n_dim). Here a uniformly sampled 5-ball embedded in 10 dimensions 12 | data = np.zeros((1000,10)) 13 | data[:,:5] = skdim.datasets.hyperBall(n = 1000, d = 5, radius = 1, random_state = 0) 14 | 15 | #estimate global intrinsic dimension 16 | danco = skdim.id.DANCo().fit(data) 17 | #estimate local intrinsic dimension (dimension in k-nearest-neighborhoods around each point): 18 | lpca = skdim.id.lPCA().fit_pw(data, 19 | n_neighbors = 100, 20 | n_jobs = 1) 21 | 22 | #get estimated intrinsic dimension 23 | print(danco.dimension_, np.mean(lpca.dimension_pw_)) 24 | -------------------------------------------------------------------------------- /.github/workflows/python-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflows will upload a Python Package using Twine when a release is created 2 | # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries 3 | 4 | name: Upload Python Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | deploy: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | with: 18 | fetch-depth: 0 19 | ref: main 20 | - name: Set up Python 21 | uses: actions/setup-python@v2 22 | with: 23 | python-version: '3.x' 24 | - name: Install dependencies 25 | run: | 26 | python -m pip install --upgrade pip 27 | pip install setuptools wheel twine 28 | - name: Build and publish 29 | env: 30 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 31 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 32 | run: | 33 | python setup.py sdist bdist_wheel 34 | twine upload --skip-existing dist/* 35 | -------------------------------------------------------------------------------- /doc/installation.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ============ 3 | 4 | scikit-dimension requires Python 3.6 or later. 5 | 6 | PyPI 7 | ^^^^ 8 | 9 | Install scikit-dimension from PyPI_ using:: 10 | 11 | pip install scikit-dimension 12 | 13 | Development Version 14 | ^^^^^^^^^^^^^^^^^^^ 15 | 16 | To work with the latest development version, install from GitHub_ using:: 17 | 18 | pip install git+https://github.com/j-bac/scikit-dimension 19 | 20 | or:: 21 | 22 | git clone https://github.com/j-bac/scikit-dimension 23 | pip install -e scikit-dimension 24 | 25 | Dependencies 26 | ^^^^^^^^^^^^ 27 | - `numba `_ 28 | - `numpy `_ 29 | - `scipy `_ 30 | - `scikit-learn `_ 31 | - `matplotlib `_ 32 | - `pandas `_ 33 | 34 | If you run into issues, do not hesitate to approach us or raise a `GitHub issue`_. 35 | 36 | .. _PyPI: https://pypi.org/project/scikit-dimension 37 | .. _Github: https://github.com/j-bac/scikit-dimension 38 | .. _`Github issue`: https://github.com/j-bac/scikit-dimension/issues/new/choose -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.vscode 2 | *.idea 3 | *.ini 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | *$py.class 8 | 9 | # C extensions 10 | *.so 11 | 12 | # scikit-learn specific 13 | doc/_build/ 14 | doc/auto_examples/ 15 | doc/modules/generated/ 16 | doc/datasets/generated/ 17 | 18 | # Distribution / packaging 19 | 20 | .Python 21 | env/ 22 | build/ 23 | develop-eggs/ 24 | dist/ 25 | downloads/ 26 | eggs/ 27 | .eggs/ 28 | lib/ 29 | lib64/ 30 | parts/ 31 | sdist/ 32 | var/ 33 | *.egg-info/ 34 | .installed.cfg 35 | *.egg 36 | *.ipynb_checkpoints/ 37 | 38 | # PyInstaller 39 | # Usually these files are written by a python script from a template 40 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 41 | *.manifest 42 | *.spec 43 | 44 | # Installer logs 45 | pip-log.txt 46 | pip-delete-this-directory.txt 47 | 48 | # Unit test / coverage reports 49 | htmlcov/ 50 | .tox/ 51 | .coverage 52 | .coverage.* 53 | .cache 54 | nosetests.xml 55 | coverage.xml 56 | *,cover 57 | .hypothesis/ 58 | 59 | # Translations 60 | *.mo 61 | *.pot 62 | 63 | # Django stuff: 64 | *.log 65 | 66 | # Sphinx documentation 67 | doc/_build/ 68 | doc/generated/ 69 | 70 | # PyBuilder 71 | target/ 72 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | build: false 2 | 3 | environment: 4 | matrix: 5 | - PYTHON: "C:\\Miniconda3-x64" 6 | PYTHON_VERSION: "3.6.x" 7 | PYTHON_ARCH: "64" 8 | NUMPY_VERSION: "*" 9 | SCIPY_VERSION: "*" 10 | SKLEARN_VERSION: "*" 11 | 12 | - PYTHON: "C:\\Miniconda3-x64" 13 | PYTHON_VERSION: "3.7.x" 14 | PYTHON_ARCH: "64" 15 | NUMPY_VERSION: "*" 16 | SCIPY_VERSION: "*" 17 | SKLEARN_VERSION: "*" 18 | 19 | - PYTHON: "C:\\Miniconda3-x64" 20 | PYTHON_VERSION: "3.8.x" 21 | PYTHON_ARCH: "64" 22 | NUMPY_VERSION: "*" 23 | SCIPY_VERSION: "*" 24 | SKLEARN_VERSION: "*" 25 | 26 | install: 27 | # Prepend miniconda installed Python to the PATH of this build 28 | # Add Library/bin directory to fix issue 29 | # https://github.com/conda/conda/issues/1753 30 | - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PYTHON%\\Library\\bin;%PATH%" 31 | # install the dependencies 32 | - "conda install --yes pip numpy==%NUMPY_VERSION% scipy==%SCIPY_VERSION% scikit-learn==%SKLEARN_VERSION% numba matplotlib pandas nose pytest pytest-cov" 33 | - pip install codecov 34 | - pip install . 35 | 36 | test_script: 37 | - mkdir for_test 38 | - cd for_test 39 | - pytest -v --cov=skdim --ignore=skdim/tests/test_results.py --pyargs skdim 40 | 41 | after_test: 42 | - cp .coverage %APPVEYOR_BUILD_FOLDER% 43 | - cd %APPVEYOR_BUILD_FOLDER% 44 | - codecov 45 | -------------------------------------------------------------------------------- /examples/plot_separabilityGraph.py: -------------------------------------------------------------------------------- 1 | """ 2 | =========================== 3 | FisherS separability graph example 4 | =========================== 5 | """ 6 | 7 | import skdim 8 | import numpy as np 9 | import matplotlib.pyplot as plt 10 | from sklearn.decomposition import PCA 11 | from scipy.stats.mstats import winsorize 12 | 13 | ball1 = skdim.datasets.hyperBall(n=1000, d=3, radius=0.5, center=[0, 0, 0]).T 14 | ball2 = skdim.datasets.hyperBall(n=1000, d=6, radius=0.5, center=[1, 0, 0, 0, 0, 0]).T 15 | 16 | _2balls = np.zeros((6, 2000)) 17 | _2balls[:3, :1000] = ball1 18 | _2balls[:, 1000:2000] = ball2 19 | X = _2balls.T 20 | 21 | u = PCA().fit_transform(X) 22 | fishers = skdim.id.FisherS(conditional_number=10000).fit(X) 23 | ns = fishers.point_inseparability_to_pointID()[0] 24 | edges, weights = fishers.getSeparabilityGraph() 25 | 26 | nsw = winsorize(ns, limits=(0.01, 0.01), inclusive=(True, True)) 27 | plt.figure(figsize=(10, 5)) 28 | plt.scatter(u[:, 0], u[:, 1], c=nsw) 29 | fishers.plotSeparabilityGraph(u[:, 0], u[:, 1], edges, alpha=0.2) 30 | plt.colorbar() 31 | plt.axis("equal") 32 | plt.title("PCA on original data") 33 | plt.xlabel("PC1") 34 | plt.ylabel("PC2") 35 | plt.show() 36 | 37 | for i in range(3): 38 | up = fishers.Xp_[:, i : i + 2] 39 | plt.figure(figsize=(10, 5)) 40 | plt.scatter(up[:, 0], up[:, 1], c=nsw) 41 | fishers.plotSeparabilityGraph(up[:, 0], up[:, 1], edges, alpha=0.2) 42 | plt.colorbar() 43 | plt.axis("equal") 44 | plt.title("Pre-processed data") 45 | plt.xlabel("Axis " + str(i + 1)) 46 | plt.ylabel("Axis " + str(i + 2)) 47 | plt.show() 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Jonathan Bac 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | #wget https://github.com/jgm/pandoc/releases/download/2.11.2/pandoc-2.11.2-linux-amd64.tar.gz 3 | #tar xvzf pandoc-2.11.2-linux-amd64.tar.gz 4 | #export PATH=$HOME/pandoc-2.11.2/bin:$PATH 5 | jobs: 6 | python3: 7 | docker: 8 | - image: circleci/python:3.6.4 9 | steps: 10 | - checkout 11 | - run: 12 | command: | 13 | wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh 14 | chmod +x miniconda.sh && ./miniconda.sh -b -p ~/miniconda 15 | export PATH="~/miniconda/bin:$PATH" 16 | conda update --yes --quiet conda 17 | conda create -n testenv --yes --quiet python=3.6.4 18 | source activate testenv 19 | conda install --yes pip 20 | conda install -c conda-forge pandoc --yes 21 | pip install -r doc/requirements.txt --ignore-installed certifi 22 | pip install -r requirements.txt --ignore-installed certifi 23 | pip install . --ignore-installed certifi 24 | cd doc 25 | make html 26 | - store_artifacts: 27 | path: doc/_build/html 28 | destination: doc 29 | - store_artifacts: 30 | path: ~/log.txt 31 | - persist_to_workspace: 32 | root: doc/_build/html 33 | paths: . 34 | - attach_workspace: 35 | at: doc/_build/html 36 | - run: ls -ltrh doc/_build/html 37 | filters: 38 | branches: 39 | ignore: gh-pages 40 | 41 | workflows: 42 | version: 2 43 | build-doc-and-deploy: 44 | jobs: 45 | - python3 46 | -------------------------------------------------------------------------------- /skdim/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | -------------------------------------------------------------------------------- /skdim/_version.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | __version__ = "0.3.4" 33 | -------------------------------------------------------------------------------- /skdim/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | from . import datasets 33 | from . import id 34 | from ._commonfuncs import get_nn, asPointwise 35 | from ._version import __version__ 36 | -------------------------------------------------------------------------------- /skdim/id/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | from ._CorrInt import CorrInt 33 | from ._DANCo import DANCo 34 | from ._KNN import KNN 35 | from ._MiND_ML import MiND_ML 36 | from ._TwoNN import TwoNN 37 | from ._MLE import MLE 38 | 39 | from ._ESS import ESS 40 | from ._FisherS import FisherS 41 | from ._PCA import lPCA 42 | from ._TLE import TLE 43 | from ._MADA import MADA 44 | from ._MOM import MOM 45 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | sudo: false 3 | 4 | jobs: 5 | include: 6 | - name: Python 3.7 on Ubuntu Linux 18.04 7 | os: linux 8 | dist: bionic 9 | language: python 10 | python: '3.7' 11 | - name: Python 3.8 on Ubuntu Linux 18.04 12 | os: linux 13 | dist: bionic 14 | language: python 15 | python: '3.8' 16 | # See https://blog.travis-ci.com/2019-08-07-extensive-python-testing-on-travis-ci 17 | # for macos config peculiarities. 18 | - name: Python 3.7 on MacOS X (xcode 10.3) 19 | os: osx 20 | language: shell 21 | osx_image: xcode10.3 # Python 3.7 22 | - name: Python 3.7 on MacOS X (xcode 11.3) 23 | os: osx 24 | language: shell 25 | osx_image: xcode11.3 # Python 3.7.5 26 | 27 | 28 | cache: 29 | directories: 30 | - $HOME/.cache/pip 31 | 32 | install: 33 | # install miniconda 34 | #- deactivate 35 | - | 36 | if [[ "$TRAVIS_OS_NAME" == 'linux' ]] && [[ "$TRAVIS_PYTHON_VERSION" == 2* ]]; then 37 | echo "WARNING: using Python2" 38 | wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; 39 | elif [[ "$TRAVIS_OS_NAME" == 'linux' ]]; then 40 | wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; 41 | elif [[ "$TRAVIS_OS_NAME" == 'osx' ]]; then 42 | wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh; 43 | fi 44 | - MINICONDA_PATH=$HOME/miniconda 45 | - chmod +x miniconda.sh && ./miniconda.sh -b -p $MINICONDA_PATH 46 | - export PATH=$MINICONDA_PATH/bin:$PATH 47 | - conda update -y conda 48 | # create the testing environment 49 | - conda create -n testenv python=$TRAVIS_PYTHON_VERSION pip --yes 50 | - conda activate testenv 51 | - conda install -y numpy scipy scikit-learn nose numba matplotlib pytest pytest-cov 52 | - pip install codecov 53 | - pip install . 54 | 55 | script: 56 | - pytest -v --cov=skdim --ignore=skdim/tests/test_results.py --pyargs skdim 57 | 58 | after_success: 59 | - codecov 60 | -------------------------------------------------------------------------------- /skdim/id/_MOM.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | import numpy as np 33 | from .._commonfuncs import LocalEstimator 34 | 35 | 36 | class MOM(LocalEstimator): 37 | """Intrinsic dimension estimation using the Method Of Moments algorithm. [Amsaleg2018]_ [IDRadovanović]_ 38 | 39 | Parameters 40 | ---------- 41 | None 42 | """ 43 | 44 | def _fit(self, **kwargs): 45 | self.dimension_pw_ = self._mom(kwargs["dists"]) 46 | 47 | def _mom(self, dists): 48 | # dists - nearest-neighbor distances (k x 1, or k x n), sorted 49 | w = dists[:, -1] 50 | m1 = np.sum(dists, axis=1) / dists.shape[1] 51 | ID = -m1 / (m1 - w) 52 | return ID 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build status](https://ci.appveyor.com/api/projects/status/tvumlfad69g6ap3u/branch/master?svg=true)](https://ci.appveyor.com/project/j-bac/scikit-dimension/branch/master) 2 | [![CircleCI](https://circleci.com/gh/scikit-learn-contrib/scikit-dimension/tree/master.svg?style=shield)](https://app.circleci.com/pipelines/github/scikit-learn-contrib/scikit-dimension) 3 | [![Documentation Status](https://readthedocs.org/projects/scikit-dimension/badge/?version=latest)](https://scikit-dimension.readthedocs.io/en/latest/?badge=latest) 4 | [![codecov](https://codecov.io/gh/j-bac/scikit-dimension/branch/master/graph/badge.svg)](https://codecov.io/gh/j-bac/scikit-dimension) 5 | [![GitHub license](https://img.shields.io/github/license/j-bac/scikit-dimension)](https://github.com/j-bac/scikit-dimension/blob/master/LICENSE) 6 | [![Downloads](https://pepy.tech/badge/scikit-dimension)](https://pepy.tech/project/scikit-dimension) 7 | 8 | # scikit-dimension 9 | 10 | scikit-dimension is a Python module for intrinsic dimension estimation built according to the [scikit-learn](https://github.com/scikit-learn/scikit-learn) API and distributed under the 3-Clause BSD license. 11 | 12 | Please refer to the [documentation](https://scikit-dimension.readthedocs.io) and the [paper](https://www.mdpi.com/1099-4300/23/10/1368) for detailed API, examples and references 13 | 14 | ### Installation 15 | 16 | Using pip: 17 | ```bash 18 | pip install scikit-dimension 19 | ``` 20 | 21 | From source: 22 | ```bash 23 | git clone https://github.com/j-bac/scikit-dimension 24 | cd scikit-dimension 25 | pip install . 26 | ``` 27 | 28 | ### Quick start 29 | 30 | Local and global estimators can be used in this way: 31 | 32 | ```python 33 | import skdim 34 | import numpy as np 35 | 36 | #generate data : np.array (n_points x n_dim). Here a uniformly sampled 5-ball embedded in 10 dimensions 37 | data = np.zeros((1000,10)) 38 | data[:,:5] = skdim.datasets.hyperBall(n = 1000, d = 5, radius = 1, random_state = 0) 39 | 40 | #estimate global intrinsic dimension 41 | danco = skdim.id.DANCo().fit(data) 42 | #estimate local intrinsic dimension (dimension in k-nearest-neighborhoods around each point): 43 | lpca = skdim.id.lPCA().fit_pw(data, 44 | n_neighbors = 100, 45 | n_jobs = 1) 46 | 47 | #get estimated intrinsic dimension 48 | print(danco.dimension_, np.mean(lpca.dimension_pw_)) 49 | ``` 50 | -------------------------------------------------------------------------------- /skdim/id/_MADA.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | import numpy as np 33 | from scipy.spatial.distance import pdist, squareform 34 | from .._commonfuncs import LocalEstimator 35 | 36 | 37 | class MADA(LocalEstimator): 38 | """Intrinsic dimension estimation using the Manifold-Adaptive Dimension Estimation algorithm. [Farahmand2007]_, [IDHino]_ 39 | 40 | MADA uses a variant of fractal dimension called the local information dimension. 41 | MADA considers the first order expansion of the probability mass around the inspection point, 42 | and it estimates the local information dimension by using two different radii from the inspection point. 43 | 44 | Parameters 45 | ---------- 46 | DM: bool 47 | Whether input is a precomputed distance matrix 48 | """ 49 | 50 | _N_NEIGHBORS = 20 51 | 52 | def __init__(self, DM=False): 53 | self.DM = DM 54 | 55 | def _fit(self, **kwargs): 56 | self.dimension_pw_ = self._mada(kwargs["X"]) 57 | 58 | def _mada(self, X): 59 | 60 | if self.DM is False: 61 | distmat = squareform(pdist(X)) 62 | else: 63 | distmat = X 64 | 65 | distmat[distmat == 0] = np.max(distmat) 66 | 67 | sortedD = np.sort(distmat, axis=0, kind="mergesort") 68 | RK = sortedD[self.n_neighbors - 1, :] 69 | RK2 = sortedD[int(np.floor(self.n_neighbors / 2) - 1), :] 70 | ests = np.log(2) / np.log(RK / RK2) 71 | 72 | return ests 73 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2020, Jonathan Bac 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # 1. Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # 3. Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | """A package implementing algorithms to estimate local and global intrinsic dimension.""" 34 | 35 | import codecs 36 | import os 37 | 38 | from setuptools import find_packages, setup 39 | 40 | # get __version__ from _version.py 41 | ver_file = os.path.join("skdim", "_version.py") 42 | with open(ver_file) as f: 43 | exec(f.read()) 44 | 45 | DISTNAME = "scikit-dimension" 46 | DESCRIPTION = "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.." 47 | MAINTAINER = "Jonathan Bac" 48 | URL = "https://github.com/j-bac/scikit-dimension" 49 | LICENSE = "BSD-3-clause" 50 | DOWNLOAD_URL = "https://github.com/j-bac/scikit-dimension" 51 | VERSION = __version__ 52 | INSTALL_REQUIRES = ["numpy", "numba", "scipy", "scikit-learn", "matplotlib"] 53 | CLASSIFIERS = [ 54 | "Intended Audience :: Science/Research", 55 | "License :: OSI Approved", 56 | "Programming Language :: Python", 57 | "Topic :: Scientific/Engineering", 58 | "Operating System :: Microsoft :: Windows", 59 | "Operating System :: Unix", 60 | "Operating System :: MacOS", 61 | "Programming Language :: Python :: 3.6", 62 | "Programming Language :: Python :: 3.7", 63 | "Programming Language :: Python :: 3.8", 64 | ] 65 | EXTRAS_REQUIRE = { 66 | "tests": ["pytest", "pytest-cov"], 67 | "docs": ["sphinx", "sphinx-gallery", "sphinx_rtd_theme", "numpydoc", "matplotlib",], 68 | } 69 | 70 | setup( 71 | name=DISTNAME, 72 | maintainer=MAINTAINER, 73 | description=DESCRIPTION, 74 | license=LICENSE, 75 | url=URL, 76 | version=VERSION, 77 | download_url=DOWNLOAD_URL, 78 | zip_safe=False, # the package can run out of an .egg file 79 | classifiers=CLASSIFIERS, 80 | packages=find_packages(), 81 | install_requires=INSTALL_REQUIRES, 82 | extras_require=EXTRAS_REQUIRE, 83 | ) 84 | -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | |Travis|_ |Appveyor|_ |Codecov|_ |CircleCI|_ |Documentation|_ |LanguageGrade|_ |License|_ 2 | 3 | .. |Travis| image:: https://travis-ci.com/j-bac/scikit-dimension.svg?branch=master 4 | .. _Travis: https://travis-ci.com/j-bac/scikit-dimension 5 | .. |Appveyor| image:: https://ci.appveyor.com/api/projects/status/tvumlfad69g6ap3u/branch/master?svg=true 6 | .. _Appveyor: https://ci.appveyor.com/project/j-bac/scikit-dimension/branch/master 7 | .. |Codecov| image:: https://codecov.io/gh/j-bac/scikit-dimension/badge.svg?branch=master&service=github 8 | .. _Codecov: https://codecov.io/gh/j-bac/scikit-dimension/ 9 | .. |CircleCI| image:: https://circleci.com/gh/j-bac/scikit-dimension/tree/master.svg?style=shield 10 | .. _CircleCI: https://circleci.com/gh/j-bac/scikit-dimension/tree/master 11 | .. |Documentation| image:: https://readthedocs.org/projects/scikit-dimension/badge/?version=latest 12 | .. _Documentation: https://scikit-dimension.readthedocs.io 13 | .. |LanguageGrade| image:: https://img.shields.io/lgtm/grade/python/g/j-bac/scikit-dimension.svg?logo=lgtm&logoWidth=18 14 | .. _LanguageGrade: https://lgtm.com/projects/g/j-bac/scikit-dimension/context:python 15 | .. |License| image:: https://img.shields.io/github/license/j-bac/scikit-dimension.svg 16 | .. _License: https://github.com/j-bac/scikit-dimension/blob/master/LICENSE 17 | 18 | scikit-dimension - Intrinsic dimension estimation in Python 19 | =========================================================== 20 | 21 | **scikit-dimension** is a Python module for intrinsic dimension estimation. 22 | 23 | What is intrinsic dimension ? 24 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | Datasets available today frequently have a large number of features and are thus said to be high-dimensional. However many of these features are usually redundant, for example because of linear or non-linear correlations. In such a case it is possible to describe a dataset using a lower number of features. The notion of intrinsic dimension (ID) intuitively refers to the minimal number of features needed to represent a dataset with little information loss. 27 | 28 | In the context of the manifold hypothesis, i.e., the hypothesis that data are sampled from an underlying :math:`n`-dimensional manifold, the goal of ID estimation is to recover :math:`n`. Global estimators of ID are based on this hypothesis and return a single estimated dimension for the whole dataset. 29 | 30 | When a dataset contains multiple manifolds or regions with different dimensionality (e.g., imagine sampling a line and a sphere and joining them as one dataset), they should be explored using local estimators. The idea behind local ID estimation is to operate in local neighborhoods of each point, where a manifold can be well approximated by its flat tangent space. These local pieces of data are assumed to be close to a uniformly distributed :math:`n`-dimensional ball. In this package, local datasets are simply defined using the :math:`k`-nearest neighbours of each point, and an ID value is thus returned for each datapoint. Such an approach also allows one to repurpose global estimators as local estimators by applying them in each local neighborhood. 31 | 32 | Organization of `scikit-dimension` 33 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | 35 | `scikit-dimension` provides a submodule `id` for intrinsic dimension estimators and `datasets` to generate benchmark datasets 36 | 37 | Functionalities 38 | ^^^^^^^^^^^^^^^ 39 | - estimate global intrinsic dimension 40 | - estimate local intrinsic dimension 41 | - generate toy datasets and widely used synthetic manifolds to benchmark estimators 42 | 43 | Support 44 | ^^^^^^^ 45 | Feel free to report an `issue `_ 46 | 47 | .. toctree:: 48 | :maxdepth: 1 49 | :hidden: 50 | :caption: Main 51 | 52 | installation 53 | quick_start 54 | api 55 | release_notes 56 | references 57 | contributing 58 | 59 | .. toctree:: 60 | :caption: Tutorials 61 | :maxdepth: 1 62 | :hidden: 63 | 64 | basics -------------------------------------------------------------------------------- /doc/references.rst: -------------------------------------------------------------------------------- 1 | References 2 | ========== 3 | 4 | Articles 5 | -------- 6 | .. [Albergante2019] Albergante, L., *et al.* (2019), 7 | *Estimating the effective dimension of large biological datasets using Fisher separability analysis.*, 8 | `2019 International Joint Conference on Neural Networks, IEEE`. 9 | .. [Amsaleg2018] Amsaleg, L., *et al.* (2018), 10 | *Extreme-value-theoretic estimation of local intrinsic dimensionality.* 11 | `DAMI, 32(6):1768–1805.` 12 | .. [Amsaleg2019], Amsaleg, L., *et al.* (2019), 13 | *Intrinsic dimensionality estimation within tight localities.*, 14 | `Proceedings of the SIAM International Conference on Data Mining (SDM), pages 181–189, Calgary, Alberta, Canada` 15 | .. [Campadelli2015] Campadelli *et al.* (2015), 16 | *Intrinsic Dimension Estimation: Relevant Techniques and a Benchmark Framework.* 17 | `Mathematical Problems in Engineering`. 18 | .. [Cangelosi2007] Cangelosi, R., and Goriely, A. (2007), 19 | *Component retention in principal component analysis with application to cDNA microarray data.*, 20 | `Biol. Direct 2:2.` 21 | .. [Carter2010] Carter, K.M., *et al.* (2010), 22 | *On local intrinsic dimension estimation and its applications.*, 23 | `IEEE Trans. on Sig. Proc., 58(2), 650-663`. 24 | .. [Ceruti2012] Ceruti, C. *et al.* (2012) 25 | *DANCo: Dimensionality from Angle and Norm Concentration.*, 26 | `arXiv preprint 1206.3881`. 27 | .. [Facco2019] Facco, E. *et al.* (2019), 28 | *Estimating the intrinsic dimension of datasets by a minimal neighborhood information.*, 29 | `Nature`. 30 | .. [Fan2010] Fan, M. *et al.* (2010). 31 | *Intrinsic dimension estimation of data by principal component analysis.* 32 | `arXiv preprint 1002.2050.` 33 | .. [Farahmand2007] Farahmand, *et al.* (2007), 34 | *Manifold-adaptive dimension estimation.*, 35 | `International Conference on Machine Learning.` 36 | .. [Fukunaga2010] Fukunaga, K. and Olsen, D. R. (1971). 37 | *An algorithm for finding intrinsic dimensionality of data.*, 38 | `IEEE Trans. Comput., c-20(2):176-183.` 39 | .. [Grassberger1983] Grassberger, P. and Procaccia, I. (1983), 40 | *Measuring the strangeness of strange attractors.*, 41 | `Physica`. 42 | .. [Haro2008] Haro, G., *et al.* (2008), 43 | *Translated Poisson Mixture Model for Stratification Learning.*, 44 | `Int. J. Comput. Vis., 80, 358-374.` 45 | .. [Hill1975] Hill, B. M. (1975), 46 | *A simple general approach to inference about the tail of a distribution.*, 47 | `Ann. Stat., 3(5) 1163-1174.` 48 | .. [Johnsson2015] Johnsson, K., *et al.* (2015), 49 | *Low Bias Local Intrinsic Dimension Estimation from Expected Simplex Skewness.*, 50 | `IEEE Trans. Pattern Anal. Mach. Intell., 37(1), 196-202`. 51 | .. [Levina2005] Levina, E. and Bickel., P. J. (2005), 52 | *Maximum likelihood estimation of intrinsic dimension.* 53 | `Advances in Neural Information Processing Systems 17, 777-784. MIT Press.` 54 | .. [Rozza2012] Rozza, A., *et al.* (2012)., 55 | *Novel high intrinsic dimensionality estimators.*, 56 | `Machine Learning, 89(1-2), 37–65. doi:10.1007/s10994-012-5294-7`. 57 | 58 | Credits and links to other implementations 59 | ------------------------------------------ 60 | 61 | R 62 | ^ 63 | .. [IDJohnsson] Kerstin Johnsson, 64 | `intrinsicDimension `__. 65 | .. [IDHino] Hideitsu Hino, 66 | `ider `__. 67 | .. [IDYou] Kisung You, 68 | `Rdimtools `__. 69 | 70 | MATLAB 71 | ^^^^^^ 72 | .. [IDLombardi] Gabriele Lombardi, 73 | `idLombardi __`. 74 | .. [IDRadovanović] Miloš Radovanović, 75 | `idRadovanović __`. 76 | 77 | C++ 78 | ^^^ 79 | .. [IDFacco] Elena Facco, 80 | `TwoNN `__. 81 | 82 | Python 83 | ^^^^^^ 84 | .. [IDMottes] Francesco Mottes, 85 | `TwoNN `__. 86 | 87 | -------------------------------------------------------------------------------- /skdim/id/_CorrInt.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | import warnings 33 | import numpy as np 34 | from sklearn.metrics import pairwise_distances_chunked 35 | from .._commonfuncs import get_nn, GlobalEstimator 36 | from sklearn.utils.validation import check_array, check_symmetric 37 | 38 | 39 | class CorrInt(GlobalEstimator): 40 | """Intrinsic dimension estimation using the Correlation Dimension. [Grassberger1983]_ [IDHino]_ 41 | 42 | Parameters 43 | ---------- 44 | k1: int 45 | First neighborhood size considered 46 | k2: int 47 | Last neighborhood size considered 48 | DM: bool, default=False 49 | Is the input a precomputed distance matrix (dense) 50 | """ 51 | 52 | def __init__(self, k1=10, k2=20, DM=False): 53 | self.k1 = k1 54 | self.k2 = k2 55 | self.DM = DM 56 | 57 | def fit(self, X, y=None): 58 | """A reference implementation of a fitting function. 59 | Parameters 60 | ---------- 61 | X : {array-like}, shape (n_samples, n_features) 62 | The training input samples. 63 | y : dummy parameter to respect the sklearn API 64 | 65 | Returns 66 | ------- 67 | self : object 68 | Returns self. 69 | """ 70 | X = check_array(X, ensure_min_samples=2, ensure_min_features=2) 71 | 72 | if self.k2 >= len(X): 73 | warnings.warn("k2 larger or equal to len(X), using len(X)-1") 74 | self.k2 = len(X) - 1 75 | 76 | if self.k1 >= len(X) or self.k1 > self.k2: 77 | warnings.warn("k1 larger than k2 or len(X), using k2-1") 78 | self.k1 = self.k2 - 1 79 | 80 | self.dimension_ = self._corrint(X) 81 | self.is_fitted_ = True 82 | # `fit` should always return `self` 83 | return self 84 | 85 | def _corrint(self, X): 86 | 87 | n_elements = len(X) ** 2 # number of elements 88 | 89 | if self.DM is False: 90 | dists, _ = get_nn(X, self.k2) 91 | chunked_distmat = pairwise_distances_chunked(X) 92 | else: 93 | dists = np.sort(X, axis=1)[:, 1 : self.k2 + 1] 94 | chunked_distmat = X 95 | 96 | r1 = np.median(dists[:, self.k1 - 1]) 97 | r2 = np.median(dists[:, self.k2 - 1]) 98 | 99 | n_diagonal_entries = len(X) # remove diagonal from sum count 100 | s1 = -n_diagonal_entries 101 | s2 = -n_diagonal_entries 102 | for chunk in chunked_distmat: 103 | s1 += (chunk < r1).sum() 104 | s2 += (chunk < r2).sum() 105 | 106 | Cr = np.array([s1 / n_elements, s2 / n_elements]) 107 | estq = np.diff(np.log(Cr)) / np.log(r2 / r1) 108 | return estq[0] 109 | -------------------------------------------------------------------------------- /doc/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* ReadTheDocs theme colors */ 2 | 3 | .wy-nav-top { background-color: #404040 } 4 | .wy-nav-content { max-width: 950px } 5 | .wy-side-nav-search { background-color: transparent } 6 | .wy-side-nav-search input[type="text"] { border-width: 0 } 7 | 8 | 9 | /* Custom classes */ 10 | .small { font-size:40% } 11 | .smaller, .pr { font-size:70% } 12 | 13 | 14 | /* Custom classes with bootstrap buttons */ 15 | 16 | .tutorial, 17 | .tutorial:visited, 18 | .tutorial:hover 19 | { 20 | /* text-decoration: underline; */ 21 | font-weight: bold; 22 | padding: 2px 5px; 23 | white-space: nowrap; 24 | max-width: 100%; 25 | background: #EF3270; 26 | border: solid 1px #EF3270; 27 | border-radius: .25rem; 28 | font-size: 75%; 29 | /* font-family: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",Courier,monospace; */ 30 | color: #404040; 31 | overflow-x: auto; 32 | box-sizing: border-box; 33 | } 34 | 35 | 36 | /* Formatting of RTD markup: rubrics and sidebars and admonitions */ 37 | 38 | /* rubric */ 39 | .rst-content p.rubric { 40 | margin-bottom: 6px; 41 | font-weight: normal; 42 | } 43 | .rst-content p.rubric::after { content: ":" } 44 | 45 | /* sidebar */ 46 | .rst-content .sidebar { 47 | /* margin: 0px 0px 0px 12px; */ 48 | padding-bottom: 0px; 49 | } 50 | .rst-content .sidebar p { 51 | margin-bottom: 12px; 52 | } 53 | .rst-content .sidebar p, 54 | .rst-content .sidebar ul, 55 | .rst-content .sidebar dl { 56 | font-size: 13px; 57 | } 58 | 59 | /* less space after bullet lists in admonitions like warnings and notes */ 60 | .rst-content .section .admonition ul { 61 | margin-bottom: 6px; 62 | } 63 | 64 | 65 | /* Code: literals and links */ 66 | 67 | .rst-content tt.literal, 68 | .rst-content code.literal { 69 | color: #404040; 70 | } 71 | /* slim font weight for non-link code */ 72 | .rst-content tt:not(.xref), 73 | .rst-content code:not(.xref), 74 | .rst-content *:not(a) > tt.xref, 75 | .rst-content *:not(a) > code.xref, 76 | .rst-content a > tt.xref, 77 | .rst-content a > code.xref, 78 | .rst-content dl:not(.docutils) a > tt.xref, 79 | 80 | 81 | /* Just one box for annotation code for a less noisy look */ 82 | 83 | .rst-content .annotation { 84 | padding: 2px 5px; 85 | background-color: white; 86 | border: 1px solid #e1e4e5; 87 | } 88 | .rst-content .annotation tt, 89 | .rst-content .annotation code { 90 | padding: 0 0; 91 | background-color: transparent; 92 | border: 0 solid transparent; 93 | } 94 | 95 | 96 | /* Parameter lists */ 97 | 98 | .rst-content dl:not(.docutils) dl dt { 99 | /* mimick numpydoc’s blockquote style */ 100 | font-weight: normal; 101 | background: none transparent; 102 | border-left: none; 103 | margin: 0 0 12px; 104 | padding: 3px 0 0; 105 | font-size: 100%; 106 | } 107 | 108 | .rst-content dl:not(.docutils) dl dt code { 109 | font-size: 100%; 110 | font-weight: normal; 111 | background: none transparent; 112 | border: none; 113 | padding: 0 2px; 114 | } 115 | 116 | .rst-content dl:not(.docutils) dl dt a.reference>code { 117 | text-decoration: underline; 118 | } 119 | 120 | /* Mimick rubric style used for other headings */ 121 | .rst-content dl:not(.docutils) dl > dt { 122 | font-weight: bold; 123 | background: none transparent; 124 | border-left: none; 125 | margin: 0 0 12px; 126 | padding: 3px 0 0; 127 | font-size: 100%; 128 | } 129 | /* Parameters contain parts and don’t need bold font */ 130 | .rst-content dl.field-list dl > dt { font-weight: unset } 131 | /* Add colon between return tuple element name and type */ 132 | .rst-content dl:not(.docutils) dl > dt .classifier::before { content: ' : ' } 133 | 134 | /* Function headers */ 135 | 136 | .rst-content dl:not(.docutils) dt { 137 | background: #edf0f2; 138 | color: #404040; 139 | border-top: solid 3px #343131; 140 | } 141 | 142 | .rst-content .section ul li p:last-child { 143 | margin-bottom: 0; 144 | margin-top: 0; 145 | } 146 | 147 | /* Copy buttons */ 148 | a.copybtn { 149 | position: absolute; 150 | top: -6.5px; 151 | right: 0px; 152 | width: 1em; 153 | height: 1em; 154 | padding: .15em; 155 | opacity: .4; 156 | transition: opacity 0.5s; 157 | } 158 | 159 | 160 | /* Remove prompt line numbers */ 161 | .nbinput > :first-child, 162 | .nboutput > :first-child { 163 | min-width: 0 !important; 164 | } 165 | 166 | /* Adjust width of navigation bar on mobile */ 167 | @media screen and (max-width: 768px) { 168 | .header-bar { 169 | display: none; 170 | } 171 | 172 | .wy-nav-content-wrap { 173 | margin-left: 0px; 174 | } 175 | 176 | .wy-nav-side { 177 | width: 300px; 178 | } 179 | 180 | .wy-nav-side.shift { 181 | max-width: 320px; 182 | } 183 | 184 | /* Fix sidebar adjust */ 185 | .rst-versions { 186 | width: 40%; 187 | max-width: 320px; 188 | } 189 | } 190 | 191 | /* Handle landscape */ 192 | @media screen and (min-width: 377px) { 193 | .wy-nav-content-wrap.shift { 194 | left: 320px; 195 | } 196 | } -------------------------------------------------------------------------------- /doc/contributing.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Contributing 3 | ============ 4 | 5 | `scikit-dimension` is free open source software. 6 | Contributions from the community are highly appreciated. 7 | 8 | Even if you are not familiar with programming languages and tools, 9 | you may contribute by filing bugs or any problems as a 10 | `GitHub issue `_. 11 | 12 | 13 | Git and branching model 14 | ======================= 15 | 16 | We use `git` for version control (CVS), as do most projects nowadays. 17 | If you are not familiar with git, there are lots of tutorials on 18 | `GitHub Guide `_. 19 | All the important basics are covered in the 20 | `GitHub Git handbook `_. 21 | 22 | Development of `scikit-dimension` (mostly) follows the 23 | `git flow branching model `_. 24 | There are two main branches: master and develop. 25 | For any changes, a new branch should be created. 26 | If you want to add a new feature, fix a noncritical bug, etc. one should 27 | branch off `develop`. 28 | Only if you want to fix a critical bug, branch off `master`. 29 | 30 | Workflow 31 | ======== 32 | 33 | In case of large changes to the software, please first get in contact 34 | with the authors for coordination, for example by filing an 35 | `issue `_. 36 | If you want to fix small issues (typos in the docs, obvious errors, etc.) 37 | you can - of course - directly submit a pull request (PR). 38 | 39 | #. Create a fork of `scikit-dimension` in your GitHub account. 40 | Simply click "Fork" button on ``_. 41 | 42 | 43 | #. Clone your fork on your computer. 44 | $ ``git clone git@github.com:YOUR-ACCOUNT-GOES-HERE/scikit-dimension.git && cd scikit-dimension`` 45 | 46 | #. Add remote upstream. 47 | $ ``git remote add upstream git@github.com:j-bac/scikit-dimension.git`` 48 | 49 | #. Create feature/bugfix branch. 50 | In case of feature or noncritical bugfix: 51 | $ ``git checkout develop && git checkout -b featureXYZ develop`` 52 | 53 | In case of critical bug: 54 | $ ``git checkout -b bugfix123 master`` 55 | 56 | #. Implement feature/fix bug/fix typo/... 57 | Happy coding! 58 | 59 | #. Create a commit with meaningful message 60 | If you only modified existing files, simply 61 | ``$ git commit -am "descriptive message what this commit does (in present tense) here"`` 62 | 63 | #. Push to GitHub 64 | e.g. $ ``git push origin featureXYZ`` 65 | 66 | #. Create pull request (PR) 67 | Git will likely provide a link to directly create the PR. 68 | If not, click "New pull request" on your fork on GitHub. 69 | 70 | #. Wait... 71 | Several devops checks will be performed automatically 72 | (e.g. continuous integration (CI) with Travis, AppVeyor). 73 | 74 | The authors will get in contact with you, 75 | and may ask for changes. 76 | 77 | #. Respond to code review. 78 | If there were issues with continous integration, 79 | or the authors asked for changes, please create a new commit locally, 80 | and simply push again to GitHub as you did before. 81 | The PR will be updated automatically. 82 | 83 | #. Maintainers merge PR, when all issues are resolved. 84 | Thanks a lot for your contribution! 85 | 86 | 87 | Code style and further guidelines 88 | ================================= 89 | 90 | * Please make sure all code complies with `PEP 8 `_ 91 | 92 | * All code should be documented sufficiently 93 | (functions, classes, etc. must have docstrings with general description, parameters, 94 | ideally return values, raised exceptions, notes, etc.) 95 | 96 | * Documentation style is 97 | `NumPy format `_. 98 | 99 | * New code must be covered by unit tests using `pytest `_. 100 | 101 | * If you fix a bug, please provide regression tests (fail on old code, succeed on new code). 102 | 103 | * It may be helpful to install `scikit-dimension` in editable mode for development. 104 | When you have already cloned the package, switch into the corresponding directory, and 105 | 106 | .. code-block:: bash 107 | 108 | pip install -e . 109 | 110 | (don't omit the trailing period). 111 | This way, any changes to the code are reflected immediately. 112 | That is, you don't need to install the package each and every time, 113 | when you make changes while developing code. 114 | 115 | 116 | Testing 117 | ======= 118 | 119 | In `scikit-dimension`, we aim for high code coverage. This is primarily to ensure: 120 | 121 | * correctness of the code (to some extent) and 122 | * maintainability (new changes don't break old code). 123 | 124 | Creating a new PR, ideally all code would be covered by tests. 125 | Sometimes, this is not feasible or only with large effort. 126 | Pull requests will likely be accepted, if the overall code coverage 127 | at least does not decrease. 128 | 129 | Unit tests are automatically performed for each PR using CI tools online. 130 | This may take some time, however. 131 | To run the tests locally, you need `pytest` installed. 132 | From the scikit-dimension directory, call 133 | 134 | .. code-block:: bash 135 | 136 | pytest skdim/ --cov=skdim 137 | 138 | In order to check code coverage locally, you need the 139 | `pytest-cov plugin `_. 140 | -------------------------------------------------------------------------------- /skdim/id/_MiND_ML.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | import numpy as np 33 | import warnings 34 | from .._commonfuncs import get_nn, GlobalEstimator 35 | from scipy.optimize import minimize 36 | from sklearn.utils.validation import check_array 37 | 38 | 39 | class MiND_ML(GlobalEstimator): 40 | # SPDX-License-Identifier: MIT, 2017 Kerstin Johnsson [IDJohnsson]_ 41 | """Intrinsic dimension estimation using the MiND_MLk and MiND_MLi algorithms. [Rozza2012]_ [IDJohnsson]_ 42 | 43 | Parameters 44 | ---------- 45 | k: int, default=20 46 | Neighborhood parameter for ver='MLk' or ver='MLi'. 47 | ver: str 48 | 'MLk' or 'MLi'. See the reference paper 49 | """ 50 | 51 | def __init__(self, k=20, D=10, ver="MLk"): 52 | self.k = k 53 | self.D = D 54 | self.ver = ver 55 | 56 | def fit(self, X, y=None): 57 | """A reference implementation of a fitting function. 58 | 59 | Parameters 60 | ---------- 61 | X : {array-like}, shape (n_samples, n_features) 62 | The training input samples. 63 | y : dummy parameter to respect the sklearn API 64 | 65 | Returns 66 | ------- 67 | self : object 68 | Returns self. 69 | """ 70 | X = check_array(X, ensure_min_samples=2, ensure_min_features=2) 71 | 72 | if self.k + 1 >= len(X): 73 | warnings.warn("k+1 >= len(X), using k+1 = len(X)-1") 74 | 75 | self.dimension_ = self._MiND_MLx(X) 76 | 77 | self.is_fitted_ = True 78 | # `fit` should always return `self` 79 | return self 80 | 81 | def _MiND_MLx(self, X): 82 | nbh_data, idx = get_nn(X, min(self.k + 1, len(X) - 1)) 83 | 84 | # if (self.ver == 'ML1'): 85 | # return self._MiND_ML1(nbh_data) 86 | 87 | rhos = nbh_data[:, 0] / nbh_data[:, -1] 88 | 89 | d_MIND_MLi = self._MiND_MLi(rhos) 90 | if self.ver == "MLi": 91 | return d_MIND_MLi 92 | 93 | d_MIND_MLk = self._MiND_MLk(rhos, d_MIND_MLi) 94 | if self.ver == "MLk": 95 | return d_MIND_MLk 96 | else: 97 | raise ValueError("Unknown version: ", self.ver) 98 | 99 | # @staticmethod 100 | # def _MiND_ML1(nbh_data): 101 | # n = len(nbh_data) 102 | # #need only squared dists to first 2 neighbors 103 | # dists2 = nbh_data[:, :2]**2 104 | # s = np.sum(np.log(dists2[:, 0]/dists2[:, 1])) 105 | # ID = -2/(s/n) 106 | # return ID 107 | 108 | def _MiND_MLi(self, rhos): 109 | # MiND MLi MLk REVERSED COMPARED TO R TO CORRESPOND TO PAPER 110 | N = len(rhos) 111 | d_lik = np.array([np.nan] * self.D) 112 | for d in range(self.D): 113 | d_lik[d] = self._lld(d + 1, rhos, N) 114 | return np.argmax(d_lik) + 1 115 | 116 | def _MiND_MLk(self, rhos, dinit): 117 | # MiND MLi MLk REVERSED COMPARED TO R TO CORRESPOND TO PAPER 118 | res = minimize( 119 | fun=self._nlld, 120 | x0=np.array([dinit]), 121 | jac=self._nlld_gr, 122 | args=(rhos, len(rhos)), 123 | method="L-BFGS-B", 124 | bounds=[(0, self.D)], 125 | ) 126 | 127 | return res["x"][0] 128 | 129 | def _nlld(self, d, rhos, N): 130 | return -self._lld(d, rhos, N) 131 | 132 | def _lld(self, d, rhos, N): 133 | if d == 0: 134 | return np.array([-1e30]) 135 | else: 136 | return ( 137 | N * np.log(self.k * d) 138 | + (d - 1) * np.sum(np.log(rhos)) 139 | + (self.k - 1) * np.sum(np.log(1 - rhos ** d)) 140 | ) 141 | 142 | def _nlld_gr(self, d, rhos, N): 143 | if d == 0: 144 | return np.array([-1e30]) 145 | else: 146 | return -( 147 | N / d 148 | + np.sum( 149 | np.log(rhos) 150 | - (self.k - 1) * (rhos ** d) * np.log(rhos) / (1 - rhos ** d) 151 | ) 152 | ) 153 | -------------------------------------------------------------------------------- /skdim/id/_KNN.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | import numpy as np 33 | from scipy.spatial.distance import pdist, squareform 34 | from sklearn.utils.validation import check_array 35 | from .._commonfuncs import GlobalEstimator 36 | 37 | 38 | class KNN(GlobalEstimator): 39 | # SPDX-License-Identifier: MIT, 2017 Kerstin Johnsson [IDJohnsson]_ 40 | """Intrinsic dimension estimation using the kNN algorithm. [Carter2010]_ [IDJohnsson]_ 41 | 42 | This is a simplified version of the kNN dimension estimation method described by Carter et al. (2010), 43 | the difference being that block bootstrapping is not used. 44 | 45 | Parameters 46 | ---------- 47 | X: 2D numeric array 48 | A 2D data set with each row describing a data point. 49 | k: int 50 | Number of distances to neighbors used at a time. 51 | ps: 1D numeric array 52 | Vector with sample sizes; each sample size has to be larger than k and smaller than nrow(data). 53 | M: int, default=1 54 | Number of bootstrap samples for each sample size. 55 | gamma: int, default=2 56 | Weighting constant. 57 | """ 58 | 59 | def __init__(self, k=None, ps=None, M=1, gamma=2): 60 | self.k = k 61 | self.ps = ps 62 | self.M = M 63 | self.gamma = gamma 64 | 65 | def fit(self, X, y=None): 66 | """A reference implementation of a fitting function. 67 | Parameters 68 | ---------- 69 | X : {array-like}, shape (n_samples, n_features) 70 | The training input samples. 71 | y : dummy parameter to respect the sklearn API 72 | 73 | Returns 74 | ------- 75 | self: object 76 | Returns self. 77 | self.dimension_: float 78 | The estimated intrinsic dimension 79 | self.residual_: float 80 | Residuals 81 | """ 82 | 83 | self._k = 2 if self.k is None else self.k 84 | self._ps = np.arange(self._k + 1, self._k + 5) if self.ps is None else self.ps 85 | 86 | X = check_array(X, ensure_min_samples=self._k + 1, ensure_min_features=2) 87 | 88 | self.dimension_, self.residual_ = self._knnDimEst(X) 89 | self.is_fitted_ = True 90 | # `fit` should always return `self` 91 | return self 92 | 93 | def _knnDimEst(self, X): 94 | n = len(X) 95 | Q = len(self._ps) 96 | 97 | if min(self._ps) <= self._k or max(self._ps) > n: 98 | raise ValueError("ps must satisfy k 1: 56 | with Parallel(n_jobs=n_jobs) as parallel: 57 | # Asynchronously apply the `fit` function to each data point and collect the results 58 | results = parallel( 59 | delayed(self._idtle)( 60 | X[knnidx[i, :]], dists[[i], :] 61 | ) for i in range(len(X)) 62 | ) 63 | self.dimension_pw_ = np.array(results) 64 | else: 65 | self.dimension_pw_ = np.zeros(len(X)) 66 | for i in range(len(X)): 67 | self.dimension_pw_[i] = self._idtle(X[knnidx[i, :]], dists[[i], :]) 68 | 69 | def _idtle(self, nn, dists): 70 | # nn - matrix of nearest neighbors (n_neighbors x d), sorted by distance 71 | # dists - nearest-neighbor distances (1 x n_neighbors), sorted 72 | r = dists[0, -1] # distance to n_neighbors-th neighbor 73 | 74 | # Boundary case 1: If $r = 0$, this is fatal, since the neighborhood would be degenerate. 75 | if r == 0: 76 | raise ValueError("All k-NN distances are zero!") 77 | # Main computation 78 | n_neighbors = dists.shape[1] 79 | V = squareform(pdist(nn)) 80 | Di = np.tile(dists.T, (1, n_neighbors)) 81 | Dj = Di.T 82 | Z2 = 2 * Di ** 2 + 2 * Dj ** 2 - V ** 2 83 | S = ( 84 | r 85 | * ( 86 | ((Di ** 2 + V ** 2 - Dj ** 2) ** 2 + 4 * V ** 2 * (r ** 2 - Di ** 2)) 87 | ** 0.5 88 | - (Di ** 2 + V ** 2 - Dj ** 2) 89 | ) 90 | / (2 * (r ** 2 - Di ** 2)) 91 | ) 92 | T = ( 93 | r 94 | * ( 95 | ((Di ** 2 + Z2 - Dj ** 2) ** 2 + 4 * Z2 * (r ** 2 - Di ** 2)) ** 0.5 96 | - (Di ** 2 + Z2 - Dj ** 2) 97 | ) 98 | / (2 * (r ** 2 - Di ** 2)) 99 | ) 100 | # handle case of repeating k-NN distances 101 | Dr = (dists == r).squeeze() 102 | S[Dr, :] = r * V[Dr, :] ** 2 / (r ** 2 + V[Dr, :] ** 2 - Dj[Dr, :] ** 2) 103 | T[Dr, :] = r * Z2[Dr, :] / (r ** 2 + Z2[Dr, :] - Dj[Dr, :] ** 2) 104 | # Boundary case 2: If $u_i = 0$, then for all $1\leq j\leq n_neighbors$ the measurements $s_{ij}$ and $t_{ij}$ reduce to $u_j$. 105 | Di0 = (Di == 0).squeeze() 106 | T[Di0] = Dj[Di0] 107 | S[Di0] = Dj[Di0] 108 | # Boundary case 3: If $u_j = 0$, then for all $1\leq j\leq n_neighbors$ the measurements $s_{ij}$ and $t_{ij}$ reduce to $\frac{r v_{ij}}{r + v_{ij}}$. 109 | Dj0 = (Dj == 0).squeeze() 110 | T[Dj0] = r * V[Dj0] / (r + V[Dj0]) 111 | S[Dj0] = r * V[Dj0] / (r + V[Dj0]) 112 | # Boundary case 4: If $v_{ij} = 0$, then the measurement $s_{ij}$ is zero and must be dropped. The measurement $t_{ij}$ should be dropped as well. 113 | V0 = (V == 0).squeeze() 114 | np.fill_diagonal(V0, False) 115 | # by setting to r, $t_{ij}$ will not contribute to the sum s1t 116 | T[V0] = r 117 | # by setting to r, $s_{ij}$ will not contribute to the sum s1s 118 | S[V0] = r 119 | # will subtract twice this number during ID computation below 120 | nV0 = np.sum(V0) 121 | # Drop T & S measurements below epsilon (V4: If $s_{ij}$ is thrown out, then for the sake of balance, $t_{ij}$ should be thrown out as well (or vice versa).) 122 | TSeps = (T < self.epsilon) | (S < self.epsilon) 123 | np.fill_diagonal(TSeps, 0) 124 | nTSeps = np.sum(TSeps) 125 | T[TSeps] = r 126 | T = np.log(T / r) 127 | S[TSeps] = r 128 | S = np.log(S / r) 129 | np.fill_diagonal(T, 0) # delete diagonal elements 130 | np.fill_diagonal(S, 0) 131 | # Sum over the whole matrices 132 | s1t = np.sum(T) 133 | s1s = np.sum(S) 134 | # Drop distances below epsilon and compute sum 135 | Deps = dists < self.epsilon 136 | nDeps = np.sum(Deps, dtype=int) 137 | dists = dists[nDeps:] 138 | s2 = np.sum(np.log(dists / r)) 139 | # Compute ID, subtracting numbers of dropped measurements 140 | ID = -2 * (n_neighbors ** 2 - nTSeps - nDeps - nV0) / (s1t + s1s + 2 * s2) 141 | return ID 142 | -------------------------------------------------------------------------------- /skdim/id/_DANCoUtils.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # from skdim.id._DANCo import DANCo 33 | # from skdim.datasets import hyperBall 34 | # from scipy.interpolate import interp2d 35 | # import pickle 36 | # import plotly.graph_objs as go 37 | # from plotly.subplots import make_subplots 38 | # 39 | # def DANCoTrain(k=10,D=100, 40 | # cardinalities=list(range(20,410,20))+[500,1000,2000,5000], 41 | # iterations=100, 42 | # n_cpus=1, 43 | # save_output_path=''): 44 | # ''' Pre-compute splines to approximate DANCo statistics as a function of 45 | # dimension D and data cardinalities (DANCoFit)''' 46 | # 47 | # N=len(cardinalities) 48 | # 49 | # dHat = np.zeros((D,N)) 50 | # mu = np.zeros((D,N)) 51 | # tau = np.zeros((D,N)) 52 | # 53 | # for d in range(1,D+1): 54 | # for n in range(N): 55 | # # Initializing the data of this iteration: 56 | # dhats = [] 57 | # nus = [] 58 | # taus = [] 59 | # 60 | # danco = DANCo(k=k,D=d) 61 | # danco._k = k 62 | # 63 | # if d >=10 and n >=1000: 64 | # n_jobs=n_cpus 65 | # else: 66 | # n_jobs=1 67 | # 68 | # # Printing to the user: 69 | # print('(d = {} \tn = {})...'.format(d,cardinalities[n])) 70 | # # Executing the experiments: 71 | # for i in range(iterations): 72 | # 73 | # # Generating the dataset: 74 | # data = skdim.datasets.hyperBall(cardinalities[n],d,radius=1) 75 | # if d==1: data = data.reshape(-1,1) 76 | # 77 | # # Estimating the parameters: 78 | # res = danco._dancoDimEstNoCalibration(data, d*2+5,n_jobs=n_jobs) 79 | # dhats.append(res['dhat']) 80 | # nus.append(res['mu_nu']) 81 | # taus.append(res['mu_tau']) 82 | # 83 | # # Storing the results: 84 | # dHat[d-1,n] = np.nanmean(dhats) 85 | # mu[d-1,n] = np.nanmean(nus) 86 | # tau[d-1,n] = np.nanmean(taus) 87 | # 88 | # #fit splines 89 | # kind='cubic' 90 | # 91 | # spline_dhat=interp2d(x=np.repeat(np.arange(1,D+1),N), 92 | # y=np.tile(cardinalities,D), 93 | # z=dHat.ravel(), 94 | # kind=kind) 95 | # 96 | # spline_mu=interp2d(x=np.repeat(np.arange(1,D+1),N), 97 | # y=np.tile(cardinalities,D), 98 | # z=mu.ravel(), 99 | # kind=kind) 100 | # 101 | # spline_tau=interp2d(x=np.repeat(np.arange(1,D+1),N), 102 | # y=np.tile(cardinalities,D), 103 | # z=tau.ravel(), 104 | # kind=kind) 105 | # 106 | # DANCo_splines = {} 107 | # for spl in ['spline_dhat','spline_mu','spline_tau']: 108 | # DANCo_splines[spl]=vars()[spl] 109 | # 110 | # if type(save_output_path) == str: 111 | # np.savetxt(save_output_path+'dhat',dHat) 112 | # np.savetxt(save_output_path+'mu',mu) 113 | # np.savetxt(save_output_path+'tau',tau) 114 | # 115 | # for spl in ['spline_dhat','spline_mu','spline_tau']: 116 | # with open(save_output_path+'DANCo_'+spl+'.pkl', 'wb') as f: 117 | # pickle.dump(vars()[spl], f) 118 | # 119 | # #loading and returning saved splines to make sure everything is ok 120 | # DANCo_splines = {} 121 | # for spl in ['spline_dhat','spline_mu','spline_tau']: 122 | # with open(save_output_path+'DANCo_'+spl+'.pkl', 'rb') as f: 123 | # DANCo_splines[spl]=pickle.load(f) 124 | # 125 | # #alternative way to save splines as explicit parameters 126 | # #from scipy.interpolate import BivariateSpline 127 | # #tck = DANCo_splines['spline_dhat'].tck 128 | # #spl2 = BivariateSpline._from_tck(tck) 129 | # 130 | # return dHat,mu,tau,DANCo_splines 131 | # 132 | # return dHat,mu,tau,DANCo_splines 133 | # 134 | # def load_DANCoTrain_results(path=''): 135 | # 136 | # dHat = np.loadtxt(path+'dhat') 137 | # mu = np.loadtxt(path+'mu') 138 | # tau = np.loadtxt(path+'tau') 139 | # 140 | # DANCo_splines = {} 141 | # for spl in ['spline_dhat','spline_mu','spline_tau']: 142 | # with open(path+'DANCo_'+spl+'.pkl', 'rb') as f: 143 | # DANCo_splines[spl]=pickle.load(f) 144 | # 145 | # return dHat,mu,tau,DANCo_splines 146 | # 147 | # def plot_DANCoTrain(cardinalities,dHat,mu,tau,DANCo_splines): 148 | # 149 | # fig = make_subplots( 150 | # rows=1, cols=3, 151 | # subplot_titles=['dHat','mu','tau'], 152 | # specs=[[{'type': 'scatter3d'}, {'type': 'scatter3d'},{'type': 'scatter3d'}]] 153 | # ) 154 | # 155 | # N=len(cardinalities) 156 | # DANCostats=[dHat,mu,tau] 157 | # for i in range(1,4): 158 | # interp=DANCo_splines[list(DANCo_splines.keys())[i-1]](x=np.arange(1,len(dHat)),y=cardinalities) 159 | # 160 | # fig.add_trace(go.Scatter3d(x=np.repeat(np.arange(1,len(dHat)),N), 161 | # y=np.tile(cardinalities,len(dHat)), 162 | # z=DANCostats[i-1].ravel(), 163 | # marker=dict(size=1), 164 | # mode='markers'), 165 | # row=1,col=i) 166 | # 167 | # fig.add_trace(go.Surface(x=np.arange(1,len(dHat)), 168 | # y=cardinalities, 169 | # z=interp), 170 | # row=1,col=i) 171 | # 172 | # 173 | # fig.update_layout( 174 | # title_text='', 175 | # height=400, 176 | # width=1000) 177 | # fig.show() 178 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | -rm -rf $(BUILDDIR)/* 51 | -rm -rf auto_examples/ 52 | -rm -rf generated/* 53 | -rm -rf modules/generated/* 54 | 55 | html: 56 | # These two lines make the build a bit more lengthy, and the 57 | # the embedding of images more robust 58 | rm -rf $(BUILDDIR)/html/_images 59 | #rm -rf _build/doctrees/ 60 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 61 | @echo 62 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 63 | 64 | dirhtml: 65 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 66 | @echo 67 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 68 | 69 | singlehtml: 70 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 71 | @echo 72 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 73 | 74 | pickle: 75 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 76 | @echo 77 | @echo "Build finished; now you can process the pickle files." 78 | 79 | json: 80 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 81 | @echo 82 | @echo "Build finished; now you can process the JSON files." 83 | 84 | htmlhelp: 85 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 86 | @echo 87 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 88 | ".hhp project file in $(BUILDDIR)/htmlhelp." 89 | 90 | qthelp: 91 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 92 | @echo 93 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 94 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 95 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/project-template.qhcp" 96 | @echo "To view the help file:" 97 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/project-template.qhc" 98 | 99 | devhelp: 100 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 101 | @echo 102 | @echo "Build finished." 103 | @echo "To view the help file:" 104 | @echo "# mkdir -p $$HOME/.local/share/devhelp/project-template" 105 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/project-template" 106 | @echo "# devhelp" 107 | 108 | epub: 109 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 110 | @echo 111 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 112 | 113 | latex: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo 116 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 117 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 118 | "(use \`make latexpdf' here to do that automatically)." 119 | 120 | latexpdf: 121 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 122 | @echo "Running LaTeX files through pdflatex..." 123 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 124 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 125 | 126 | latexpdfja: 127 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 128 | @echo "Running LaTeX files through platex and dvipdfmx..." 129 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 130 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 131 | 132 | text: 133 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 134 | @echo 135 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 136 | 137 | man: 138 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 139 | @echo 140 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 141 | 142 | texinfo: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo 145 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 146 | @echo "Run \`make' in that directory to run these through makeinfo" \ 147 | "(use \`make info' here to do that automatically)." 148 | 149 | info: 150 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 151 | @echo "Running Texinfo files through makeinfo..." 152 | make -C $(BUILDDIR)/texinfo info 153 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 154 | 155 | gettext: 156 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 157 | @echo 158 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 159 | 160 | changes: 161 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 162 | @echo 163 | @echo "The overview file is in $(BUILDDIR)/changes." 164 | 165 | linkcheck: 166 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 167 | @echo 168 | @echo "Link check complete; look for any errors in the above output " \ 169 | "or in $(BUILDDIR)/linkcheck/output.txt." 170 | 171 | doctest: 172 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 173 | @echo "Testing of doctests in the sources finished, look at the " \ 174 | "results in $(BUILDDIR)/doctest/output.txt." 175 | 176 | xml: 177 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 178 | @echo 179 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 180 | 181 | pseudoxml: 182 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 183 | @echo 184 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 185 | -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\project-template.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\project-template.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /skdim/id/_TwoNN.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | # MIT License 33 | # 34 | # Copyright (c) 2019 fmottes 35 | # 36 | # Permission is hereby granted, free of charge, to any person obtaining a copy 37 | # of this software and associated documentation files (the "Software"), to deal 38 | # in the Software without restriction, including without limitation the rights 39 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 40 | # copies of the Software, and to permit persons to whom the Software is 41 | # furnished to do so, subject to the following conditions: 42 | # 43 | # The above copyright notice and this permission notice shall be included in all 44 | # copies or substantial portions of the Software. 45 | # 46 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 47 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 49 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 52 | # SOFTWARE. 53 | 54 | from sklearn.utils.validation import check_array 55 | 56 | import numpy as np 57 | from sklearn.metrics.pairwise import pairwise_distances_chunked 58 | from sklearn.linear_model import LinearRegression 59 | from .._commonfuncs import get_nn, GlobalEstimator 60 | 61 | 62 | class TwoNN(GlobalEstimator): 63 | # SPDX-License-Identifier: MIT, 2019 Francesco Mottes [IDMottes]_ 64 | """Intrinsic dimension estimation using the TwoNN algorithm. [Facco2019]_ [IDFacco]_ [IDMottes]_ 65 | 66 | Parameters 67 | ---------- 68 | discard_fraction: float 69 | Fraction (between 0 and 1) of largest distances to discard (heuristic from the paper) 70 | dist: bool 71 | Whether data is a precomputed distance matrix 72 | 73 | Attributes 74 | ---------- 75 | x_: 1d array 76 | np.array with the -log(mu) values. 77 | y_: 1d array 78 | np.array with the -log(F(mu_{sigma(i)})) values. 79 | """ 80 | 81 | def __init__(self, discard_fraction: float = 0.1, dist: bool = False): 82 | self.discard_fraction = discard_fraction 83 | self.dist = dist 84 | 85 | def fit(self, X, y=None): 86 | """A reference implementation of a fitting function. 87 | Parameters 88 | ---------- 89 | X : {array-like}, shape (n_samples, n_features) 90 | A data set for which the intrinsic dimension is estimated. 91 | y : dummy parameter to respect the sklearn API 92 | 93 | Returns 94 | ------- 95 | self : object 96 | Returns self. 97 | """ 98 | X = check_array(X, ensure_min_samples=2, ensure_min_features=2) 99 | 100 | self.dimension_, self.x_, self.y_ = self._twonn(X) 101 | 102 | self.is_fitted_ = True 103 | # `fit` should always return `self` 104 | return self 105 | 106 | def _twonn(self, X): 107 | """ 108 | Calculates intrinsic dimension of the provided data points with the TWO-NN algorithm. 109 | 110 | ----------- 111 | Parameters: 112 | 113 | X : 2d array-like 114 | 2d data matrix. Samples on rows and features on columns. 115 | return_xy : bool (default=False) 116 | Whether to return also the coordinate vectors used for the linear fit. 117 | discard_fraction : float between 0 and 1 118 | Fraction of largest distances to discard (heuristic from the paper) 119 | dist : bool (default=False) 120 | Whether data is a precomputed distance matrix 121 | ----------- 122 | Returns: 123 | 124 | d : float 125 | Intrinsic dimension of the dataset according to TWO-NN. 126 | x : 1d np.array (optional) 127 | Array with the -log(mu) values. 128 | y : 1d np.array (optional) 129 | Array with the -log(F(mu_{sigma(i)})) values. 130 | 131 | ----------- 132 | References: 133 | 134 | E. Facco, M. d’Errico, A. Rodriguez & A. Laio 135 | Estimating the intrinsic dimension of datasets by a minimal neighborhood information (https://doi.org/10.1038/s41598-017-11873-y) 136 | """ 137 | 138 | N = len(X) 139 | 140 | if self.dist: 141 | r1, r2 = X[:, 0], X[:, 1] 142 | _mu = r2 / r1 143 | # discard the largest distances 144 | mu = _mu[np.argsort(_mu)[: int(N * (1 - self.discard_fraction))]] 145 | 146 | else: 147 | # mu = r2/r1 for each data point 148 | # relatively high dimensional data, use distance matrix generator 149 | if X.shape[1] > 25: 150 | distmat_chunks = pairwise_distances_chunked(X) 151 | _mu = np.zeros((len(X))) 152 | i = 0 153 | for x in distmat_chunks: 154 | x = np.sort(x, axis=1) 155 | r1, r2 = x[:, 1], x[:, 2] 156 | _mu[i : i + len(x)] = r2 / r1 157 | i += len(x) 158 | 159 | # discard the largest distances 160 | mu = _mu[np.argsort(_mu)[: int(N * (1 - self.discard_fraction))]] 161 | 162 | else: # relatively low dimensional data, search nearest neighbors directly 163 | dists, _ = get_nn(X, k=2) 164 | r1, r2 = dists[:, 0], dists[:, 1] 165 | _mu = r2 / r1 166 | # discard the largest distances 167 | mu = _mu[np.argsort(_mu)[: int(N * (1 - self.discard_fraction))]] 168 | 169 | # Empirical cumulate 170 | Femp = np.arange(1, 1 + int(N * (1 - self.discard_fraction))) / N 171 | 172 | # Fit line 173 | lr = LinearRegression(fit_intercept=False) 174 | lr.fit(np.log(mu).reshape(-1, 1), -np.log(1 - Femp).reshape(-1, 1)) 175 | 176 | d = lr.coef_[0][0] # extract slope 177 | 178 | return ( 179 | d, 180 | np.log(mu).reshape(-1, 1), 181 | -np.log(1 - Femp).reshape(-1, 1), 182 | ) 183 | -------------------------------------------------------------------------------- /skdim/tests/test_all_params.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | import pytest 33 | import numpy as np 34 | import skdim 35 | import matplotlib.pyplot as plt 36 | from inspect import getmembers, isclass 37 | from sklearn.utils.estimator_checks import check_estimator 38 | 39 | 40 | @pytest.fixture 41 | def data(): 42 | X = np.zeros((100, 10)) 43 | X[:, :5] = skdim.datasets.hyperBall(n=100, d=5, radius=1, random_state=0) 44 | return X 45 | 46 | 47 | # test all estimators pass check_estimator 48 | estimators = [o[1] for o in getmembers(skdim.id) if isclass(o[1])] 49 | 50 | 51 | @pytest.mark.parametrize("Estimator", estimators) 52 | def test_all_estimators(Estimator): 53 | return check_estimator(Estimator()) 54 | 55 | 56 | # test default and non-default parameters 57 | def test_ess_params(data): 58 | x = skdim.id.ESS().fit(data) 59 | x = skdim.id.ESS(ver="b").fit(data) 60 | x = skdim.id.ESS(d=2).fit(data) 61 | x = skdim.id.ESS().fit_once(data) 62 | 63 | ### additionally test all common LocalEstimator base functions 64 | x = skdim.id.ESS().fit(data).transform() 65 | x = skdim.id.ESS().fit(data).transform_pw() 66 | x = skdim.id.ESS().fit_transform(data) 67 | x = skdim.id.ESS().fit_transform_pw(data) 68 | x = skdim.id.ESS().fit_transform_pw(data, smooth=True) 69 | 70 | 71 | def test_fisher_params(data, monkeypatch): 72 | monkeypatch.setattr(plt, "show", lambda: None) 73 | x = skdim.id.FisherS().fit(data) 74 | x = skdim.id.FisherS(conditional_number=2).fit(data) 75 | x = skdim.id.FisherS(produce_plots=True).fit(data) 76 | x = skdim.id.FisherS(project_on_sphere=False).fit(data) 77 | x = skdim.id.FisherS(verbose=True).fit(data) 78 | x = skdim.id.FisherS(limit_maxdim=True).fit(data) 79 | x = skdim.id.FisherS().fit(data).point_inseparability_to_pointID() 80 | 81 | ### additionally test all common GlobalEstimator base functions 82 | x = skdim.id.FisherS().fit(data).transform() 83 | x = skdim.id.FisherS().fit_pw(data, n_neighbors=50).transform_pw() 84 | x = skdim.id.FisherS().fit_transform(data) 85 | x = skdim.id.FisherS().fit_transform_pw(data, n_neighbors=50) 86 | 87 | 88 | def test_mind_ml_params(data): 89 | x = skdim.id.MiND_ML() 90 | x = skdim.id.MiND_ML(ver="MLi") 91 | x = skdim.id.MiND_ML(ver="ML1") 92 | x = skdim.id.MiND_ML(D=5) 93 | x = skdim.id.MiND_ML(k=5) 94 | 95 | 96 | def test_mom_params(data): 97 | x = skdim.id.MOM() 98 | 99 | 100 | def test_lpca_params(data): 101 | x = skdim.id.lPCA().fit(data) 102 | x = skdim.id.lPCA(ver="Fan").fit(data) 103 | x = skdim.id.lPCA(ver="ratio").fit(data) 104 | x = skdim.id.lPCA(ver="maxgap").fit(data) 105 | x = skdim.id.lPCA(ver="Kaiser").fit(data) 106 | x = skdim.id.lPCA(ver="broken_stick").fit(data) 107 | x = skdim.id.lPCA(ver="participation_ratio").fit(data) 108 | 109 | 110 | def test_tle_params(data): 111 | x = skdim.id.TLE().fit(data) 112 | x = skdim.id.TLE(epsilon=0.01).fit(data) 113 | 114 | 115 | def test_corrint_params(data): 116 | x = skdim.id.CorrInt().fit(data) 117 | x = skdim.id.CorrInt(k1=5, k2=15).fit(data) 118 | 119 | 120 | def test_danco_params(data): 121 | x = skdim.id.DANCo().fit(data) 122 | x = skdim.id.DANCo(fractal=False).fit(data) 123 | x = skdim.id.DANCo(D=5).fit(data) 124 | x = skdim.id.DANCo(k=5).fit(data) 125 | x = skdim.id.DANCo(ver="MIND_MLk").fit(data) 126 | x = skdim.id.DANCo(ver="MIND_MLi").fit(data) 127 | 128 | 129 | def test_knn_params(data): 130 | x = skdim.id.KNN().fit(data) 131 | x = skdim.id.KNN(k=5).fit(data) 132 | x = skdim.id.KNN(ps=np.arange(30, 32)).fit(data) 133 | x = skdim.id.KNN(M=2).fit(data) 134 | x = skdim.id.KNN(gamma=3).fit(data) 135 | 136 | 137 | def test_mada_params(data): 138 | x = skdim.id.MADA().fit(data) 139 | 140 | 141 | def test_mle_params(data): 142 | x = skdim.id.MLE().fit(data) 143 | x = skdim.id.MLE(n=20, sigma=0.1, dnoise="dnoiseGaussH").fit(data) 144 | x = skdim.id.MLE(unbiased=True).fit(data) 145 | x = skdim.id.MLE(K=10, neighborhood_based=False).fit(data) 146 | 147 | 148 | def test_twonn_params(data): 149 | # to trigger the "n_features>25 condition" 150 | test_high_dim = np.zeros((len(data), 30)) 151 | test_high_dim[:, : data.shape[1]] = data 152 | x = skdim.id.TwoNN().fit(test_high_dim) 153 | x = skdim.id.TwoNN(discard_fraction=0.05).fit(data) 154 | 155 | 156 | def test_aspointwise(data): 157 | x = skdim.asPointwise(data, skdim.id.TwoNN(), n_neighbors=50) 158 | x = skdim.asPointwise(data, skdim.id.TwoNN(), n_neighbors=50, n_jobs=2) 159 | assert len(x) == len(data) 160 | 161 | 162 | def test_datasets(): 163 | skdim.datasets.hyperBall(100, 2) 164 | skdim.datasets.hyperSphere(100, 2) 165 | skdim.datasets.hyperTwinPeaks(100, 2) 166 | skdim.datasets.lineDiskBall(100) 167 | skdim.datasets.swissRoll3Sph(100, 100) 168 | skdim.datasets.BenchmarkManifolds(noise_type="uniform").generate(n=123) 169 | skdim.datasets.BenchmarkManifolds(noise_type="normal").generate( 170 | name="M5b_Helix2d", n=456, dim=3, d=2 171 | ) 172 | 173 | 174 | def test_fisher_separability_graph(monkeypatch): 175 | monkeypatch.setattr(plt, "show", lambda: None) 176 | import numpy as np 177 | from sklearn.decomposition import PCA 178 | from scipy.stats.mstats import winsorize 179 | 180 | ball1 = skdim.datasets.hyperBall(n=1000, d=3, radius=0.5, center=[0, 0, 0]).T 181 | ball2 = skdim.datasets.hyperBall( 182 | n=1000, d=6, radius=0.5, center=[1, 0, 0, 0, 0, 0] 183 | ).T 184 | 185 | _2balls = np.zeros((6, 2000)) 186 | _2balls[:3, :1000] = ball1 187 | _2balls[:, 1000:2000] = ball2 188 | X = _2balls.T 189 | 190 | u = PCA().fit_transform(X) 191 | fishers = skdim.id.FisherS(conditional_number=10000).fit(X) 192 | ns = fishers.point_inseparability_to_pointID()[0] 193 | edges, weights = fishers.getSeparabilityGraph() 194 | 195 | nsw = winsorize(ns, limits=(0.01, 0.01), inclusive=(True, True)) 196 | plt.figure(figsize=(10, 5)) 197 | plt.scatter(u[:, 0], u[:, 1], c=nsw) 198 | fishers.plotSeparabilityGraph(u[:, 0], u[:, 1], edges, alpha=0.2) 199 | plt.colorbar() 200 | plt.axis("equal") 201 | plt.title("PCA on original data") 202 | plt.xlabel("PC1") 203 | plt.ylabel("PC2") 204 | plt.show() 205 | -------------------------------------------------------------------------------- /skdim/tests/test_results.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | import pytest 33 | import numpy as np 34 | import skdim 35 | 36 | # import rpy2.robjects.packages as rpackages 37 | # import rpy2.robjects.numpy2ri 38 | # utils = rpackages.importr('utils') 39 | # utils.install_packages('intrinsicDimension') 40 | # utils.install_packages('ider') 41 | # intdimr = rpackages.importr('intrinsicDimension') 42 | # ider = intdimr = rpackages.importr('ider') 43 | # rpy2.robjects.numpy2ri.activate() 44 | 45 | 46 | @pytest.fixture 47 | def data(): 48 | X = np.zeros((30, 10)) 49 | X[:, :5] = skdim.datasets.hyperBall(n=30, d=5, radius=1, random_state=0) 50 | return X 51 | 52 | 53 | # test default and non-default parameters 54 | def test_ess_results(data): 55 | x = skdim.id.ESS().fit_once(data) 56 | x2 = skdim.id.ESS(ver="b").fit_once(data) 57 | x3 = skdim.id.ESS(d=2).fit_once(data) 58 | 59 | # rx=intdimr.essLocalDimEst(data) 60 | # rx2=intdimr.essLocalDimEst(data,ver='b') 61 | # rx3=intdimr.essLocalDimEst(data,d=2) 62 | # rx_results = np.array([rx[0],rx[1],rx2[0],rx2[1],rx3[0],rx3[1]]).T 63 | rx_results = np.array( 64 | [[5.08681575, 0.88546915, 5.11274497, 0.371001, 5.06259738, 0.66653896,]] 65 | ) 66 | 67 | assert np.allclose( 68 | np.array( 69 | [ 70 | x.dimension_, 71 | x.essval_, 72 | x2.dimension_, 73 | x2.essval_, 74 | x3.dimension_, 75 | x3.essval_, 76 | ] 77 | ), 78 | rx_results, 79 | ) 80 | 81 | 82 | def test_mind_ml_results(data): 83 | # all((skdim.id.MiND_ML(ver='MLk').fit(data).dimension_ == np.array(intdimr.dancoDimEst(data,k=20,D=10,ver='MIND_MLi')[0]), 84 | # skdim.id.MiND_ML(ver='MLi').fit(data).dimension_ == np.array(intdimr.dancoDimEst(data,k=10,D=5,ver='MIND_MLk')[0]))) 85 | assert all( 86 | ( 87 | skdim.id.MiND_ML(ver="MLk").fit(data).dimension_ == 3.696083548872364, 88 | skdim.id.MiND_ML(ver="MLi").fit(data).dimension_ == 4, 89 | ) 90 | ) 91 | 92 | 93 | # def test_mom_results(data): 94 | # x = skdim.id.MOM() 95 | # x = skdim.id.MOM(k=5) 96 | 97 | 98 | def test_lpca_results(data): 99 | # assert all((skdim.id.lPCA().fit(data).dimension_ == intdimr.pcaLocalDimEst(data,ver='FO')[0][0], 100 | # skdim.id.lPCA(ver='fan').fit(data).dimension_ == intdimr.pcaLocalDimEst(data,ver='fan')[0][0], 101 | # skdim.id.lPCA(ver='maxgap').fit(data).dimension_ == intdimr.pcaLocalDimEst(data,ver='maxgap')[0][0] 102 | # )) 103 | assert all( 104 | ( 105 | skdim.id.lPCA().fit(data).dimension_ == 5, 106 | skdim.id.lPCA(ver="Fan").fit(data).dimension_ == 3, 107 | skdim.id.lPCA(ver="maxgap").fit(data).dimension_ == 5, 108 | ) 109 | ) 110 | 111 | 112 | def test_corrint_results(data): 113 | # assert np.isclose(skdim.id.CorrInt().fit(data).dimension_,np.array(ider.corint(data,k1=10,k2=20))) 114 | assert np.isclose(skdim.id.CorrInt().fit(data).dimension_, 2.9309171335492548) 115 | 116 | 117 | def test_danco_results(): 118 | x = np.zeros(9) 119 | for i in range(2, 11): 120 | print(i, end="\r") 121 | X = skdim.datasets.hyperBall(n=100, d=i, radius=1, random_state=0) 122 | x[i - 2] = skdim.id.DANCo(D=11, fractal=False, random_state=0).fit(X).dimension_ 123 | 124 | assert np.all(x == np.array([2, 3, 4, 5, 6, 7, 8, 9, 10])) 125 | 126 | 127 | # def test_knn_results(data): 128 | # x = skdim.id.KNN().fit(data) 129 | # x = skdim.id.KNN(k=5).fit(data) 130 | # x = skdim.id.KNN(ps=np.arange(30,32)).fit(data) 131 | # x = skdim.id.KNN(M=2).fit(data) 132 | # x = skdim.id.KNN(gamma=3).fit(data) 133 | 134 | 135 | def test_mada_results(data): 136 | # assert np.allclose(skdim.id.Mada(local=True,k=20).fit(data).dimension_,np.array(ider.mada(data,local=True,k=20))) 137 | # 138 | assert np.allclose( 139 | skdim.id.MADA().fit(data).dimension_pw_, 140 | np.array( 141 | [ 142 | 2.73873109, 143 | 2.1619804, 144 | 2.29577097, 145 | 3.13300883, 146 | 2.68340134, 147 | 2.7744833, 148 | 2.16936429, 149 | 2.63976628, 150 | 3.73803225, 151 | 2.68782875, 152 | 3.3468158, 153 | 3.3375878, 154 | 2.58747076, 155 | 3.49101585, 156 | 2.84130906, 157 | 3.68365681, 158 | 3.5694458, 159 | 3.50015857, 160 | 2.78155042, 161 | 4.47995493, 162 | 4.0897491, 163 | 3.79781342, 164 | 2.62101409, 165 | 3.03665971, 166 | 2.84263582, 167 | 3.82414291, 168 | 2.65283788, 169 | 3.46869821, 170 | 3.851816, 171 | 3.13222988, 172 | ] 173 | ), 174 | ) 175 | 176 | 177 | def test_mle_results(data): 178 | # assert np.allclose( 179 | # (skdim.id.MLE().fit(data).dimension_, 180 | # skdim.id.MLE(k=5).fit(data).dimension_, 181 | # skdim.id.MLE(n = 20, sigma=.1, dnoise='dnoiseGaussH').fit(data).dimension_, 182 | # skdim.id.MLE(unbiased=True).fit(data).dimension_, 183 | # skdim.id.MLE(K=10, neighborhood_based=False).fit(data).dimension_, 184 | # skdim.id.MLE(neighborhood_aggregation='mean').fit(data).dimension_, 185 | # ), 186 | # (intdimr.maxLikGlobalDimEst(data,k=20)[0][0], 187 | # intdimr.maxLikGlobalDimEst(data,k=5)[0][0], 188 | # intdimr.maxLikGlobalDimEst(data,k=20,n = 20, sigma=.1, dnoise='dnoiseGaussH')[0][0], 189 | # intdimr.maxLikGlobalDimEst(data,k=20,unbiased=True)[0][0], 190 | # intdimr.maxLikGlobalDimEst(data,k=20,K=10, neighborhood_based=False)[0][0], 191 | # intdimr.maxLikGlobalDimEst(data,k=20,neighborhood_aggregation='mean')[0][0] 192 | # ) 193 | # ) 194 | assert np.allclose( 195 | ( 196 | skdim.id.MLE().fit(data).dimension_, 197 | skdim.id.MLE().fit(data, n_neighbors=5).dimension_, 198 | skdim.id.MLE(n=20, sigma=0.1, dnoise="dnoiseGaussH").fit(data).dimension_, 199 | skdim.id.MLE(unbiased=True).fit(data).dimension_, 200 | skdim.id.MLE(K=10, neighborhood_based=False).fit(data).dimension_, 201 | skdim.id.MLE().fit(data, comb="mean").dimension_, 202 | ), 203 | ( 204 | 3.341161830518472, 205 | 4.350132038093711, 206 | 3.2755228756927455, 207 | 3.1653112078596046, 208 | 5.312292926569348, 209 | 3.4389424541367437, 210 | ), 211 | ) 212 | 213 | 214 | def test_tle_results(data): 215 | # assert np.allclose(np.round(skdim.id.TLE().fit(data).dimension_,4),radovanovic_estimators_matlab(data,k=20)['id_tle']) 216 | assert np.allclose( 217 | np.round(skdim.id.TLE().fit(data).dimension_pw_, 4), 218 | np.array( 219 | [ 220 | 3.1975, 221 | 3.0745, 222 | 3.0447, 223 | 3.3422, 224 | 2.9231, 225 | 3.7637, 226 | 2.9517, 227 | 3.2285, 228 | 3.8731, 229 | 2.9633, 230 | 3.2595, 231 | 4.1404, 232 | 3.1353, 233 | 3.671, 234 | 3.6847, 235 | 3.9358, 236 | 3.9902, 237 | 3.7741, 238 | 3.5728, 239 | 4.2938, 240 | 4.2238, 241 | 3.9431, 242 | 3.0891, 243 | 3.4052, 244 | 4.0238, 245 | 4.7747, 246 | 3.9094, 247 | 4.9064, 248 | 4.0431, 249 | 3.4192, 250 | ] 251 | ), 252 | ) 253 | 254 | 255 | def test_twonn_results(data): 256 | # to trigger the "n_features>25 condition" 257 | test_high_dim = np.zeros((len(data), 30)) 258 | test_high_dim[:, : data.shape[1]] = data 259 | assert all( 260 | ( 261 | np.round(skdim.id.TwoNN().fit(test_high_dim).dimension_, 5) == 4.05496, 262 | np.round(skdim.id.TwoNN(discard_fraction=0.05).fit(data).dimension_, 5) 263 | == 4.11323, 264 | ) 265 | ) 266 | -------------------------------------------------------------------------------- /skdim/id/_PCA.py: -------------------------------------------------------------------------------- 1 | # 2 | # BSD 3-Clause License 3 | # 4 | # Copyright (c) 2020, Jonathan Bac 5 | # All rights reserved. 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, this 11 | # list of conditions and the following disclaimer. 12 | # 13 | # 2. Redistributions in binary form must reproduce the above copyright notice, 14 | # this list of conditions and the following disclaimer in the documentation 15 | # and/or other materials provided with the distribution. 16 | # 17 | # 3. Neither the name of the copyright holder nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | import numpy as np 33 | from sklearn.decomposition import PCA 34 | from sklearn.utils.validation import check_array 35 | from .._commonfuncs import GlobalEstimator 36 | 37 | 38 | class lPCA(GlobalEstimator): 39 | # SPDX-License-Identifier: MIT, 2017 Kerstin Johnsson [IDJohnsson]_ 40 | """Intrinsic dimension estimation using the PCA algorithm. [Cangelosi2007]_ [Fan2010]_ [Fukunaga2010]_ [IDJohnsson]_ 41 | 42 | Version 'FO' (Fukunaga-Olsen) returns eigenvalues larger than alphaFO times the largest eigenvalue.\n 43 | Version 'Fan' is the method by Fan et al.\n 44 | Version 'maxgap' returns the position of the largest relative gap in the sequence of eigenvalues.\n 45 | Version 'ratio' returns the number of eigenvalues needed to retain at least alphaRatio of the variance.\n 46 | Version 'participation_ratio' returns the number of eigenvalues given by PR=sum(eigenvalues)^2/sum(eigenvalues^2)\n 47 | Version 'Kaiser' returns the number of eigenvalues above average (the average eigenvalue is 1)\n 48 | Version 'broken_stick' returns the number of eigenvalues above corresponding values of the broken stick distribution\n 49 | 50 | Parameters 51 | ---------- 52 | ver: str, default='FO' 53 | Version. Possible values: 'FO', 'Fan', 'maxgap','ratio', 'Kaiser', 'broken_stick'. 54 | alphaRatio: float in (0,1) 55 | Only for ver = 'ratio'. ID is estimated to be 56 | the number of principal components needed to retain at least alphaRatio of the variance. 57 | alphaFO: float in (0,1) 58 | Only for ver = 'FO'. An eigenvalue is considered significant 59 | if it is larger than alpha times the largest eigenvalue. 60 | alphaFan: float 61 | Only for ver = 'Fan'. The alpha parameter (large gap threshold). 62 | betaFan: float 63 | Only for ver = 'Fan'. The beta parameter (total covariance threshold). 64 | PFan: float 65 | Only for ver = 'Fan'. Total covariance in non-noise. 66 | verbose: bool, default=False 67 | explained_variance: bool, default=False 68 | If True, lPCA.fit(X) expects as input 69 | a precomputed explained_variance vector: X = sklearn.decomposition.PCA().fit(X).explained_variance_ 70 | 71 | Attributes 72 | ---------- 73 | gap_: 74 | Ratio of each PC's explained variance (except the last) 75 | with the following PC's explained variance 76 | """ 77 | 78 | def __init__( 79 | self, 80 | ver="FO", 81 | alphaRatio=0.05, 82 | alphaFO=0.05, 83 | alphaFan=10, 84 | betaFan=0.8, 85 | PFan=0.95, 86 | verbose=True, 87 | fit_explained_variance=False, 88 | ): 89 | self.ver = ver 90 | self.alphaRatio = alphaRatio 91 | self.alphaFO = alphaFO 92 | self.alphaFan = alphaFan 93 | self.betaFan = betaFan 94 | self.PFan = PFan 95 | self.verbose = verbose 96 | self.fit_explained_variance = fit_explained_variance 97 | 98 | def fit(self, X, y=None): 99 | """A reference implementation of a fitting function. 100 | 101 | Parameters 102 | ---------- 103 | X : {array-like}, shape (n_samples, n_features) 104 | A local dataset of training input samples. 105 | y : dummy parameter to respect the sklearn API 106 | 107 | Returns 108 | ------- 109 | self : object 110 | Returns self. 111 | """ 112 | if self.fit_explained_variance: 113 | X = check_array(X, ensure_2d=False, ensure_min_samples=2) 114 | else: 115 | X = check_array(X, ensure_min_samples=2, ensure_min_features=2) 116 | 117 | self.dimension_, self.gap_ = self._pcaLocalDimEst(X) 118 | self.is_fitted_ = True 119 | # `fit` should always return `self` 120 | return self 121 | 122 | def _fit_once(self, X, y=None): 123 | """A reference implementation of a fitting function. 124 | Parameters 125 | ---------- 126 | X : {array-like}, shape (n_samples, n_features) 127 | A local dataset of training input samples. 128 | y : dummy parameter to respect the sklearn API 129 | 130 | Returns 131 | ------- 132 | self : object 133 | Returns self. 134 | """ 135 | if self.fit_explained_variance: 136 | X = check_array(X, ensure_2d=False, ensure_min_samples=2) 137 | else: 138 | X = check_array(X, ensure_min_samples=2, ensure_min_features=2) 139 | 140 | self.dimension_, self.gap_ = self._pcaLocalDimEst(X) 141 | self.is_fitted_ = True 142 | # `fit` should always return `self` 143 | return self 144 | 145 | def _pcaLocalDimEst(self, X): 146 | if self.fit_explained_variance: 147 | explained_var = X 148 | else: 149 | pca = PCA().fit(X) 150 | self.explained_var_ = explained_var = pca.explained_variance_ 151 | 152 | if self.ver == "FO": 153 | return self._FO(explained_var) 154 | elif self.ver == "Fan": 155 | return self._fan(explained_var) 156 | elif self.ver == "maxgap": 157 | return self._maxgap(explained_var) 158 | elif self.ver == "ratio": 159 | return self._ratio(explained_var) 160 | elif self.ver == "participation_ratio": 161 | return self._participation_ratio(explained_var) 162 | elif self.ver == "Kaiser": 163 | return self._Kaiser(explained_var) 164 | elif self.ver == "broken_stick": 165 | return self._broken_stick(explained_var) 166 | 167 | def _FO(self, explained_var): 168 | de = sum(explained_var > (self.alphaFO * explained_var[0])) 169 | gaps = explained_var[:-1] / explained_var[1:] 170 | return de, gaps 171 | 172 | 173 | @staticmethod 174 | def _maxgap(explained_var): 175 | gaps = explained_var[:-1] / explained_var[1:] 176 | de = np.nanargmax(gaps) + 1 177 | return de, gaps 178 | 179 | 180 | def _ratio(self, explained_var): 181 | sumexp = np.cumsum(explained_var) 182 | sumexp_norm = sumexp / np.max(sumexp) 183 | de = sum(sumexp_norm < self.alphaRatio) + 1 184 | gaps = explained_var[:-1] / explained_var[1:] 185 | return de, gaps 186 | 187 | 188 | def _participation_ratio(self, explained_var): 189 | PR = sum(explained_var) ** 2 / sum(explained_var ** 2) 190 | de = PR 191 | gaps = explained_var[:-1] / explained_var[1:] 192 | return de, gaps 193 | 194 | 195 | def _fan(self, explained_var): 196 | r = np.where(np.cumsum(explained_var) / sum(explained_var) > self.PFan)[0][0] 197 | sigma = np.mean(explained_var[r:]) 198 | explained_var -= sigma 199 | gaps = explained_var[:-1] / explained_var[1:] 200 | de = 1 + np.min( 201 | np.concatenate( 202 | ( 203 | np.where(gaps > self.alphaFan)[0], 204 | np.where( 205 | (np.cumsum(explained_var) / sum(explained_var)) > self.betaFan 206 | )[0], 207 | ) 208 | ) 209 | ) 210 | return de, gaps 211 | 212 | 213 | def _Kaiser(self, explained_var): 214 | de = sum(explained_var > np.mean(explained_var)) 215 | gaps = explained_var[:-1] / explained_var[1:] 216 | return de, gaps 217 | 218 | 219 | @staticmethod 220 | def _brokenstick_distribution(dim): 221 | distr = np.zeros(dim) 222 | for i in range(dim): 223 | for j in range(i, dim): 224 | distr[i] = distr[i] + 1 / (j + 1) 225 | distr[i] = distr[i] / dim 226 | return distr 227 | 228 | def _broken_stick(self, explained_var): 229 | bs = self._brokenstick_distribution(dim=len(explained_var)) 230 | gaps = explained_var[:-1] / explained_var[1:] 231 | de = 0 232 | explained_var_norm = explained_var / np.sum(explained_var) 233 | for i in range(len(explained_var)): 234 | if bs[i] > explained_var_norm[i]: 235 | de = i + 1 236 | break 237 | return de, gaps 238 | 239 | 240 | ##### dev in progress 241 | # from sklearn.cluster import KMeans 242 | # def pcaOtpmPointwiseDimEst(data, N, alpha = 0.05): 243 | # km = KMeans(n_clusters=N) 244 | # km.fit(data) 245 | # pt = km.cluster_centers_ 246 | # pt_bm = km.labels_ 247 | # pt_sm = np.repeat(np.nan, len(pt_bm)) 248 | # 249 | # for k in range(len(data)): 250 | # pt_sm[k] = np.argmin(lens(pt[[i for i in range(N) if i!=pt_bm[k]],:] - data[k,:])) 251 | # if (pt_sm[k] >= pt_bm[k]): 252 | # pt_sm[k] += 1 253 | # 254 | # de_c = np.repeat(np.nan, N) 255 | # nbr_nb_c = np.repeat(np.nan, N) 256 | # for k in range(N): 257 | # nb = np.unique(np.concatenate((pt_sm[pt_bm == k], pt_bm[pt_sm == k]))).astype(int) 258 | # nbr_nb_c[k] = len(nb) 259 | # loc_dat = pt[nb,:] - pt[k,:] 260 | # if len(loc_dat) == 1: 261 | # continue 262 | # de_c[k] = lPCA().fit(loc_dat).dimension_ #pcaLocalDimEst(loc_dat, ver = "FO", alphaFO = alpha) 263 | # 264 | # de = de_c[pt_bm] 265 | # nbr_nb = nbr_nb_c[pt_bm] 266 | # return de, nbr_nb 267 | --------------------------------------------------------------------------------