data-formulator 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. data_formulator-0.1.2/LICENSE +21 -0
  2. data_formulator-0.1.2/MANIFEST.in +2 -0
  3. data_formulator-0.1.2/PKG-INFO +200 -0
  4. data_formulator-0.1.2/README.md +150 -0
  5. data_formulator-0.1.2/py-src/data_formulator/__init__.py +5 -0
  6. data_formulator-0.1.2/py-src/data_formulator/__main__.py +4 -0
  7. data_formulator-0.1.2/py-src/data_formulator/agents/__init__.py +22 -0
  8. data_formulator-0.1.2/py-src/data_formulator/agents/agent_code_explanation.py +92 -0
  9. data_formulator-0.1.2/py-src/data_formulator/agents/agent_concept_derive.py +217 -0
  10. data_formulator-0.1.2/py-src/data_formulator/agents/agent_data_clean.py +150 -0
  11. data_formulator-0.1.2/py-src/data_formulator/agents/agent_data_filter.py +197 -0
  12. data_formulator-0.1.2/py-src/data_formulator/agents/agent_data_load.py +173 -0
  13. data_formulator-0.1.2/py-src/data_formulator/agents/agent_data_rec.py +210 -0
  14. data_formulator-0.1.2/py-src/data_formulator/agents/agent_data_transform_v2.py +296 -0
  15. data_formulator-0.1.2/py-src/data_formulator/agents/agent_data_transformation.py +221 -0
  16. data_formulator-0.1.2/py-src/data_formulator/agents/agent_generic_py_concept.py +243 -0
  17. data_formulator-0.1.2/py-src/data_formulator/agents/agent_py_concept_derive.py +203 -0
  18. data_formulator-0.1.2/py-src/data_formulator/agents/agent_sort_data.py +116 -0
  19. data_formulator-0.1.2/py-src/data_formulator/agents/agent_utils.py +229 -0
  20. data_formulator-0.1.2/py-src/data_formulator/agents/client_utils.py +35 -0
  21. data_formulator-0.1.2/py-src/data_formulator/app.py +461 -0
  22. data_formulator-0.1.2/py-src/data_formulator/dist/DataFormulator.js +1906 -0
  23. data_formulator-0.1.2/py-src/data_formulator/dist/assets/chart-icon-custom-point-D9Pkojxu.png +0 -0
  24. data_formulator-0.1.2/py-src/data_formulator/dist/assets/chart-icon-dot-plot-horizontal-DKFCuGMg.png +0 -0
  25. data_formulator-0.1.2/py-src/data_formulator/dist/assets/chart-icon-dotted-line-iiUsajLi.png +0 -0
  26. data_formulator-0.1.2/py-src/data_formulator/dist/assets/chart-icon-line-k93XJJqK.png +0 -0
  27. data_formulator-0.1.2/py-src/data_formulator/dist/assets/chart-icon-linear-regression-B2oG00j-.png +0 -0
  28. data_formulator-0.1.2/py-src/data_formulator/dist/assets/chart-icon-scatter-CrRD3gQ6.png +0 -0
  29. data_formulator-0.1.2/py-src/data_formulator/dist/assets/df-logo-DfhqzchR.png +0 -0
  30. data_formulator-0.1.2/py-src/data_formulator/dist/assets/example-image-table-Dt9uSzww.png +0 -0
  31. data_formulator-0.1.2/py-src/data_formulator/dist/assets/index-XIyIzJet.css +1 -0
  32. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-all-300-normal-Ds3nfeLf.woff +0 -0
  33. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-all-400-normal-f4MUuuLv.woff +0 -0
  34. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-all-500-normal-DDdyfEVV.woff +0 -0
  35. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-all-700-normal-3dkacwT9.woff +0 -0
  36. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-cyrillic-300-normal-BOy--GS2.woff2 +0 -0
  37. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-cyrillic-400-normal-BWCKIajk.woff2 +0 -0
  38. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-cyrillic-500-normal-DPqBUHAx.woff2 +0 -0
  39. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-cyrillic-700-normal-CPtRbep5.woff2 +0 -0
  40. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-cyrillic-ext-300-normal-Cd-WzVcx.woff2 +0 -0
  41. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-cyrillic-ext-400-normal-DjuvKb_P.woff2 +0 -0
  42. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-cyrillic-ext-500-normal-V1HAW4zQ.woff2 +0 -0
  43. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-cyrillic-ext-700-normal-C9lmAwgy.woff2 +0 -0
  44. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-greek-300-normal-C16gQb3f.woff2 +0 -0
  45. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-greek-400-normal-DuywzvlP.woff2 +0 -0
  46. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-greek-500-normal-SYDpG7Yn.woff2 +0 -0
  47. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-greek-700-normal-DD0cEo49.woff2 +0 -0
  48. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-latin-300-normal-MgpfczZf.woff2 +0 -0
  49. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-latin-400-normal-DeojfH1t.woff2 +0 -0
  50. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-latin-500-normal-C1mc9L83.woff2 +0 -0
  51. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-latin-700-normal-GvK2Ggwj.woff2 +0 -0
  52. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-latin-ext-300-normal-6MJ3uiaw.woff2 +0 -0
  53. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-latin-ext-400-normal-DXUWhv3T.woff2 +0 -0
  54. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-latin-ext-500-normal-D5yZxhUJ.woff2 +0 -0
  55. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-latin-ext-700-normal-DGCUpLqw.woff2 +0 -0
  56. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-vietnamese-300-normal-I8f0-PPn.woff2 +0 -0
  57. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-vietnamese-400-normal-DUA88K9g.woff2 +0 -0
  58. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-vietnamese-500-normal-C1Ol7oNW.woff2 +0 -0
  59. data_formulator-0.1.2/py-src/data_formulator/dist/assets/roboto-vietnamese-700-normal-Cz5viwFU.woff2 +0 -0
  60. data_formulator-0.1.2/py-src/data_formulator/dist/data-formulator-screenshot.png +0 -0
  61. data_formulator-0.1.2/py-src/data_formulator/dist/favicon.ico +0 -0
  62. data_formulator-0.1.2/py-src/data_formulator/dist/index.html +33 -0
  63. data_formulator-0.1.2/py-src/data_formulator/dist/load-data.mp4 +0 -0
  64. data_formulator-0.1.2/py-src/data_formulator/dist/manifest.json +15 -0
  65. data_formulator-0.1.2/py-src/data_formulator/dist/renewable-pct.mp4 +0 -0
  66. data_formulator-0.1.2/py-src/data_formulator/dist/renewable-rank.mp4 +0 -0
  67. data_formulator-0.1.2/py-src/data_formulator/dist/renewable.mp4 +0 -0
  68. data_formulator-0.1.2/py-src/data_formulator/dist/robots.txt +3 -0
  69. data_formulator-0.1.2/py-src/data_formulator/py_sandbox.py +143 -0
  70. data_formulator-0.1.2/py-src/data_formulator.egg-info/PKG-INFO +200 -0
  71. data_formulator-0.1.2/py-src/data_formulator.egg-info/SOURCES.txt +75 -0
  72. data_formulator-0.1.2/py-src/data_formulator.egg-info/dependency_links.txt +1 -0
  73. data_formulator-0.1.2/py-src/data_formulator.egg-info/entry_points.txt +2 -0
  74. data_formulator-0.1.2/py-src/data_formulator.egg-info/requires.txt +13 -0
  75. data_formulator-0.1.2/py-src/data_formulator.egg-info/top_level.txt +1 -0
  76. data_formulator-0.1.2/pyproject.toml +49 -0
  77. data_formulator-0.1.2/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
