speechplotlib 0.1.0__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.
- speechplotlib-0.1.0/LICENSE +21 -0
- speechplotlib-0.1.0/PKG-INFO +166 -0
- speechplotlib-0.1.0/README.md +129 -0
- speechplotlib-0.1.0/pyproject.toml +43 -0
- speechplotlib-0.1.0/setup.cfg +4 -0
- speechplotlib-0.1.0/speechplotlib/__init__.py +40 -0
- speechplotlib-0.1.0/speechplotlib/accessor.py +102 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/__init__.py +12 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/_input.py +97 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/_stats.py +165 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/_text.py +192 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/categorical.py +211 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/distribution.py +409 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/model.py +456 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/overview.py +157 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/relationship.py +413 -0
- speechplotlib-0.1.0/speechplotlib/analyzers/trend.py +281 -0
- speechplotlib-0.1.0/speechplotlib/config.py +124 -0
- speechplotlib-0.1.0/speechplotlib/errors.py +8 -0
- speechplotlib-0.1.0/speechplotlib/plotting.py +102 -0
- speechplotlib-0.1.0/speechplotlib/result.py +207 -0
- speechplotlib-0.1.0/speechplotlib/rules.py +139 -0
- speechplotlib-0.1.0/speechplotlib/session.py +73 -0
- speechplotlib-0.1.0/speechplotlib/speech.py +117 -0
- speechplotlib-0.1.0/speechplotlib/var.py +303 -0
- speechplotlib-0.1.0/speechplotlib.egg-info/PKG-INFO +166 -0
- speechplotlib-0.1.0/speechplotlib.egg-info/SOURCES.txt +35 -0
- speechplotlib-0.1.0/speechplotlib.egg-info/dependency_links.txt +1 -0
- speechplotlib-0.1.0/speechplotlib.egg-info/requires.txt +15 -0
- speechplotlib-0.1.0/speechplotlib.egg-info/top_level.txt +1 -0
- speechplotlib-0.1.0/tests/test_distribution.py +227 -0
- speechplotlib-0.1.0/tests/test_docs_match_library.py +33 -0
- speechplotlib-0.1.0/tests/test_haptic_variables.py +94 -0
- speechplotlib-0.1.0/tests/test_overview.py +48 -0
- speechplotlib-0.1.0/tests/test_relationship_and_categories.py +168 -0
- speechplotlib-0.1.0/tests/test_speech_and_rules.py +72 -0
- speechplotlib-0.1.0/tests/test_trend_and_models.py +221 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sugumar S
|
|
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,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: speechplotlib
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Screen-reader-friendly text descriptions of data science charts, computed from the data.
|
|
5
|
+
Author-email: Sugumar S <ssugumar2001@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/SSugumar2/speechplotlib
|
|
8
|
+
Project-URL: Documentation, https://github.com/SSugumar2/speechplotlib/tree/main/docs
|
|
9
|
+
Project-URL: Issues, https://github.com/SSugumar2/speechplotlib/issues
|
|
10
|
+
Keywords: accessibility,blind,screen reader,eda,data visualization,statistics,nvda
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Intended Audience :: Science/Research
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=1.22
|
|
25
|
+
Requires-Dist: pandas>=1.5
|
|
26
|
+
Requires-Dist: scipy>=1.9
|
|
27
|
+
Provides-Extra: plot
|
|
28
|
+
Requires-Dist: matplotlib>=3.8; extra == "plot"
|
|
29
|
+
Provides-Extra: ml
|
|
30
|
+
Requires-Dist: scikit-learn>=1.1; extra == "ml"
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
33
|
+
Requires-Dist: matplotlib>=3.8; extra == "dev"
|
|
34
|
+
Requires-Dist: scikit-learn>=1.1; extra == "dev"
|
|
35
|
+
Requires-Dist: statsmodels>=0.13; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# speechplotlib
|
|
39
|
+
|
|
40
|
+
Text descriptions of data science charts for screen reader users, computed from the data.
|
|
41
|
+
|
|
42
|
+
A sighted analyst runs `df.plot.hist()` and reads the shape at a glance. With speechplotlib you run `df.spl.hist("price")` and hear the same thing in a few sentences, with every number kept for follow-up questions.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import pandas as pd
|
|
46
|
+
import speechplotlib as spl
|
|
47
|
+
|
|
48
|
+
df = pd.read_csv("datasets/diamonds.csv")
|
|
49
|
+
h = df.spl.hist("price")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Output:
|
|
53
|
+
|
|
54
|
+
> Histogram of price, 53,940 values, none missing. Highly right-skewed, skewness 1.62. Median 2,400, mean 3,930. Middle half lies between 950 and 5,320. 3,540 high outliers above 11,900; largest 18,800.
|
|
55
|
+
|
|
56
|
+
## Why
|
|
57
|
+
|
|
58
|
+
Charts are how most people explore data, and they are silent to a screen reader. Blind learners can compute statistics one function at a time, but that takes many calls to learn what one picture shows. speechplotlib gives the picture's meaning in one call, in plain sentences that NVDA, JAWS and VoiceOver read cleanly.
|
|
59
|
+
|
|
60
|
+
It works from the data, not from a drawing, so it describes your own DataFrame the same way whether you would draw the chart with Matplotlib, Seaborn, Plotly or not at all.
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
Install from GitHub:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
pip install git+https://github.com/SSugumar2/speechplotlib.git
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
To work with the examples, docs and tests, clone the repository and install it with the extra tools:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
git clone https://github.com/SSugumar2/speechplotlib.git
|
|
74
|
+
cd speechplotlib
|
|
75
|
+
python -m venv .venv
|
|
76
|
+
.venv\Scripts\activate
|
|
77
|
+
pip install -e ".[dev]"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
On macOS or Linux, activate with `source .venv/bin/activate`. speechplotlib needs Python 3.9 or later, NumPy, pandas and SciPy. `[dev]` adds Matplotlib for drawings, scikit-learn for the model charts, and pytest and statsmodels for the tests.
|
|
81
|
+
|
|
82
|
+
## What it describes
|
|
83
|
+
|
|
84
|
+
18 charts and a dataset overview:
|
|
85
|
+
|
|
86
|
+
| Group | Calls |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| Dataset | `df.spl.overview(target=None)` |
|
|
89
|
+
| Distribution | `df.spl.hist(col)`, `kde(col)`, `box(col, by=None)`, `violin(col, by=None)`, `qq(col)`, `ecdf(col)` |
|
|
90
|
+
| Relationship | `df.spl.scatter(x, y)`, `regression(x, y)`, `corr(target=None)` |
|
|
91
|
+
| Categories | `df.spl.bar(col, values=None, agg="sum")`, `pie(col)` |
|
|
92
|
+
| Trend | `df.spl.line(y, x="date")` |
|
|
93
|
+
| Models | `spl.elbow(X)`, `spl.pca(model)`, `spl.importance(model)`, `spl.roc(y_true, y_score)`, `spl.residuals(y_true, y_pred)` |
|
|
94
|
+
|
|
95
|
+
Every call also works as a plain function, such as `spl.hist(values)`. Each takes `level="standard"` or `"full"` for more detail, and `plot=True` to also draw the chart for a sighted colleague.
|
|
96
|
+
|
|
97
|
+
## Follow-up questions
|
|
98
|
+
|
|
99
|
+
Each call returns a result that keeps every number:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
h.median # 2401.0
|
|
103
|
+
h.outliers # the outlier rows, largest first
|
|
104
|
+
h.detail() # more sentences
|
|
105
|
+
h.explain("skewness") # what skewness means and the bands used
|
|
106
|
+
h.advice() # suggested next steps, kept apart from the facts
|
|
107
|
+
h.values() # every number as a dict
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Haptic variables
|
|
111
|
+
|
|
112
|
+
Declare a column once, then ask it questions:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
price = spl.var(df, "price")
|
|
116
|
+
price.median # one number, nothing else printed
|
|
117
|
+
price.summary() # a few sentences of key numbers
|
|
118
|
+
price.box(by="cut") # a chart description
|
|
119
|
+
price.vs("carat") # compared with another column
|
|
120
|
+
price.questions() # everything you can ask
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Documentation
|
|
124
|
+
|
|
125
|
+
Start with [the documentation home](docs/index.md):
|
|
126
|
+
|
|
127
|
+
1. [Getting started](docs/getting-started.md): install and first steps in VS Code, a terminal or Jupyter.
|
|
128
|
+
2. [Haptic variables](docs/haptic-variables.md): the full guide, with a worked example.
|
|
129
|
+
3. [Charts](docs/charts.md): every chart with an example.
|
|
130
|
+
4. [Results and the session](docs/results-and-session.md).
|
|
131
|
+
5. [How words are chosen](docs/how-words-are-chosen.md): every threshold, and how to change it.
|
|
132
|
+
6. [Drawings for sighted colleagues](docs/drawings.md).
|
|
133
|
+
|
|
134
|
+
To try everything at once, from the repository folder:
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
python examples/try_speechplotlib.py > try_output.txt
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Datasets
|
|
141
|
+
|
|
142
|
+
The [datasets](datasets) folder has five public datasets as CSV files: penguins, mpg, iris, diamonds and flights. They are used in the docs, the examples and the tests. Sources, licences and column descriptions are in [datasets/README.md](datasets/README.md).
|
|
143
|
+
|
|
144
|
+
## Accuracy
|
|
145
|
+
|
|
146
|
+
- Every statistic is checked in the tests against pandas, SciPy, statsmodels or scikit-learn.
|
|
147
|
+
- Every example output in the docs and this README was produced by running the library. The docs are generated by `python docs_src/build_docs.py`, and a test fails if they fall out of date.
|
|
148
|
+
- Words such as "highly skewed" come from stated bands, and the number is always said next to the word.
|
|
149
|
+
|
|
150
|
+
Run the tests with `python -m pytest`.
|
|
151
|
+
|
|
152
|
+
## Author
|
|
153
|
+
|
|
154
|
+
speechplotlib is created and maintained by [Sugumar S](https://github.com/SSugumar2), an AI/ML engineer who uses a screen reader. Contact: ssugumar2001@gmail.com. The idea began in his article [Revolutionizing Data Science: Accessible Visualizations for All](https://www.linkedin.com/pulse/revolutionizing-data-science-accessible-visualization-sugumar-s-dfebc/).
|
|
155
|
+
|
|
156
|
+
## Citing
|
|
157
|
+
|
|
158
|
+
If you use speechplotlib in research or teaching, please cite it. GitHub's "Cite this repository" button, on the right of the repository page, gives the citation in APA and BibTeX, from [CITATION.cff](CITATION.cff).
|
|
159
|
+
|
|
160
|
+
## Feedback
|
|
161
|
+
|
|
162
|
+
Report a problem or suggest an improvement at https://github.com/SSugumar2/speechplotlib/issues. If a description reads badly with your screen reader, please include the output and the screen reader you use.
|
|
163
|
+
|
|
164
|
+
## Licence
|
|
165
|
+
|
|
166
|
+
MIT. See [LICENSE](LICENSE). The datasets keep their own licences, listed in [datasets/README.md](datasets/README.md).
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# speechplotlib
|
|
2
|
+
|
|
3
|
+
Text descriptions of data science charts for screen reader users, computed from the data.
|
|
4
|
+
|
|
5
|
+
A sighted analyst runs `df.plot.hist()` and reads the shape at a glance. With speechplotlib you run `df.spl.hist("price")` and hear the same thing in a few sentences, with every number kept for follow-up questions.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
import pandas as pd
|
|
9
|
+
import speechplotlib as spl
|
|
10
|
+
|
|
11
|
+
df = pd.read_csv("datasets/diamonds.csv")
|
|
12
|
+
h = df.spl.hist("price")
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Output:
|
|
16
|
+
|
|
17
|
+
> Histogram of price, 53,940 values, none missing. Highly right-skewed, skewness 1.62. Median 2,400, mean 3,930. Middle half lies between 950 and 5,320. 3,540 high outliers above 11,900; largest 18,800.
|
|
18
|
+
|
|
19
|
+
## Why
|
|
20
|
+
|
|
21
|
+
Charts are how most people explore data, and they are silent to a screen reader. Blind learners can compute statistics one function at a time, but that takes many calls to learn what one picture shows. speechplotlib gives the picture's meaning in one call, in plain sentences that NVDA, JAWS and VoiceOver read cleanly.
|
|
22
|
+
|
|
23
|
+
It works from the data, not from a drawing, so it describes your own DataFrame the same way whether you would draw the chart with Matplotlib, Seaborn, Plotly or not at all.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
Install from GitHub:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
pip install git+https://github.com/SSugumar2/speechplotlib.git
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To work with the examples, docs and tests, clone the repository and install it with the extra tools:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
git clone https://github.com/SSugumar2/speechplotlib.git
|
|
37
|
+
cd speechplotlib
|
|
38
|
+
python -m venv .venv
|
|
39
|
+
.venv\Scripts\activate
|
|
40
|
+
pip install -e ".[dev]"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
On macOS or Linux, activate with `source .venv/bin/activate`. speechplotlib needs Python 3.9 or later, NumPy, pandas and SciPy. `[dev]` adds Matplotlib for drawings, scikit-learn for the model charts, and pytest and statsmodels for the tests.
|
|
44
|
+
|
|
45
|
+
## What it describes
|
|
46
|
+
|
|
47
|
+
18 charts and a dataset overview:
|
|
48
|
+
|
|
49
|
+
| Group | Calls |
|
|
50
|
+
| --- | --- |
|
|
51
|
+
| Dataset | `df.spl.overview(target=None)` |
|
|
52
|
+
| Distribution | `df.spl.hist(col)`, `kde(col)`, `box(col, by=None)`, `violin(col, by=None)`, `qq(col)`, `ecdf(col)` |
|
|
53
|
+
| Relationship | `df.spl.scatter(x, y)`, `regression(x, y)`, `corr(target=None)` |
|
|
54
|
+
| Categories | `df.spl.bar(col, values=None, agg="sum")`, `pie(col)` |
|
|
55
|
+
| Trend | `df.spl.line(y, x="date")` |
|
|
56
|
+
| Models | `spl.elbow(X)`, `spl.pca(model)`, `spl.importance(model)`, `spl.roc(y_true, y_score)`, `spl.residuals(y_true, y_pred)` |
|
|
57
|
+
|
|
58
|
+
Every call also works as a plain function, such as `spl.hist(values)`. Each takes `level="standard"` or `"full"` for more detail, and `plot=True` to also draw the chart for a sighted colleague.
|
|
59
|
+
|
|
60
|
+
## Follow-up questions
|
|
61
|
+
|
|
62
|
+
Each call returns a result that keeps every number:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
h.median # 2401.0
|
|
66
|
+
h.outliers # the outlier rows, largest first
|
|
67
|
+
h.detail() # more sentences
|
|
68
|
+
h.explain("skewness") # what skewness means and the bands used
|
|
69
|
+
h.advice() # suggested next steps, kept apart from the facts
|
|
70
|
+
h.values() # every number as a dict
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Haptic variables
|
|
74
|
+
|
|
75
|
+
Declare a column once, then ask it questions:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
price = spl.var(df, "price")
|
|
79
|
+
price.median # one number, nothing else printed
|
|
80
|
+
price.summary() # a few sentences of key numbers
|
|
81
|
+
price.box(by="cut") # a chart description
|
|
82
|
+
price.vs("carat") # compared with another column
|
|
83
|
+
price.questions() # everything you can ask
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
Start with [the documentation home](docs/index.md):
|
|
89
|
+
|
|
90
|
+
1. [Getting started](docs/getting-started.md): install and first steps in VS Code, a terminal or Jupyter.
|
|
91
|
+
2. [Haptic variables](docs/haptic-variables.md): the full guide, with a worked example.
|
|
92
|
+
3. [Charts](docs/charts.md): every chart with an example.
|
|
93
|
+
4. [Results and the session](docs/results-and-session.md).
|
|
94
|
+
5. [How words are chosen](docs/how-words-are-chosen.md): every threshold, and how to change it.
|
|
95
|
+
6. [Drawings for sighted colleagues](docs/drawings.md).
|
|
96
|
+
|
|
97
|
+
To try everything at once, from the repository folder:
|
|
98
|
+
|
|
99
|
+
```text
|
|
100
|
+
python examples/try_speechplotlib.py > try_output.txt
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Datasets
|
|
104
|
+
|
|
105
|
+
The [datasets](datasets) folder has five public datasets as CSV files: penguins, mpg, iris, diamonds and flights. They are used in the docs, the examples and the tests. Sources, licences and column descriptions are in [datasets/README.md](datasets/README.md).
|
|
106
|
+
|
|
107
|
+
## Accuracy
|
|
108
|
+
|
|
109
|
+
- Every statistic is checked in the tests against pandas, SciPy, statsmodels or scikit-learn.
|
|
110
|
+
- Every example output in the docs and this README was produced by running the library. The docs are generated by `python docs_src/build_docs.py`, and a test fails if they fall out of date.
|
|
111
|
+
- Words such as "highly skewed" come from stated bands, and the number is always said next to the word.
|
|
112
|
+
|
|
113
|
+
Run the tests with `python -m pytest`.
|
|
114
|
+
|
|
115
|
+
## Author
|
|
116
|
+
|
|
117
|
+
speechplotlib is created and maintained by [Sugumar S](https://github.com/SSugumar2), an AI/ML engineer who uses a screen reader. Contact: ssugumar2001@gmail.com. The idea began in his article [Revolutionizing Data Science: Accessible Visualizations for All](https://www.linkedin.com/pulse/revolutionizing-data-science-accessible-visualization-sugumar-s-dfebc/).
|
|
118
|
+
|
|
119
|
+
## Citing
|
|
120
|
+
|
|
121
|
+
If you use speechplotlib in research or teaching, please cite it. GitHub's "Cite this repository" button, on the right of the repository page, gives the citation in APA and BibTeX, from [CITATION.cff](CITATION.cff).
|
|
122
|
+
|
|
123
|
+
## Feedback
|
|
124
|
+
|
|
125
|
+
Report a problem or suggest an improvement at https://github.com/SSugumar2/speechplotlib/issues. If a description reads badly with your screen reader, please include the output and the screen reader you use.
|
|
126
|
+
|
|
127
|
+
## Licence
|
|
128
|
+
|
|
129
|
+
MIT. See [LICENSE](LICENSE). The datasets keep their own licences, listed in [datasets/README.md](datasets/README.md).
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "speechplotlib"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Screen-reader-friendly text descriptions of data science charts, computed from the data."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Sugumar S", email = "ssugumar2001@gmail.com" }]
|
|
14
|
+
keywords = ["accessibility", "blind", "screen reader", "eda", "data visualization", "statistics", "nvda"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.9",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
"Intended Audience :: Science/Research",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
26
|
+
]
|
|
27
|
+
dependencies = ["numpy>=1.22", "pandas>=1.5", "scipy>=1.9"]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/SSugumar2/speechplotlib"
|
|
31
|
+
Documentation = "https://github.com/SSugumar2/speechplotlib/tree/main/docs"
|
|
32
|
+
Issues = "https://github.com/SSugumar2/speechplotlib/issues"
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
plot = ["matplotlib>=3.8"]
|
|
36
|
+
ml = ["scikit-learn>=1.1"]
|
|
37
|
+
dev = ["pytest>=7", "matplotlib>=3.8", "scikit-learn>=1.1", "statsmodels>=0.13"]
|
|
38
|
+
|
|
39
|
+
[tool.setuptools]
|
|
40
|
+
packages = ["speechplotlib", "speechplotlib.analyzers"]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""speechplotlib: screen-reader-friendly descriptions of data science charts.
|
|
2
|
+
|
|
3
|
+
import speechplotlib as spl
|
|
4
|
+
df.spl.overview()
|
|
5
|
+
h = df.spl.hist("price") # reads the description
|
|
6
|
+
h.skewness # every number is kept on the result
|
|
7
|
+
h.detail(); h.explain("skewness"); h.advice()
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from . import accessor as _accessor # noqa: F401 registers df.spl and series.spl
|
|
11
|
+
from .analyzers import (bar, box, corr, ecdf, elbow, hist, importance, kde, line, overview, pca, pie, qq,
|
|
12
|
+
regression, residuals, roc, scatter, violin)
|
|
13
|
+
from .config import config
|
|
14
|
+
from .result import Result
|
|
15
|
+
from .session import session
|
|
16
|
+
from .var import HapticVar, var
|
|
17
|
+
|
|
18
|
+
__version__ = "0.1.0"
|
|
19
|
+
__author__ = "Sugumar S"
|
|
20
|
+
__email__ = "ssugumar2001@gmail.com"
|
|
21
|
+
__license__ = "MIT"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def get(name: str):
|
|
25
|
+
"""Bring back a saved result, for example ``spl.get("hist:price")``."""
|
|
26
|
+
return session.get(name)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def __getattr__(attr):
|
|
30
|
+
if attr == "last":
|
|
31
|
+
return session.last
|
|
32
|
+
raise AttributeError(f"module 'speechplotlib' has no attribute {attr!r}")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"overview", "hist", "kde", "box", "violin", "qq", "ecdf",
|
|
37
|
+
"scatter", "regression", "corr", "bar", "pie",
|
|
38
|
+
"line", "elbow", "pca", "importance", "roc", "residuals",
|
|
39
|
+
"var", "HapticVar", "Result", "config", "session", "get", "last",
|
|
40
|
+
]
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""``df.spl`` and ``series.spl``: the same calls as the ``spl`` functions, read like ``df.plot``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
from . import analyzers
|
|
8
|
+
from .var import HapticVar
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pd.api.extensions.register_dataframe_accessor("spl")
|
|
12
|
+
class DataFrameSpeech:
|
|
13
|
+
"""Describe charts of this DataFrame: ``df.spl.hist("price")``."""
|
|
14
|
+
|
|
15
|
+
def __init__(self, df: pd.DataFrame) -> None:
|
|
16
|
+
self._df = df
|
|
17
|
+
|
|
18
|
+
# dataset
|
|
19
|
+
def overview(self, target=None, **kw):
|
|
20
|
+
return analyzers.overview(self._df, target=target, **kw)
|
|
21
|
+
|
|
22
|
+
# distribution
|
|
23
|
+
def hist(self, column=None, **kw):
|
|
24
|
+
return analyzers.hist(self._df, column, **kw)
|
|
25
|
+
|
|
26
|
+
def kde(self, column=None, **kw):
|
|
27
|
+
return analyzers.kde(self._df, column, **kw)
|
|
28
|
+
|
|
29
|
+
def box(self, column=None, by=None, **kw):
|
|
30
|
+
return analyzers.box(self._df, column, by=by, **kw)
|
|
31
|
+
|
|
32
|
+
def violin(self, column=None, by=None, **kw):
|
|
33
|
+
return analyzers.violin(self._df, column, by=by, **kw)
|
|
34
|
+
|
|
35
|
+
def qq(self, column=None, **kw):
|
|
36
|
+
return analyzers.qq(self._df, column, **kw)
|
|
37
|
+
|
|
38
|
+
def ecdf(self, column=None, **kw):
|
|
39
|
+
return analyzers.ecdf(self._df, column, **kw)
|
|
40
|
+
|
|
41
|
+
# relationship
|
|
42
|
+
def scatter(self, x, y, **kw):
|
|
43
|
+
return analyzers.scatter(self._df, x, y, **kw)
|
|
44
|
+
|
|
45
|
+
def regression(self, x, y, **kw):
|
|
46
|
+
return analyzers.regression(self._df, x, y, **kw)
|
|
47
|
+
|
|
48
|
+
def corr(self, target=None, method="pearson", **kw):
|
|
49
|
+
return analyzers.corr(self._df, target=target, method=method, **kw)
|
|
50
|
+
|
|
51
|
+
# categories
|
|
52
|
+
def bar(self, column, values=None, agg="sum", **kw):
|
|
53
|
+
return analyzers.bar(self._df, column, values=values, agg=agg, **kw)
|
|
54
|
+
|
|
55
|
+
def pie(self, column, values=None, agg="sum", **kw):
|
|
56
|
+
return analyzers.pie(self._df, column, values=values, agg=agg, **kw)
|
|
57
|
+
|
|
58
|
+
# trend
|
|
59
|
+
def line(self, y, x=None, **kw):
|
|
60
|
+
return analyzers.line(self._df, y, x=x, **kw)
|
|
61
|
+
|
|
62
|
+
# haptic variables
|
|
63
|
+
def var(self, column) -> HapticVar:
|
|
64
|
+
return HapticVar(self._df, column)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pd.api.extensions.register_series_accessor("spl")
|
|
68
|
+
class SeriesSpeech:
|
|
69
|
+
"""Describe charts of this Series: ``df["price"].spl.hist()``."""
|
|
70
|
+
|
|
71
|
+
def __init__(self, s: pd.Series) -> None:
|
|
72
|
+
self._s = s
|
|
73
|
+
|
|
74
|
+
def hist(self, **kw):
|
|
75
|
+
return analyzers.hist(self._s, **kw)
|
|
76
|
+
|
|
77
|
+
def kde(self, **kw):
|
|
78
|
+
return analyzers.kde(self._s, **kw)
|
|
79
|
+
|
|
80
|
+
def box(self, **kw):
|
|
81
|
+
return analyzers.box(self._s, **kw)
|
|
82
|
+
|
|
83
|
+
def violin(self, **kw):
|
|
84
|
+
return analyzers.violin(self._s, **kw)
|
|
85
|
+
|
|
86
|
+
def qq(self, **kw):
|
|
87
|
+
return analyzers.qq(self._s, **kw)
|
|
88
|
+
|
|
89
|
+
def ecdf(self, **kw):
|
|
90
|
+
return analyzers.ecdf(self._s, **kw)
|
|
91
|
+
|
|
92
|
+
def bar(self, **kw):
|
|
93
|
+
return analyzers.bar(self._s, **kw)
|
|
94
|
+
|
|
95
|
+
def pie(self, **kw):
|
|
96
|
+
return analyzers.pie(self._s, **kw)
|
|
97
|
+
|
|
98
|
+
def line(self, x=None, **kw):
|
|
99
|
+
return analyzers.line(self._s, x=x, **kw)
|
|
100
|
+
|
|
101
|
+
def var(self) -> HapticVar:
|
|
102
|
+
return HapticVar(self._s)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from .categorical import bar, pie
|
|
2
|
+
from .distribution import box, ecdf, hist, kde, qq, violin
|
|
3
|
+
from .model import elbow, importance, pca, residuals, roc
|
|
4
|
+
from .overview import overview
|
|
5
|
+
from .relationship import corr, regression, scatter
|
|
6
|
+
from .trend import line
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"overview", "hist", "kde", "box", "violin", "qq", "ecdf",
|
|
10
|
+
"scatter", "regression", "corr", "bar", "pie",
|
|
11
|
+
"line", "elbow", "pca", "importance", "roc", "residuals",
|
|
12
|
+
]
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""Bring user input into a clean numeric Series and record what was dropped."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import pandas as pd
|
|
9
|
+
|
|
10
|
+
from .. import speech as sp
|
|
11
|
+
from ..errors import SpeechKeyError
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class NumericInput:
|
|
16
|
+
values: np.ndarray # finite values only, original order
|
|
17
|
+
series: pd.Series # finite values with the original index
|
|
18
|
+
name: str
|
|
19
|
+
n_total: int
|
|
20
|
+
n_missing: int # NaN, None and infinite
|
|
21
|
+
n_infinite: int
|
|
22
|
+
frame: pd.DataFrame | None
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def n(self) -> int:
|
|
26
|
+
return len(self.values)
|
|
27
|
+
|
|
28
|
+
def missing_phrase(self) -> str:
|
|
29
|
+
if self.n_missing == 0:
|
|
30
|
+
return "none missing"
|
|
31
|
+
text = f"{sp.integer(self.n_missing)} missing, {sp.pct(self.n_missing / self.n_total)}"
|
|
32
|
+
if self.n_infinite:
|
|
33
|
+
text += f", including {sp.integer(self.n_infinite)} infinite"
|
|
34
|
+
return text
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _pick_column(data: pd.DataFrame, column):
|
|
38
|
+
if column is None:
|
|
39
|
+
if data.shape[1] == 1:
|
|
40
|
+
return data.columns[0]
|
|
41
|
+
cols = ", ".join(map(str, data.columns[:10]))
|
|
42
|
+
more = "" if data.shape[1] <= 10 else f" and {data.shape[1] - 10} more"
|
|
43
|
+
raise ValueError(f"Pass the column to describe. This DataFrame has {data.shape[1]} columns: {cols}{more}.")
|
|
44
|
+
if column not in data.columns:
|
|
45
|
+
raise SpeechKeyError(f"No column named {column!r}.")
|
|
46
|
+
return column
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def numeric(data, column=None, name: str | None = None) -> NumericInput:
|
|
50
|
+
frame = None
|
|
51
|
+
if isinstance(data, pd.DataFrame):
|
|
52
|
+
column = _pick_column(data, column)
|
|
53
|
+
s = data[column]
|
|
54
|
+
frame = data
|
|
55
|
+
elif isinstance(data, pd.Series):
|
|
56
|
+
s = data
|
|
57
|
+
else:
|
|
58
|
+
arr = np.asarray(data)
|
|
59
|
+
if arr.ndim > 1:
|
|
60
|
+
arr = arr.ravel()
|
|
61
|
+
s = pd.Series(arr)
|
|
62
|
+
label = name or (str(s.name) if s.name is not None else "values")
|
|
63
|
+
|
|
64
|
+
if pd.api.types.is_bool_dtype(s):
|
|
65
|
+
s = s.astype(float)
|
|
66
|
+
if not pd.api.types.is_numeric_dtype(s):
|
|
67
|
+
converted = pd.to_numeric(s, errors="coerce")
|
|
68
|
+
if converted.notna().sum() < s.notna().sum():
|
|
69
|
+
raise TypeError(
|
|
70
|
+
f"{label} is not numeric. It holds text or categories; "
|
|
71
|
+
"describe it with bar or pie instead."
|
|
72
|
+
)
|
|
73
|
+
s = converted
|
|
74
|
+
s = s.astype(float)
|
|
75
|
+
n_total = len(s)
|
|
76
|
+
infinite = np.isinf(s.to_numpy())
|
|
77
|
+
n_inf = int(infinite.sum())
|
|
78
|
+
clean = s[~infinite].dropna()
|
|
79
|
+
return NumericInput(
|
|
80
|
+
values=clean.to_numpy(),
|
|
81
|
+
series=clean,
|
|
82
|
+
name=label,
|
|
83
|
+
n_total=n_total,
|
|
84
|
+
n_missing=n_total - len(clean),
|
|
85
|
+
n_infinite=n_inf,
|
|
86
|
+
frame=frame,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def frame_and_group(data, column, by):
|
|
91
|
+
"""Return (frame, value column, group column) for grouped charts."""
|
|
92
|
+
if not isinstance(data, pd.DataFrame):
|
|
93
|
+
raise TypeError("Grouping with by= needs a DataFrame and a column name.")
|
|
94
|
+
column = _pick_column(data, column)
|
|
95
|
+
if by not in data.columns:
|
|
96
|
+
raise SpeechKeyError(f"No column named {by!r} to group by.")
|
|
97
|
+
return data, column, by
|