Metadata-Version: 2.1
Name: data-morph-ai
Version: 0.2.0
Summary: Teaching tool on the importance of data visualization.
Author-email: Stefanie Molin <24376333+stefmolin@users.noreply.github.com>, Aaron Stevens <bheklilr2@gmail.com>, Justin Matejka <Justin.Matejka@Autodesk.com>
Maintainer: Stefanie Molin
License: MIT License
        
        Copyright (c) 2017 jmatejka
        Copyright (c) 2023 Stefanie Molin
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://stefmolin.github.io/data-morph
Project-URL: Bug Tracker, https://github.com/stefmolin/data-morph/issues
Project-URL: Documentation, https://stefmolin.github.io/data-morph/stable/api.html
Project-URL: Source, https://github.com/stefmolin/data-morph
Keywords: data visualization,summary statistics,data animation
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Matplotlib
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib >=3.3
Requires-Dist: numpy >=1.20
Requires-Dist: pandas >=1.2
Requires-Dist: pytweening >=1.0.5
Requires-Dist: scipy >=1.10.0
Requires-Dist: tqdm >=4.64.1
Provides-Extra: dev
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: pytest-mock ; extra == 'dev'
Requires-Dist: pytest-randomly ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: pydata-sphinx-theme >=0.13.1 ; extra == 'docs'
Requires-Dist: sphinx >=7.2.1 ; extra == 'docs'
Requires-Dist: sphinx-argparse >=0.4.0 ; extra == 'docs'
Requires-Dist: sphinx-copybutton >=0.5.1 ; extra == 'docs'

<div align="center">
  <img alt="Data Morph" src="https://github.com/stefmolin/data-morph/raw/main/docs/_static/logo.png">

  <hr>

  <table>
   <tr>
     <td>
      <img alt="Last Release" src="https://img.shields.io/badge/last%20release-inactive?style=for-the-badge">
     </td>
     <td>
      <a href="https://stefmolin.github.io/data-morph" target="_blank" rel="noopener noreferrer">
        <img alt="View docs" src="https://img.shields.io/badge/docs-stable-success">
      </a>
      <a href="https://pypi.org/project/data-morph-ai/" target="_blank" rel="noopener noreferrer">
        <img alt="PyPI release" src="https://img.shields.io/pypi/v/data-morph-ai.svg">
      </a>
      <a href="https://anaconda.org/conda-forge/data-morph-ai" target="_blank" rel="noopener noreferrer">
        <img alt="conda-forge release" src="https://img.shields.io/conda/vn/conda-forge/data-morph-ai.svg">
      </a>
      <a href="https://pypi.org/project/data-morph-ai/" target="_blank" rel="noopener noreferrer">
        <img alt="Supported Python Versions" src="https://img.shields.io/pypi/pyversions/data-morph-ai">
      </a>
      <a href="https://github.com/stefmolin/data-morph/blob/main/LICENSE" target="_blank" rel="noopener noreferrer">
         <img alt="License" src="https://img.shields.io/pypi/l/data-morph-ai.svg?color=blueviolet">
      </a>
     </td>
   </tr>
   <tr>
     <td>
       <img alt="Citation information" src="https://img.shields.io/badge/for%20citation-inactive?style=for-the-badge">
   </td>
     <td>
      <a href="https://zenodo.org/badge/latestdoi/597895841" target="_blank" rel="noopener noreferrer">
        <img alt="DOI" src="https://zenodo.org/badge/597895841.svg">
      </a>
     </td>
   </tr>
   <tr>
     <td>
      <img alt="Build status" src="https://img.shields.io/badge/build%20status-inactive?style=for-the-badge">
     </td>
     <td>
      <a href="https://codecov.io/gh/stefmolin/data-morph" target="_blank" rel="noopener noreferrer">
        <img alt="codecov" src="https://codecov.io/gh/stefmolin/data-morph/branch/main/graph/badge.svg?token=3SEEG9SZQO">
      </a>
      <a href="https://github.com/stefmolin/data-morph/actions/workflows/ci.yml" target="_blank" rel="noopener noreferrer">
        <img alt="CI" src="https://github.com/stefmolin/data-morph/actions/workflows/ci.yml/badge.svg">
      </a>
      <a href="https://github.com/stefmolin/data-morph/actions/workflows/docs.yml" target="_blank" rel="noopener noreferrer">
        <img alt="Deploy Docs" src="https://github.com/stefmolin/data-morph/actions/workflows/docs.yml/badge.svg">
      </a>
     </td>
   </tr>
  </table>
  <hr/>