@@ -0,0 +1,2 @@
1
+ include py-src/data_formulator/dist/*
2
+ include py-src/data_formulator/dist/assets/*
@@ -0,0 +1,200 @@
1
+ Metadata-Version: 2.1
2
+ Name: data_formulator
3
+ Version: 0.1.2
4
+ Summary: Data Formulator is research protoype data visualization tool powered by AI.
5
+ Author-email: Chenglong Wang <chenglong.wang@microsoft.com>, Dan Marshall <danmar@microsoft.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE
27
+
28
+ Project-URL: Homepage, https://github.com/microsoft/data-formulator
29
+ Project-URL: Repository, https://github.com/microsoft/data-formulator.git
30
+ Project-URL: Bug Tracker, https://github.com/microsoft/data-formulator/issues
31
+ Keywords: data visualization,LLM,AI
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Programming Language :: Python
34
+ Requires-Python: >=3.9
35
+ Description-Content-Type: text/markdown
36
+ License-File: LICENSE
37
+ Requires-Dist: autopep8
38
+ Requires-Dist: jupyter
39
+ Requires-Dist: pandas
40
+ Requires-Dist: docker
41
+ Requires-Dist: namedlist
42
+ Requires-Dist: matplotlib
43
+ Requires-Dist: flask
44
+ Requires-Dist: flask-cors
45
+ Requires-Dist: openai
46
+ Requires-Dist: azure-identity
47
+ Requires-Dist: azure-keyvault-secrets
48
+ Requires-Dist: python-dotenv
49
+ Requires-Dist: vega_datasets
50
+
51
+ <h1>
52
+ <img src="./public/favicon.ico" alt="Data Formulator icon" width="28"> <b>Data Formulator: Create Rich Visualizations with AI</b>
53
+ </h1>
54
+
55
+ <div>
56
+
57
+ [![arxiv](https://img.shields.io/badge/Paper-arXiv:2408.16119-b31b1b.svg)](https://arxiv.org/abs/2408.16119)&ensp;
58
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)&ensp;
59
+ [![YouTube](https://img.shields.io/badge/YouTube-white?logo=youtube&logoColor=%23FF0000)](https://youtu.be/3ndlwt0Wi3c)&ensp;
60
+ [![build](https://github.com/microsoft/data-formulator/actions/workflows/python-build.yml/badge.svg)](https://github.com/microsoft/data-formulator/actions/workflows/python-build.yml)
61
+
62
+ </div>
63
+
64
+ Transform data and create rich visualizations iteratively with AI 🪄. Try Data Formulator now in GitHub Codespaces!
65
+
66
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/data-formulator?quickstart=1)
67
+
68
+ <kbd>
69
+ <a target="_blank" rel="noopener noreferrer" href="https://codespaces.new/microsoft/data-formulator?quickstart=1" title="open Data Formulator in GitHub Codespaces"><img src="public/data-formulator-screenshot.png"></a>
70
+ </kbd>
71
+
72
+
73
+ ## News 🔥🔥🔥
74
+
75
+ - [10-11-2024] Data Formulator python package released!
76
+ - You can now install Data Formulator using Python and run it locally, easily. [[check it out]](#get-started).
77
+ - Our Codespace configuration is also updated for fast start up ⚡️. [[try it now!]](https://codespaces.new/microsoft/data-formulator?quickstart=1)
78
+ - New exprimental feature: load an image or a messy text, and ask AI parsing and cleaning it for you(!). [[demo]](https://github.com/microsoft/data-formulator/pull/31#issuecomment-2403652717)
79
+
80
+ - [10-01-2024] Initial release of Data Formulator, check out our [[blog]](https://www.microsoft.com/en-us/research/blog/data-formulator-exploring-how-ai-can-help-analysts-create-rich-data-visualizations/) and [[video]](https://youtu.be/3ndlwt0Wi3c)!
81
+
82
+
83
+
84
+ ## Overview
85
+
86
+ **Data Formulator** is an application from Microsoft Research that uses large language models to transform data, expediting the practice of data visualization.
87
+
88
+ Data Formulator is an AI-powered tool for analysts to iteratively create rich visualizations. Unlike most chat-based AI tools where users need to describe everything in natural language, Data Formulator combines *user interface interactions (UI)* and *natural language (NL) inputs* for easier interaction. This blended approach makes it easier for users to describe their chart designs while delegating data transformation to AI.
89
+
90
+ ## Get Started
91
+
92
+ Play with Data Formulator with one of the following options:
93
+
94
+ - **Option 1: Install via Python PIP**
95
+
96
+ Use Python PIP for an easy setup experience, running locally (recommend: install it in a virtual environment).
97
+
98
+ ```bash
99
+ # install data_formulator
100
+ pip install data_formulator
101
+
102
+ # start data_formulator
103
+ data_formulator
104
+
105
+ # alternatively, you can run data formualtor with this command
106
+ python -m data_formulator
107
+ ```
108
+
109
+ Data Formulator will be automatically opened in the browser at [http://localhost:5000](http://localhost:5000).
110
+
111
+ - **Option 2: Codespaces (5 minutes)**
112
+
113
+ You can also run Data Formualtor in codespace, we have everything pre-configured. For more details, see [CODESPACES.md](CODESPACES.md).
114
+
115
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/data-formulator?quickstart=1)
116
+
117
+ - **Option 3: Working in the developer mode**
118
+
119
+ You can build Data Formulator locally if you prefer full control over your development environment and the ability to customize the setup to your specific needs. For detailed instructions, refer to [DEVELOPMENT.md](DEVELOPMENT.md).
120
+
121
+
122
+ ## Using Data Formulator
123
+
124
+ Once you’ve completed the setup using either option, follow these steps to start using Data Formulator:
125
+
126
+ ### The basics of data visualization
127
+ * Provide OpenAI keys and select a model (GPT-4o suggested) and choose a dataset.
128
+ * Choose a chart type, and then drag-and-drop data fields to chart properties (x, y, color, ...) to specify visual encodings.
129
+
130
+ https://github.com/user-attachments/assets/0fbea012-1d2d-46c3-a923-b1fc5eb5e5b8
131
+
132
+
133
+ ### Create visualization beyond the initial dataset (powered by 🤖)
134
+ * You can type names of **fields that do not exist in current data** in the encoding shelf:
135
+ - this tells Data Formulator that you want to create visualizions that require computation or transformation from existing data,
136
+ - you can optionally provide a natural language prompt to explain your intent to clarify your intent (not necessary when field names are self-explanatory).
137
+ * Click the **Formulate** button.
138
+ - Data Formulator will transform data and instantiate the visualization based on the encoding and prompt.
139
+ * Inspect the data, chart and code.
140
+ * To create a new chart based on existing ones, follow up in natural language:
141
+ - provide a follow up prompt (e.g., *``show only top 5!''*),
142
+ - you may also update visual encodings for the new chart.
143
+
144
+ https://github.com/user-attachments/assets/160c69d2-f42d-435c-9ff3-b1229b5bddba
145
+
146
+ https://github.com/user-attachments/assets/c93b3e84-8ca8-49ae-80ea-f91ceef34acb
147
+
148
+ Repeat this process as needed to explore and understand your data. Your explorations are trackable in the **Data Threads** panel.
149
+
150
+ ## Developers' Guide
151
+
152
+ Follow the [developers' instructions](DEVELOPMENT.md) to build your new data analysis tools on top of Data Formulator.
153
+
154
+ ## Research Papers
155
+ * [Data Formulator 2: Iteratively Creating Rich Visualizations with AI](https://arxiv.org/abs/2408.16119)
156
+
157
+ ```
158
+ @article{wang2024dataformulator2iteratively,
159
+ title={Data Formulator 2: Iteratively Creating Rich Visualizations with AI},
160
+ author={Chenglong Wang and Bongshin Lee and Steven Drucker and Dan Marshall and Jianfeng Gao},
161
+ year={2024},
162
+ booktitle={ArXiv preprint arXiv:2408.16119},
163
+ }
164
+ ```
165
+
166
+ * [Data Formulator: AI-powered Concept-driven Visualization Authoring](https://arxiv.org/abs/2309.10094)
167
+
168
+ ```
169
+ @article{wang2023data,
170
+ title={Data Formulator: AI-powered Concept-driven Visualization Authoring},
171
+ author={Wang, Chenglong and Thompson, John and Lee, Bongshin},
172
+ journal={IEEE Transactions on Visualization and Computer Graphics},
173
+ year={2023},
174
+ publisher={IEEE}
175
+ }
176
+ ```
177
+
178
+
179
+ ## Contributing
180
+
181
+ This project welcomes contributions and suggestions. Most contributions require you to
182
+ agree to a Contributor License Agreement (CLA) declaring that you have the right to,
183
+ and actually do, grant us the rights to use your contribution. For details, visit
184
+ https://cla.microsoft.com.
185
+
186
+ When you submit a pull request, a CLA-bot will automatically determine whether you need
187
+ to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
188
+ instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
189
+
190
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
191
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
192
+ or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
193
+
194
+ ## Trademarks
195
+
196
+ This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
197
+ trademarks or logos is subject to and must follow
198
+ [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
199
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
200
+ Any use of third-party trademarks or logos are subject to those third-party's policies.
@@ -0,0 +1,150 @@
1
+ <h1>
2
+ <img src="./public/favicon.ico" alt="Data Formulator icon" width="28"> <b>Data Formulator: Create Rich Visualizations with AI</b>
3
+ </h1>
4
+
5
+ <div>
6
+
7
+ [![arxiv](https://img.shields.io/badge/Paper-arXiv:2408.16119-b31b1b.svg)](https://arxiv.org/abs/2408.16119)&ensp;
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)&ensp;
9
+ [![YouTube](https://img.shields.io/badge/YouTube-white?logo=youtube&logoColor=%23FF0000)](https://youtu.be/3ndlwt0Wi3c)&ensp;
10
+ [![build](https://github.com/microsoft/data-formulator/actions/workflows/python-build.yml/badge.svg)](https://github.com/microsoft/data-formulator/actions/workflows/python-build.yml)
11
+
12
+ </div>
13
+
14
+ Transform data and create rich visualizations iteratively with AI 🪄. Try Data Formulator now in GitHub Codespaces!
15
+
16
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/data-formulator?quickstart=1)
17
+
18
+ <kbd>
19
+ <a target="_blank" rel="noopener noreferrer" href="https://codespaces.new/microsoft/data-formulator?quickstart=1" title="open Data Formulator in GitHub Codespaces"><img src="public/data-formulator-screenshot.png"></a>
20
+ </kbd>
21
+
22
+
23
+ ## News 🔥🔥🔥
24
+
25
+ - [10-11-2024] Data Formulator python package released!
26
+ - You can now install Data Formulator using Python and run it locally, easily. [[check it out]](#get-started).
27
+ - Our Codespace configuration is also updated for fast start up ⚡️. [[try it now!]](https://codespaces.new/microsoft/data-formulator?quickstart=1)
28
+ - New exprimental feature: load an image or a messy text, and ask AI parsing and cleaning it for you(!). [[demo]](https://github.com/microsoft/data-formulator/pull/31#issuecomment-2403652717)
29
+
30
+ - [10-01-2024] Initial release of Data Formulator, check out our [[blog]](https://www.microsoft.com/en-us/research/blog/data-formulator-exploring-how-ai-can-help-analysts-create-rich-data-visualizations/) and [[video]](https://youtu.be/3ndlwt0Wi3c)!
31
+
32
+
33
+
34
+ ## Overview
35
+
36
+ **Data Formulator** is an application from Microsoft Research that uses large language models to transform data, expediting the practice of data visualization.
37
+
38
+ Data Formulator is an AI-powered tool for analysts to iteratively create rich visualizations. Unlike most chat-based AI tools where users need to describe everything in natural language, Data Formulator combines *user interface interactions (UI)* and *natural language (NL) inputs* for easier interaction. This blended approach makes it easier for users to describe their chart designs while delegating data transformation to AI.
39
+
40
+ ## Get Started
41
+
42
+ Play with Data Formulator with one of the following options:
43
+
44
+ - **Option 1: Install via Python PIP**
45
+
46
+ Use Python PIP for an easy setup experience, running locally (recommend: install it in a virtual environment).
47
+
48
+ ```bash
49
+ # install data_formulator
50
+ pip install data_formulator
51
+
52
+ # start data_formulator
53
+ data_formulator
54
+
55
+ # alternatively, you can run data formualtor with this command
56
+ python -m data_formulator
57
+ ```
58
+
59
+ Data Formulator will be automatically opened in the browser at [http://localhost:5000](http://localhost:5000).
60
+
61
+ - **Option 2: Codespaces (5 minutes)**
62
+
63
+ You can also run Data Formualtor in codespace, we have everything pre-configured. For more details, see [CODESPACES.md](CODESPACES.md).
64
+
65
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/data-formulator?quickstart=1)
66
+
67
+ - **Option 3: Working in the developer mode**
68
+
69
+ You can build Data Formulator locally if you prefer full control over your development environment and the ability to customize the setup to your specific needs. For detailed instructions, refer to [DEVELOPMENT.md](DEVELOPMENT.md).
70
+
71
+
72
+ ## Using Data Formulator
73
+
74
+ Once you’ve completed the setup using either option, follow these steps to start using Data Formulator:
75
+
76
+ ### The basics of data visualization
77
+ * Provide OpenAI keys and select a model (GPT-4o suggested) and choose a dataset.
78
+ * Choose a chart type, and then drag-and-drop data fields to chart properties (x, y, color, ...) to specify visual encodings.
79
+
80
+ https://github.com/user-attachments/assets/0fbea012-1d2d-46c3-a923-b1fc5eb5e5b8
81
+
82
+
83
+ ### Create visualization beyond the initial dataset (powered by 🤖)
84
+ * You can type names of **fields that do not exist in current data** in the encoding shelf:
85
+ - this tells Data Formulator that you want to create visualizions that require computation or transformation from existing data,
86
+ - you can optionally provide a natural language prompt to explain your intent to clarify your intent (not necessary when field names are self-explanatory).
87
+ * Click the **Formulate** button.
88
+ - Data Formulator will transform data and instantiate the visualization based on the encoding and prompt.
89
+ * Inspect the data, chart and code.
90
+ * To create a new chart based on existing ones, follow up in natural language:
91
+ - provide a follow up prompt (e.g., *``show only top 5!''*),
92
+ - you may also update visual encodings for the new chart.
93
+
94
+ https://github.com/user-attachments/assets/160c69d2-f42d-435c-9ff3-b1229b5bddba
95
+
96
+ https://github.com/user-attachments/assets/c93b3e84-8ca8-49ae-80ea-f91ceef34acb
97
+
98
+ Repeat this process as needed to explore and understand your data. Your explorations are trackable in the **Data Threads** panel.
99
+
100
+ ## Developers' Guide
101
+
102
+ Follow the [developers' instructions](DEVELOPMENT.md) to build your new data analysis tools on top of Data Formulator.
103
+
104
+ ## Research Papers
105
+ * [Data Formulator 2: Iteratively Creating Rich Visualizations with AI](https://arxiv.org/abs/2408.16119)
106
+
107
+ ```
108
+ @article{wang2024dataformulator2iteratively,
109
+ title={Data Formulator 2: Iteratively Creating Rich Visualizations with AI},
110
+ author={Chenglong Wang and Bongshin Lee and Steven Drucker and Dan Marshall and Jianfeng Gao},
111
+ year={2024},
112
+ booktitle={ArXiv preprint arXiv:2408.16119},
113
+ }
114
+ ```
115
+
116
+ * [Data Formulator: AI-powered Concept-driven Visualization Authoring](https://arxiv.org/abs/2309.10094)
117
+
118
+ ```
119
+ @article{wang2023data,
120
+ title={Data Formulator: AI-powered Concept-driven Visualization Authoring},
121
+ author={Wang, Chenglong and Thompson, John and Lee, Bongshin},
122
+ journal={IEEE Transactions on Visualization and Computer Graphics},
123
+ year={2023},
124
+ publisher={IEEE}
125
+ }
126
+ ```
127
+
128
+
129
+ ## Contributing
130
+
131
+ This project welcomes contributions and suggestions. Most contributions require you to
132
+ agree to a Contributor License Agreement (CLA) declaring that you have the right to,
133
+ and actually do, grant us the rights to use your contribution. For details, visit
134
+ https://cla.microsoft.com.
135
+
136
+ When you submit a pull request, a CLA-bot will automatically determine whether you need
137
+ to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
138
+ instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
139
+
140
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
141
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
142
+ or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
143
+
144
+ ## Trademarks
145
+
146
+ This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
147
+ trademarks or logos is subject to and must follow
148
+ [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
149
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
150
+ Any use of third-party trademarks or logos are subject to those third-party's policies.
@@ -0,0 +1,5 @@
1
+ from .app import run_app
2
+
3
+ __all__ = [
4
+ "run_app",
5
+ ]
@@ -0,0 +1,4 @@
1
+ from .app import run_app
2
+
3
+ if __name__ == "__main__":
4
+ run_app()
@@ -0,0 +1,22 @@
1
+ # Copyright (c) Microsoft Corporation.
2
+ # Licensed under the MIT License.
3
+
4
+ from data_formulator.agents.agent_concept_derive import ConceptDeriveAgent
5
+ from data_formulator.agents.agent_py_concept_derive import PyConceptDeriveAgent
6
+ from data_formulator.agents.agent_data_transformation import DataTransformationAgent
7
+ from data_formulator.agents.agent_data_transform_v2 import DataTransformationAgentV2
8
+ from data_formulator.agents.agent_data_load import DataLoadAgent
9
+ from data_formulator.agents.agent_sort_data import SortDataAgent
10
+ from data_formulator.agents.agent_data_clean import DataCleanAgent
11
+ from data_formulator.agents.agent_data_rec import DataRecAgent
12
+
13
+ __all__ = [
14
+ "ConceptDeriveAgent",
15
+ "PyConceptDeriveAgent",
16
+ "DataTransformationAgent",
17
+ "DataTransformationAgentV2",
18
+ "DataRecAgent",
19
+ "DataLoadAgent",
20
+ "SortDataAgent",
21
+ "DataCleanAgent"
22
+ ]
@@ -0,0 +1,92 @@
1
+ # Copyright (c) Microsoft Corporation.
2
+ # Licensed under the MIT License.
3
+
4
+ import pandas as pd
5
+ from data_formulator.agents.agent_utils import generate_data_summary, extract_code_from_gpt_response
6
+
7
+ import logging
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+
12
+ SYSTEM_PROMPT = '''You are a data scientist to help user explain code,
13
+ so that a non-code can clearly understand what the code is doing, you are provided with a summary of the input data, and the transformation code.
14
+ You should generate a good itemized explanation of the code so that the reader can understand high-level steps of what the data transformation is doing.
15
+ Be very concise, and stay at a high-level. The reader doesn't understand code and does not want to learn exactly what the code is doing. They just want to learn what have been done from a logical level.
16
+
17
+ The focus is to explain how new fields are computed, don't generate explanation for low-level actions like "return", "load data" etc.
18
+
19
+ Format the transformation explanation in markdown format: highlight constants, data fields, and important verbs. Be sure to be concise.
20
+
21
+
22
+ For example:
23
+
24
+ [CONTEXT]
25
+
26
+ Here are our datasets, here are their field summaries and samples:
27
+
28
+ table_0 (us_covid_cases) fields:
29
+ Date -- type: object, values: 1/1/2021, 1/1/2022, 1/1/2023, ..., 9/8/2022, 9/9/2020, 9/9/2021, 9/9/2022
30
+ Cases -- type: int64, values: -23999, -14195, -6940, ..., 1018935, 1032159, 1178403, 1433977
31
+
32
+ table_0 (us_covid_cases) sample:
33
+ ```
34
+ |Date|Cases
35
+ 0|1/21/2020|1
36
+ 1|1/22/2020|0
37
+ 2|1/23/2020|0
38
+ 3|1/24/2020|1
39
+ 4|1/25/2020|1
40
+ ......
41
+ ```
42
+
43
+ [CODE]
44
+
45
+ ```python
46
+ import pandas as pd
47
+
48
+ def transform_data(df_0):
49
+ # Convert Date field to datetime format
50
+ df_0['Date'] = pd.to_datetime(df_0['Date'])
51
+
52
+ # Sort the dataframe by Date column
53
+ df_0 = df_0.sort_values('Date')
54
+
55
+ # Calculate 7-day rolling average of Cases column
56
+ df_0['7-day average cases'] = df_0['Cases'].rolling(window=7).mean()
57
+
58
+ return df_0
59
+ ```
60
+
61
+ [EXPLANATION]
62
+
63
+ 1. **Sort** the data in chronological order based on the `Date` column.
64
+ 2. **Calculate** the `7-day rolling average` of `Cases`.
65
+ '''
66
+
67
+ class CodeExplanationAgent(object):
68
+
69
+ def __init__(self, client, model):
70
+ self.client = client
71
+ self.model = model
72
+
73
+ def run(self, input_tables, code):
74
+
75
+ data_summary = generate_data_summary(input_tables, include_data_samples=True)
76
+
77
+ user_query = f"[CONTEXT]\n\n{data_summary}\n\n[CODE]\n\here is the transformation code: {code}\n\n[EXPLANATION]\n"
78
+
79
+ logger.info(user_query)
80
+
81
+ messages = [{"role":"system", "content": SYSTEM_PROMPT},
82
+ {"role":"user","content": user_query}]
83
+
84
+ ###### the part that calls open_ai
85
+ response = self.client.chat.completions.create(
86
+ model=self.model, messages = messages, temperature=0.7, max_tokens=1200,
87
+ top_p=0.95, n=1, frequency_penalty=0, presence_penalty=0, stop=None)
88
+
89
+ logger.info('\n=== explanation output ===>\n')
90
+ logger.info(response.choices[0].message.content)
91
+
92
+ return response.choices[0].message.content