dreimac


Namedreimac JSON
Version 0.3.1 PyPI version JSON
download
home_page
SummaryDREiMac: Dimensionality reduction with Eilenberg-MacLane coordinates
upload_time2023-11-15 12:45:04
maintainer
docs_urlNone
authorJose A. Perea, Luis Scoccola, Chris Tralie
requires_python>=3.8,<3.12
licenseApache2
keywords topological data analysis dimensionality reduction
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI version](https://badge.fury.io/py/dreimac.svg)](https://badge.fury.io/py/dreimac)
[![Downloads](https://static.pepy.tech/badge/dreimac)](https://pepy.tech/project/dreimac)
[![codecov](https://codecov.io/gh/scikit-tda/dreimac/branch/master/graph/badge.svg)](https://codecov.io/gh/scikit-tda/dreimac)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

# DREiMac: Dimensionality Reduction with Eilenberg-MacLane Coordinates

DREiMac is a library for topological data coordinatization, visualization, and dimensionality reduction.
Currently, DREiMac is able to find topology-preserving representations of point clouds taking values in the circle, in higher dimensional tori, in the real and complex projective space, and in lens spaces.

In a few words, DREiMac takes as input a point cloud together with a topological feature of the point cloud (in the form of a persistent cohomology class), and returns a map from the point cloud to a well-understood topological space (a circle, a product of circles, a projective space, or a lens space), which preserves the given topological feature in a precise sense.
For more information, please check the theory and examples in the [documentation](https://scikit-tda.org/DREiMac/index.html).


## Basic usage

Here is a simple example; please check the Jupyter notebooks in the `notebooks` directory for further examples.

```python
# basic imports
from dreimac import CircularCoords
from persim import plot_diagrams
import matplotlib.pyplot as plt
import numpy as np

# prepare plot with 4 subplots
f, (a0, a1, a2, a3) = plt.subplots(1, 4, width_ratios=[1, 1, 1, 0.2], figsize=(14,3))

# 200 samples from a noisy circle
n_samples = 200
np.random.seed(0)
Z = np.random.random((n_samples, 2)) - 0.5
X = Z / np.linalg.norm(Z, axis=1).reshape((n_samples, 1)) + (np.random.random((n_samples, 2)) - 0.5) * 0.2

# plot point cloud
a0.scatter(X[:,0], X[:,1], s=10)
a0.set_title("Input point cloud") ; a0.axis("off") ; a0.set_aspect("equal")

# plot the persistence diagram, showing a single prominent class
cc = CircularCoords(X, n_landmarks=200)
plot_diagrams(cc._dgms, title="Persistence diagram", ax=a1)

# plot the data colored by the circle-valued map constructed by DREiMac
circular_coordinates = cc.get_coordinates()
a2.scatter(X[:,0], X[:,1], c=circular_coordinates, s=10, cmap="viridis")
a2.set_title("Input colored by circular coordinate") ; a2.axis("off") ; a2.set_aspect("equal")

# plot colorbar
img = a3.imshow([[0,1]], cmap="viridis"); a3.set_visible(False)
cb = plt.colorbar(mappable=img,ticks=[0,0.5,1]) ; _ = cb.ax.set_yticklabels(["0","$\pi$","2$\pi$"])
```

![output](https://user-images.githubusercontent.com/1679929/232109124-bf2653e5-6f91-409d-b972-7104b96b3430.png)

## More examples

For Jupyter notebooks with more examples, please check the [documentation](https://scikit-tda.org/DREiMac/index.html) or this repository's [docs/notebooks](https://github.com/scikit-tda/DREiMac/tree/master/docs/notebooks) directory.

## Installing

Make sure your Python version is >=3.8 and <3.12.
DREiMac depends on the following python packages, which will be installed automatically when you install with pip:
`matplotlib`,
`numba`,
`numpy`,
`persim`,
`ripser`, and
`scipy`.

To install the latest release:

~~~~~ bash
pip install dreimac
~~~~~

To install directly from GitHub:

~~~~~ bash
pip install git+https://github.com/scikit-tda/DREiMac.git
~~~~~

## Documentation and support

You can find the documentation [here](https://scikit-tda.org/DREiMac/index.html), including the [API reference](https://scikit-tda.org/DREiMac/api.html).
If you have further questions, please [open an issue](https://github.com/scikit-tda/DREiMac/issues/new) and we will do our best to help you.
Please include as much information as possible, including your system's information, warnings, logs, screenshots, and anything else you think may be of use.

## Running the tests

If you want to check that your machine is running DREiMac properly, you may run the tests by running the following commands from the root directory of a clone of this repository.

```bash
pip install pytest
pip install -r requirements.txt
pytest .
```

## Contributing

To contribute, you can fork the project, make your changes, and submit a pull request.
If you're looking for a way to contribute, you could consider:
* adding documentation to existing functionality;
* adding missing tests to improve coverage;
* adding a Jupyter notebook with a tutorial or demo;
* adding functionality and the corresponding documentation and tests;
* responding to a bug or feature request in the Github issues.

## Authors

Jose A. Perea, Luis Scoccola, Chris Tralie

## Acknowledgements

We thank Tom Mease for contributions and discussions.

## License

This software is published under Apache License Version 2.0.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dreimac",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<3.12",
    "maintainer_email": "",
    "keywords": "topological data analysis,dimensionality reduction",
    "author": "Jose A. Perea, Luis Scoccola, Chris Tralie",
    "author_email": "ctralie@alumni.princeton.edu",
    "download_url": "https://files.pythonhosted.org/packages/f2/10/48ed6e548f481944fe5cb6e7324117cd2d6a657c4485b02e4ac2c0d0165e/dreimac-0.3.1.tar.gz",
    "platform": null,
    "description": "[![PyPI version](https://badge.fury.io/py/dreimac.svg)](https://badge.fury.io/py/dreimac)\n[![Downloads](https://static.pepy.tech/badge/dreimac)](https://pepy.tech/project/dreimac)\n[![codecov](https://codecov.io/gh/scikit-tda/dreimac/branch/master/graph/badge.svg)](https://codecov.io/gh/scikit-tda/dreimac)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n# DREiMac: Dimensionality Reduction with Eilenberg-MacLane Coordinates\n\nDREiMac is a library for topological data coordinatization, visualization, and dimensionality reduction.\nCurrently, DREiMac is able to find topology-preserving representations of point clouds taking values in the circle, in higher dimensional tori, in the real and complex projective space, and in lens spaces.\n\nIn a few words, DREiMac takes as input a point cloud together with a topological feature of the point cloud (in the form of a persistent cohomology class), and returns a map from the point cloud to a well-understood topological space (a circle, a product of circles, a projective space, or a lens space), which preserves the given topological feature in a precise sense.\nFor more information, please check the theory and examples in the [documentation](https://scikit-tda.org/DREiMac/index.html).\n\n\n## Basic usage\n\nHere is a simple example; please check the Jupyter notebooks in the `notebooks` directory for further examples.\n\n```python\n# basic imports\nfrom dreimac import CircularCoords\nfrom persim import plot_diagrams\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n# prepare plot with 4 subplots\nf, (a0, a1, a2, a3) = plt.subplots(1, 4, width_ratios=[1, 1, 1, 0.2], figsize=(14,3))\n\n# 200 samples from a noisy circle\nn_samples = 200\nnp.random.seed(0)\nZ = np.random.random((n_samples, 2)) - 0.5\nX = Z / np.linalg.norm(Z, axis=1).reshape((n_samples, 1)) + (np.random.random((n_samples, 2)) - 0.5) * 0.2\n\n# plot point cloud\na0.scatter(X[:,0], X[:,1], s=10)\na0.set_title(\"Input point cloud\") ; a0.axis(\"off\") ; a0.set_aspect(\"equal\")\n\n# plot the persistence diagram, showing a single prominent class\ncc = CircularCoords(X, n_landmarks=200)\nplot_diagrams(cc._dgms, title=\"Persistence diagram\", ax=a1)\n\n# plot the data colored by the circle-valued map constructed by DREiMac\ncircular_coordinates = cc.get_coordinates()\na2.scatter(X[:,0], X[:,1], c=circular_coordinates, s=10, cmap=\"viridis\")\na2.set_title(\"Input colored by circular coordinate\") ; a2.axis(\"off\") ; a2.set_aspect(\"equal\")\n\n# plot colorbar\nimg = a3.imshow([[0,1]], cmap=\"viridis\"); a3.set_visible(False)\ncb = plt.colorbar(mappable=img,ticks=[0,0.5,1]) ; _ = cb.ax.set_yticklabels([\"0\",\"$\\pi$\",\"2$\\pi$\"])\n```\n\n![output](https://user-images.githubusercontent.com/1679929/232109124-bf2653e5-6f91-409d-b972-7104b96b3430.png)\n\n## More examples\n\nFor Jupyter notebooks with more examples, please check the [documentation](https://scikit-tda.org/DREiMac/index.html) or this repository's [docs/notebooks](https://github.com/scikit-tda/DREiMac/tree/master/docs/notebooks) directory.\n\n## Installing\n\nMake sure your Python version is >=3.8 and <3.12.\nDREiMac depends on the following python packages, which will be installed automatically when you install with pip:\n`matplotlib`,\n`numba`,\n`numpy`,\n`persim`,\n`ripser`, and\n`scipy`.\n\nTo install the latest release:\n\n~~~~~ bash\npip install dreimac\n~~~~~\n\nTo install directly from GitHub:\n\n~~~~~ bash\npip install git+https://github.com/scikit-tda/DREiMac.git\n~~~~~\n\n## Documentation and support\n\nYou can find the documentation [here](https://scikit-tda.org/DREiMac/index.html), including the [API reference](https://scikit-tda.org/DREiMac/api.html).\nIf you have further questions, please [open an issue](https://github.com/scikit-tda/DREiMac/issues/new) and we will do our best to help you.\nPlease include as much information as possible, including your system's information, warnings, logs, screenshots, and anything else you think may be of use.\n\n## Running the tests\n\nIf you want to check that your machine is running DREiMac properly, you may run the tests by running the following commands from the root directory of a clone of this repository.\n\n```bash\npip install pytest\npip install -r requirements.txt\npytest .\n```\n\n## Contributing\n\nTo contribute, you can fork the project, make your changes, and submit a pull request.\nIf you're looking for a way to contribute, you could consider:\n* adding documentation to existing functionality;\n* adding missing tests to improve coverage;\n* adding a Jupyter notebook with a tutorial or demo;\n* adding functionality and the corresponding documentation and tests;\n* responding to a bug or feature request in the Github issues.\n\n## Authors\n\nJose A. Perea, Luis Scoccola, Chris Tralie\n\n## Acknowledgements\n\nWe thank Tom Mease for contributions and discussions.\n\n## License\n\nThis software is published under Apache License Version 2.0.\n",
    "bugtrack_url": null,
    "license": "Apache2",
    "summary": "DREiMac: Dimensionality reduction with Eilenberg-MacLane coordinates",
    "version": "0.3.1",
    "project_urls": null,
    "split_keywords": [
        "topological data analysis",
        "dimensionality reduction"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f5a671295316be11f68982211fa65912260cfc893db5fad8621c201e31880a78",
                "md5": "75140b7b3c95c03ac2e95150df7021c8",
                "sha256": "a862c3573925a474ac26a2e96545801fefe6bf5113a8bef8df4de288087a3209"
            },
            "downloads": -1,
            "filename": "dreimac-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "75140b7b3c95c03ac2e95150df7021c8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<3.12",
            "size": 36778,
            "upload_time": "2023-11-15T12:47:30",
            "upload_time_iso_8601": "2023-11-15T12:47:30.814579Z",
            "url": "https://files.pythonhosted.org/packages/f5/a6/71295316be11f68982211fa65912260cfc893db5fad8621c201e31880a78/dreimac-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f21048ed6e548f481944fe5cb6e7324117cd2d6a657c4485b02e4ac2c0d0165e",
                "md5": "e64b77f74b0bc600c20c134db03c77e8",
                "sha256": "0eb4858e6d431a954499c55c1bd0d70be9b07c34256d46d23890bd378eebc7f9"
            },
            "downloads": -1,
            "filename": "dreimac-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e64b77f74b0bc600c20c134db03c77e8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<3.12",
            "size": 34110,
            "upload_time": "2023-11-15T12:45:04",
            "upload_time_iso_8601": "2023-11-15T12:45:04.701949Z",
            "url": "https://files.pythonhosted.org/packages/f2/10/48ed6e548f481944fe5cb6e7324117cd2d6a657c4485b02e4ac2c0d0165e/dreimac-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-15 12:45:04",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dreimac"
}
        
Elapsed time: 0.17863s