</div>

Data Morph transforms an input dataset of 2D points into select shapes, while preserving the summary statistics to a given number of decimal points through simulated annealing.

<div align="center">
  <img alt="Morphing the panda dataset into the star shape." src="https://raw.githubusercontent.com/stefmolin/data-morph/main/docs/_static/panda-to-star-eased.gif">
  <br/>
</div>

## Installation

Data Morph can be installed from PyPI using `pip`:

```console
$ pip install data-morph-ai
```

Alternatively, Data Morph can be installed with `conda` by specifying the `conda-forge` channel:

```console
$ conda install -c conda-forge data-morph-ai
```

## Usage

Once installed, Data Morph can be used on the command line or as an importable Python package. Below are some examples; be sure to check out the [documentation](https://stefmolin.github.io/data-morph) for more information.


### Command Line Usage

Run `data-morph` on the command line:

```console
$ data-morph --start-shape panda --target-shape star
```

This produces the animation in the newly-created `morphed_data` directory within your current working directory (shown above).

----

See all available CLI options by passing in `--help`:

```console
$ data-morph --help
```

### Python Usage

The `DataMorpher` class performs the morphing from a `Dataset` to a `Shape`. Any `pandas.DataFrame` with numeric columns `x` and `y` can be a `Dataset`. Use the `DataLoader` to create the `Dataset` from a file or use a built-in dataset:

```python
from data_morph.data.loader import DataLoader

dataset = DataLoader.load_dataset('panda')
```

For morphing purposes, all target shapes are placed/sized based on aspects of the `Dataset` class.
All shapes are accessible via the `ShapeFactory` class:

```python
from data_morph.shapes.factory import ShapeFactory

shape_factory = ShapeFactory(dataset)
target_shape = shape_factory.generate_shape('star')
```

With the `Dataset` and `Shape` created, here is a minimal example of morphing:

```python
from data_morph.morpher import DataMorpher

morpher = DataMorpher(
    decimals=2,
    in_notebook=False,  # whether you are running in a Jupyter Notebook
    output_dir='data_morph/output',
)

result = morpher.morph(start_shape=dataset, target_shape=target_shape)
```

Note that the `result` variable in the above code block is a `pandas.DataFrame` of the data after completing the specified iterations of the simulated annealing process. The `DataMorpher.morph()` method is also saving plots to visualize the output periodically and make an animation; these end up in `data_morph/output`, which we set as `DataMorpher.output_dir`.


----

In this example, we morphed the built-in panda `Dataset` into the star `Shape`. Be sure to try out the other built-in options:

* The `DataLoader.AVAILABLE_DATASETS` attribute contains a list of available datasets, which are also visualized in the `DataLoader` documentation.

* The `ShapeFactory.AVAILABLE_SHAPES` attribute contains a list of available shapes, which are also visualized in the `ShapeFactory` documentation.

## Acknowledgements

This code has been altered by Stefanie Molin ([@stefmolin](https://github.com/stefmolin)) to work for other input datasets by parameterizing the target shapes with information from the input shape. The original code works for a specific dataset called the "Datasaurus" and was created for the paper *Same Stats, Different Graphs: Generating Datasets with Varied Appearance and Identical Statistics through Simulated Annealing* by Justin Matejka and George Fitzmaurice (ACM CHI 2017).

The paper and video can be found on the Autodesk Research website [here](https://www.research.autodesk.com/publications/same-stats-different-graphs-generating-datasets-with-varied-appearance-and-identical-statistics-through-simulated-annealing/). The version of the code placed on GitHub at [jmatejka/same-stats-different-graphs](https://github.com/jmatejka/same-stats-different-graphs), served as the starting point for the Data Morph code base, which is on GitHub at [stefmolin/data-morph](https://github.com/stefmolin/data-morph).

Read more about the creation of Data Morph [here](https://medium.com/@stefaniemolin/data-morph-moving-beyond-the-datasaurus-dozen-156927b20f8c).

## Citations

If you use this software, please cite both Data Morph (DOI: [10.5281/zenodo.7834197](https://doi.org/10.5281/zenodo.7834197)) and *[Same Stats, Different Graphs: Generating Datasets with Varied Appearance and Identical Statistics through Simulated Annealing](https://damassets.autodesk.net/content/dam/autodesk/research/publications-assets/pdf/same-stats-different-graphs.pdf)* by Justin Matejka and George Fitzmaurice (ACM CHI 2017).
