Teaching tool on the importance of data visualization.
Project description
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. It is intended to be used as a teaching tool to illustrate the importance of data visualization (see the Data Morph in the Classroom section for ideas).
Installation
Data Morph can be installed from PyPI using pip:
$ python -m pip install data-morph-ai
Alternatively, Data Morph can be installed with conda by specifying the conda-forge channel:
$ 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 for more information.
Command Line Usage
Run data-morph on the command line:
$ 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). More examples, including how to run multiple transformations in parallel, can be found in the documentation.
See all available CLI options by passing in --help or consulting the CLI reference in the documentation:
$ 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:
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:
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:
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_DATASETSattribute contains a list of available datasets, which are also visualized in theDataLoaderdocumentation here. -
The
ShapeFactory.AVAILABLE_SHAPESattribute contains a list of available shapes, which are also visualized in theShapeFactorydocumentation here.
Data Morph in the Classroom
Data Morph is intended to be used as a teaching tool to illustrate the importance of data visualization. Here are some potential classroom activities for instructors:
- Statistics Focus: Have students pick one of the built-in datasets, and morph it into all available target shapes. Ask students to comment on which transformations worked best and why.
- Creativity Focus: Have students create a new dataset (e.g., your school logo or something that the student designs), and morph that into multiple target shapes. Ask students to comment on which transformations worked best and why.
- Math and Coding Focus: Have students create a custom shape by inheriting from
LineCollectionorPointCollection, and try morphing a couple of the built-in datasets into that shape. Ask students to explain how they chose to calculate the shape, and comment on which transformations worked best and why.
If you end up using Data Morph in your classroom, I would love to hear about it. Please send me a message detailing how you used it and how it went.
Acknowledgements
This code has been altered by Stefanie Molin (@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. The version of the code placed on GitHub at jmatejka/same-stats-different-graphs, served as the starting point for the Data Morph codebase, which is on GitHub at stefmolin/data-morph.
Read more about the creation of Data Morph here and here.
Citations
If you use this software, please cite both Data Morph (DOI: 10.5281/zenodo.7834197) and Same Stats, Different Graphs: Generating Datasets with Varied Appearance and Identical Statistics through Simulated Annealing by Justin Matejka and George Fitzmaurice (ACM CHI 2017).
Contributing
Please consult the contributing guidelines.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file data_morph_ai-0.3.1.tar.gz.
File metadata
- Download URL: data_morph_ai-0.3.1.tar.gz
- Upload date:
- Size: 11.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
721761e995895ec33f39e71581c8a3a58e76056f84d0f4b2a064fa3987f6557e
|
|
| MD5 |
8d56a89599384d29b13cfdaa0902ddbf
|
|
| BLAKE2b-256 |
7d042774e426a20dd8d79d2695042626564e382b01e50f899cfc1aa4c48b7155
|
Provenance
The following attestation bundles were made for data_morph_ai-0.3.1.tar.gz:
Publisher:
pypi-publish.yml on stefmolin/data-morph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
data_morph_ai-0.3.1.tar.gz -
Subject digest:
721761e995895ec33f39e71581c8a3a58e76056f84d0f4b2a064fa3987f6557e - Sigstore transparency entry: 213107602
- Sigstore integration time:
-
Permalink:
stefmolin/data-morph@a84464ee5c745d4f8869ea4d60a80a087adc09b7 -
Branch / Tag:
refs/tags/0.3.1 - Owner: https://github.com/stefmolin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@a84464ee5c745d4f8869ea4d60a80a087adc09b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file data_morph_ai-0.3.1-py3-none-any.whl.
File metadata
- Download URL: data_morph_ai-0.3.1-py3-none-any.whl
- Upload date:
- Size: 162.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f2442ba707edc263735816d1ea084d3355145cfdd1ce2af29b4db04e2be4933
|
|
| MD5 |
20b67142fb0679d2049067f20aeda96a
|
|
| BLAKE2b-256 |
be3f386bc8b2ef3d9fdbcda8a6e476cd99d687fc53b5def760cc5f2eb393e31b
|
Provenance
The following attestation bundles were made for data_morph_ai-0.3.1-py3-none-any.whl:
Publisher:
pypi-publish.yml on stefmolin/data-morph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
data_morph_ai-0.3.1-py3-none-any.whl -
Subject digest:
5f2442ba707edc263735816d1ea084d3355145cfdd1ce2af29b4db04e2be4933 - Sigstore transparency entry: 213107605
- Sigstore integration time:
-
Permalink:
stefmolin/data-morph@a84464ee5c745d4f8869ea4d60a80a087adc09b7 -
Branch / Tag:
refs/tags/0.3.1 - Owner: https://github.com/stefmolin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@a84464ee5c745d4f8869ea4d60a80a087adc09b7 -
Trigger Event:
push
-
Statement type: