speechplotlib 0.1.0__py3-none-any.whl
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/__init__.py +40 -0
- speechplotlib/accessor.py +102 -0
- speechplotlib/analyzers/__init__.py +12 -0
- speechplotlib/analyzers/_input.py +97 -0
- speechplotlib/analyzers/_stats.py +165 -0
- speechplotlib/analyzers/_text.py +192 -0
- speechplotlib/analyzers/categorical.py +211 -0
- speechplotlib/analyzers/distribution.py +409 -0
- speechplotlib/analyzers/model.py +456 -0
- speechplotlib/analyzers/overview.py +157 -0
- speechplotlib/analyzers/relationship.py +413 -0
- speechplotlib/analyzers/trend.py +281 -0
- speechplotlib/config.py +124 -0
- speechplotlib/errors.py +8 -0
- speechplotlib/plotting.py +102 -0
- speechplotlib/result.py +207 -0
- speechplotlib/rules.py +139 -0
- speechplotlib/session.py +73 -0
- speechplotlib/speech.py +117 -0
- speechplotlib/var.py +303 -0
- speechplotlib-0.1.0.dist-info/METADATA +166 -0
- speechplotlib-0.1.0.dist-info/RECORD +25 -0
- speechplotlib-0.1.0.dist-info/WHEEL +5 -0
- speechplotlib-0.1.0.dist-info/licenses/LICENSE +21 -0
- speechplotlib-0.1.0.dist-info/top_level.txt +1 -0
speechplotlib/var.py
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"""Haptic variables: declare a column once, then ask it questions.
|
|
2
|
+
|
|
3
|
+
price = spl.var(df, "price")
|
|
4
|
+
price.median # one number, nothing printed
|
|
5
|
+
price.summary() # a few sentences of key numbers
|
|
6
|
+
price.hist() # the histogram description
|
|
7
|
+
price.vs("carat") # scatter of price against another column
|
|
8
|
+
|
|
9
|
+
A haptic variable knows whether its column holds numbers or categories and offers
|
|
10
|
+
the questions that fit. Numbers are computed the first time they are asked for and
|
|
11
|
+
then kept, so asking again is instant.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import numpy as np
|
|
17
|
+
import pandas as pd
|
|
18
|
+
|
|
19
|
+
from . import analyzers
|
|
20
|
+
from . import rules
|
|
21
|
+
from . import speech as sp
|
|
22
|
+
from .analyzers import _input, _stats
|
|
23
|
+
from .result import Spoken
|
|
24
|
+
from .errors import SpeechKeyError
|
|
25
|
+
|
|
26
|
+
_NUMERIC_CHARTS = ("hist", "kde", "box", "violin", "qq", "ecdf", "line")
|
|
27
|
+
_CATEGORY_CHARTS = ("bar", "pie")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class HapticVar:
|
|
31
|
+
"""A column held for repeated questions. Create one with ``spl.var(...)``."""
|
|
32
|
+
|
|
33
|
+
def __init__(self, data, column=None, name=None) -> None:
|
|
34
|
+
if isinstance(data, pd.DataFrame):
|
|
35
|
+
if column is None:
|
|
36
|
+
raise ValueError("Pass the column too, for example spl.var(df, \"price\").")
|
|
37
|
+
if column not in data.columns:
|
|
38
|
+
raise SpeechKeyError(f"No column named {column!r}. Columns: {', '.join(map(str, data.columns[:15]))}.")
|
|
39
|
+
series = data[column]
|
|
40
|
+
self._frame = data
|
|
41
|
+
else:
|
|
42
|
+
series = data if isinstance(data, pd.Series) else pd.Series(np.asarray(data).ravel())
|
|
43
|
+
self._frame = None
|
|
44
|
+
self._column = column
|
|
45
|
+
self._series = series
|
|
46
|
+
self._name = name or (str(column) if column is not None else (str(series.name) if series.name is not None else "values"))
|
|
47
|
+
numeric = pd.api.types.is_numeric_dtype(series) and not pd.api.types.is_bool_dtype(series)
|
|
48
|
+
self.kind = "numeric" if numeric else "category"
|
|
49
|
+
self._inp = _input.numeric(series, name=self._name) if numeric else None
|
|
50
|
+
self._cache: dict = {}
|
|
51
|
+
|
|
52
|
+
# ----- helpers -----------------------------------------------------------------
|
|
53
|
+
def _need(self, kind: str, what: str):
|
|
54
|
+
if self.kind != kind:
|
|
55
|
+
if kind == "numeric":
|
|
56
|
+
raise TypeError(f"{self._name} holds categories, so it cannot give {what}. Ask for .counts, .bar() or .pie().")
|
|
57
|
+
raise TypeError(f"{self._name} holds numbers, so it cannot give {what}. Ask for .hist(), .box() or .median.")
|
|
58
|
+
|
|
59
|
+
def _s(self) -> dict:
|
|
60
|
+
self._need("numeric", "statistics")
|
|
61
|
+
if "summary" not in self._cache:
|
|
62
|
+
self._cache["summary"] = _stats.summary(self._inp.values)
|
|
63
|
+
return self._cache["summary"]
|
|
64
|
+
|
|
65
|
+
def _counts(self) -> pd.Series:
|
|
66
|
+
if "counts" not in self._cache:
|
|
67
|
+
self._cache["counts"] = self._series.value_counts(dropna=True)
|
|
68
|
+
return self._cache["counts"]
|
|
69
|
+
|
|
70
|
+
def _source(self):
|
|
71
|
+
"""What to hand to the chart functions: the DataFrame and column, or the Series."""
|
|
72
|
+
if self._frame is not None:
|
|
73
|
+
return self._frame, self._column
|
|
74
|
+
return self._series, None
|
|
75
|
+
|
|
76
|
+
# ----- always available ---------------------------------------------------------
|
|
77
|
+
@property
|
|
78
|
+
def name(self) -> str:
|
|
79
|
+
"""The column name."""
|
|
80
|
+
return self._name
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def n(self) -> int:
|
|
84
|
+
"""Number of values present, not counting missing ones."""
|
|
85
|
+
return int(self._series.notna().sum()) if self.kind == "category" else self._inp.n
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def missing(self) -> int:
|
|
89
|
+
"""Number of missing values."""
|
|
90
|
+
return int(self._series.isna().sum()) if self.kind == "category" else self._inp.n_missing
|
|
91
|
+
|
|
92
|
+
@property
|
|
93
|
+
def missing_share(self) -> float:
|
|
94
|
+
"""Share of rows that are missing, from 0 to 1."""
|
|
95
|
+
total = len(self._series)
|
|
96
|
+
return self.missing / total if total else 0.0
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def data(self) -> pd.Series:
|
|
100
|
+
"""The values themselves, missing ones removed."""
|
|
101
|
+
return self._series.dropna() if self.kind == "category" else self._inp.series
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def unique(self) -> int:
|
|
105
|
+
"""Number of distinct values."""
|
|
106
|
+
return int(self._series.nunique(dropna=True))
|
|
107
|
+
|
|
108
|
+
# ----- numeric columns ------------------------------------------------------------
|
|
109
|
+
mean = property(lambda self: self._s()["mean"], doc="Average of the values.")
|
|
110
|
+
median = property(lambda self: self._s()["median"], doc="Middle value.")
|
|
111
|
+
std = property(lambda self: self._s()["std"], doc="Standard deviation.")
|
|
112
|
+
min = property(lambda self: self._s()["min"], doc="Smallest value.")
|
|
113
|
+
max = property(lambda self: self._s()["max"], doc="Largest value.")
|
|
114
|
+
q1 = property(lambda self: self._s()["q1"], doc="First quartile: 25% of values are below it.")
|
|
115
|
+
q3 = property(lambda self: self._s()["q3"], doc="Third quartile: 75% of values are below it.")
|
|
116
|
+
iqr = property(lambda self: self._s()["iqr"], doc="Interquartile range, q3 minus q1.")
|
|
117
|
+
skewness = property(lambda self: self._s()["skewness"], doc="Skewness, as pandas skew().")
|
|
118
|
+
kurtosis = property(lambda self: self._s()["kurtosis"], doc="Excess kurtosis, as pandas kurt().")
|
|
119
|
+
n_outliers = property(lambda self: self._s()["n_outliers"], doc="Number of values beyond the 1.5 IQR fences.")
|
|
120
|
+
lower_fence = property(lambda self: self._s()["lower_fence"], doc="Values below this are low outliers.")
|
|
121
|
+
upper_fence = property(lambda self: self._s()["upper_fence"], doc="Values above this are high outliers.")
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def shape(self) -> str:
|
|
125
|
+
"""The shape in words, for example "highly right-skewed"."""
|
|
126
|
+
return rules.skew_words(self._s()["skewness"])
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def outliers(self) -> pd.Series:
|
|
130
|
+
"""The outlier values, largest first, with their row labels."""
|
|
131
|
+
s = self._s()
|
|
132
|
+
mask = _stats.outlier_mask(self._inp.values, s)
|
|
133
|
+
return self._inp.series[mask].sort_values(ascending=False)
|
|
134
|
+
|
|
135
|
+
def percentile(self, p: float) -> float:
|
|
136
|
+
"""The value with ``p`` percent of values at or below it, for example ``price.percentile(90)``."""
|
|
137
|
+
self._need("numeric", "percentiles")
|
|
138
|
+
return float(np.percentile(self._inp.values, p))
|
|
139
|
+
|
|
140
|
+
def share_below(self, value: float) -> float:
|
|
141
|
+
"""Share of values at or below ``value``, from 0 to 1."""
|
|
142
|
+
self._need("numeric", "shares below a value")
|
|
143
|
+
return float(np.mean(self._inp.values <= value))
|
|
144
|
+
|
|
145
|
+
# ----- category columns ---------------------------------------------------------------
|
|
146
|
+
@property
|
|
147
|
+
def counts(self) -> pd.Series:
|
|
148
|
+
"""Count of each category, largest first."""
|
|
149
|
+
self._need("category", "category counts")
|
|
150
|
+
return self._counts()
|
|
151
|
+
|
|
152
|
+
@property
|
|
153
|
+
def n_categories(self) -> int:
|
|
154
|
+
"""Number of distinct categories."""
|
|
155
|
+
self._need("category", "categories")
|
|
156
|
+
return len(self._counts())
|
|
157
|
+
|
|
158
|
+
@property
|
|
159
|
+
def top(self):
|
|
160
|
+
"""The most common category."""
|
|
161
|
+
self._need("category", "a most common category")
|
|
162
|
+
c = self._counts()
|
|
163
|
+
return c.index[0] if len(c) else None
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def top_share(self) -> float:
|
|
167
|
+
"""Share of the most common category among present values."""
|
|
168
|
+
self._need("category", "a most common category")
|
|
169
|
+
c = self._counts()
|
|
170
|
+
return float(c.iloc[0] / c.sum()) if len(c) else float("nan")
|
|
171
|
+
|
|
172
|
+
# ----- short summary -------------------------------------------------------------------
|
|
173
|
+
def summary(self) -> Spoken:
|
|
174
|
+
"""A few sentences of key numbers, without a chart."""
|
|
175
|
+
miss = "none missing" if self.missing == 0 else f"{sp.integer(self.missing)} missing, {sp.pct(self.missing_share)}"
|
|
176
|
+
if self.kind == "category":
|
|
177
|
+
c = self._counts()
|
|
178
|
+
if not len(c):
|
|
179
|
+
return Spoken(f"{self._name}: no values, {miss}.")
|
|
180
|
+
top = sp.join([f"{k} {sp.integer(v)}" for k, v in c.head(3).items()])
|
|
181
|
+
return Spoken(f"{self._name}: categories, {sp.plural(self.n, 'value')}, {miss}. "
|
|
182
|
+
f"{sp.plural(len(c), 'category', 'categories')}; most common: {top}.")
|
|
183
|
+
s = self._s()
|
|
184
|
+
if s["n"] == 0:
|
|
185
|
+
return Spoken(f"{self._name}: no numeric values, {miss}.")
|
|
186
|
+
return Spoken(
|
|
187
|
+
f"{self._name}: numbers, {sp.plural(s['n'], 'value')}, {miss}. "
|
|
188
|
+
f"Median {sp.num(s['median'])}, mean {sp.num(s['mean'])}, range {sp.range_text(s['min'], s['max'])}. "
|
|
189
|
+
f"{sp.sentence(self.shape)} {sp.plural(s['n_outliers'], 'outlier')}."
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
# ----- charts -------------------------------------------------------------------------
|
|
193
|
+
def _numeric_chart(self, fn, **kw):
|
|
194
|
+
self._need("numeric", "this chart")
|
|
195
|
+
data, col = self._source()
|
|
196
|
+
return fn(data, col, **kw) if col is not None else fn(data, name=self._name, **kw)
|
|
197
|
+
|
|
198
|
+
def hist(self, **kw):
|
|
199
|
+
"""Histogram description. Takes the same options as ``spl.hist``, such as ``bins=`` and ``plot=True``."""
|
|
200
|
+
return self._numeric_chart(analyzers.hist, **kw)
|
|
201
|
+
|
|
202
|
+
def kde(self, **kw):
|
|
203
|
+
"""Density curve description."""
|
|
204
|
+
return self._numeric_chart(analyzers.kde, **kw)
|
|
205
|
+
|
|
206
|
+
def box(self, by=None, **kw):
|
|
207
|
+
"""Box plot description; ``by="column"`` gives one box per group."""
|
|
208
|
+
if by is not None:
|
|
209
|
+
self._need("numeric", "a box plot")
|
|
210
|
+
if self._frame is None:
|
|
211
|
+
raise TypeError("by= needs a variable made from a DataFrame: spl.var(df, \"column\").")
|
|
212
|
+
return analyzers.box(self._frame, self._column, by=by, **kw)
|
|
213
|
+
return self._numeric_chart(analyzers.box, **kw)
|
|
214
|
+
|
|
215
|
+
def violin(self, by=None, **kw):
|
|
216
|
+
"""Violin plot description; ``by="column"`` gives one violin per group."""
|
|
217
|
+
if by is not None:
|
|
218
|
+
self._need("numeric", "a violin plot")
|
|
219
|
+
if self._frame is None:
|
|
220
|
+
raise TypeError("by= needs a variable made from a DataFrame: spl.var(df, \"column\").")
|
|
221
|
+
return analyzers.violin(self._frame, self._column, by=by, **kw)
|
|
222
|
+
return self._numeric_chart(analyzers.violin, **kw)
|
|
223
|
+
|
|
224
|
+
def qq(self, **kw):
|
|
225
|
+
"""Normal Q-Q plot description."""
|
|
226
|
+
return self._numeric_chart(analyzers.qq, **kw)
|
|
227
|
+
|
|
228
|
+
def ecdf(self, **kw):
|
|
229
|
+
"""Cumulative distribution description."""
|
|
230
|
+
return self._numeric_chart(analyzers.ecdf, **kw)
|
|
231
|
+
|
|
232
|
+
def line(self, x=None, **kw):
|
|
233
|
+
"""Line chart over ``x`` (a column name), or over the index or row order."""
|
|
234
|
+
self._need("numeric", "a line chart")
|
|
235
|
+
if self._frame is not None:
|
|
236
|
+
return analyzers.line(self._frame, self._column, x=x, **kw)
|
|
237
|
+
return analyzers.line(self._series, x=x, name=self._name, **kw)
|
|
238
|
+
|
|
239
|
+
def vs(self, other, kind="scatter", **kw):
|
|
240
|
+
"""Compare with another numeric column: ``price.vs("carat")``.
|
|
241
|
+
|
|
242
|
+
``kind="regression"`` fits a line with this variable as the outcome.
|
|
243
|
+
``other`` can be a column name of the same DataFrame or another haptic variable.
|
|
244
|
+
"""
|
|
245
|
+
self._need("numeric", "a comparison")
|
|
246
|
+
if isinstance(other, HapticVar):
|
|
247
|
+
if other._frame is not None and other._frame is self._frame:
|
|
248
|
+
other = other._column
|
|
249
|
+
else:
|
|
250
|
+
xs, x_name = other._series, other.name
|
|
251
|
+
fn = analyzers.regression if kind == "regression" else analyzers.scatter
|
|
252
|
+
return fn(xs, self._series, x_name=x_name, y_name=self._name, **kw)
|
|
253
|
+
if self._frame is None:
|
|
254
|
+
raise TypeError("Give another haptic variable, or make this one from a DataFrame to compare by column name.")
|
|
255
|
+
fn = {"scatter": analyzers.scatter, "regression": analyzers.regression}.get(kind)
|
|
256
|
+
if fn is None:
|
|
257
|
+
raise ValueError("kind must be scatter or regression.")
|
|
258
|
+
return fn(self._frame, other, self._column, **kw)
|
|
259
|
+
|
|
260
|
+
def bar(self, **kw):
|
|
261
|
+
"""Bar chart of category counts."""
|
|
262
|
+
self._need("category", "a bar chart")
|
|
263
|
+
data, col = self._source()
|
|
264
|
+
return analyzers.bar(data, col, **kw)
|
|
265
|
+
|
|
266
|
+
def pie(self, **kw):
|
|
267
|
+
"""Pie chart of category shares."""
|
|
268
|
+
self._need("category", "a pie chart")
|
|
269
|
+
data, col = self._source()
|
|
270
|
+
return analyzers.pie(data, col, **kw)
|
|
271
|
+
|
|
272
|
+
# ----- display -----------------------------------------------------------------------------
|
|
273
|
+
def questions(self) -> Spoken:
|
|
274
|
+
"""Everything you can ask this variable."""
|
|
275
|
+
if self.kind == "numeric":
|
|
276
|
+
numbers = ("n, missing, missing_share, mean, median, std, min, max, q1, q3, iqr, skewness, kurtosis, "
|
|
277
|
+
"shape, n_outliers, outliers, lower_fence, upper_fence, unique, data")
|
|
278
|
+
calls = "summary(), percentile(p), share_below(value), hist(), kde(), box(), violin(), qq(), ecdf(), line(x), vs(other)"
|
|
279
|
+
else:
|
|
280
|
+
numbers = "n, missing, missing_share, unique, counts, n_categories, top, top_share, data"
|
|
281
|
+
calls = "summary(), bar(), pie()"
|
|
282
|
+
return Spoken(f"Numbers: {numbers}. Calls: {calls}.")
|
|
283
|
+
|
|
284
|
+
def __repr__(self) -> str:
|
|
285
|
+
if self.kind == "numeric":
|
|
286
|
+
charts = ".hist(), .kde(), .box(), .violin(), .qq(), .ecdf(), .line() or .vs(other)"
|
|
287
|
+
else:
|
|
288
|
+
charts = ".bar() or .pie()"
|
|
289
|
+
miss = "none missing" if self.missing == 0 else f"{sp.integer(self.missing)} missing"
|
|
290
|
+
return (f"Haptic variable {self._name}, {'numbers' if self.kind == 'numeric' else 'categories'}: "
|
|
291
|
+
f"{sp.plural(self.n, 'value')}, {miss}. Ask .summary(), {charts}; .questions() lists everything.")
|
|
292
|
+
|
|
293
|
+
def _ipython_display_(self):
|
|
294
|
+
print(repr(self))
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def var(data, column=None, name=None) -> HapticVar:
|
|
298
|
+
"""Declare a haptic variable.
|
|
299
|
+
|
|
300
|
+
``spl.var(df, "price")`` from a DataFrame column (recommended: allows ``by=`` and ``vs("other")``),
|
|
301
|
+
``spl.var(series)`` from a Series, or ``spl.var([1, 2, 3], name="scores")`` from a list or array.
|
|
302
|
+
"""
|
|
303
|
+
return HapticVar(data, column, name)
|
|
@@ -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,25 @@
|
|
|
1
|
+
speechplotlib/__init__.py,sha256=KwVmr_jt8dtDgkS1VbH-B3291l4uVjpkxmX8U_ksGCg,1335
|
|
2
|
+
speechplotlib/accessor.py,sha256=Rx8NEmvvusREUuA1KafDp07XcFiwZYxDjQMfGwTqko8,2936
|
|
3
|
+
speechplotlib/config.py,sha256=nxdFsRCQHBK6kpX0IyLserYESSwnB89RFmfIQuF1s0g,5065
|
|
4
|
+
speechplotlib/errors.py,sha256=x-zQUthV0zBzRvqQ7WYKxg-KQ7bljRYTjyouLj2ZAFw,265
|
|
5
|
+
speechplotlib/plotting.py,sha256=FW2m-ucYu_woZrCSUIdE60Zv_ZQm0mPLRK2RBkNaYZs,3935
|
|
6
|
+
speechplotlib/result.py,sha256=D7H7UGvQM3GDMFeIoyFVkWp-AtKdPx7jcCODvjpg9DE,6409
|
|
7
|
+
speechplotlib/rules.py,sha256=zIqu_x7QP1XHIjDLdYliYdEPaFEsHUr0M9lqMLMtlPk,3637
|
|
8
|
+
speechplotlib/session.py,sha256=v1hm4RUojhVmNkYyjLT7Ce3kNk7JJqwjQ9KR4k2p30o,2469
|
|
9
|
+
speechplotlib/speech.py,sha256=KGMjSF7TUL0igIX7nR9Jxo4JJhuR4AL0p5bKFg8xD_8,3562
|
|
10
|
+
speechplotlib/var.py,sha256=RtFUNTHDRzcBdui8ZXuueMwmHm47zUZnZSak20hq4_A,13961
|
|
11
|
+
speechplotlib/analyzers/__init__.py,sha256=6Q7Z3YXBn2pg0U_Hh8lQV2R0iccunyugpO2zomvJDWs,448
|
|
12
|
+
speechplotlib/analyzers/_input.py,sha256=_30EDwVlwa6p3JH3x69be4sLsFrEW7_IjnNaWGQZ4rI,3090
|
|
13
|
+
speechplotlib/analyzers/_stats.py,sha256=hUHlJgdlvUX-UDOue1FiTVUEy9ezmfjuQ8bhCyx5VfY,6221
|
|
14
|
+
speechplotlib/analyzers/_text.py,sha256=rGdqOvnEb_VX3oGSDY29VVM8uYXDiVnz1shvQG4rmc4,9237
|
|
15
|
+
speechplotlib/analyzers/categorical.py,sha256=38a38wAYzlUi1IEWjDbM-WyoqofLZlOh3YBFo9rkqnU,11960
|
|
16
|
+
speechplotlib/analyzers/distribution.py,sha256=NEfYXae83-kWpz3s6_iRu74M3y4tLxXw5FJncUUNozs,20923
|
|
17
|
+
speechplotlib/analyzers/model.py,sha256=Cq3n5H6r1s56RPdj0hGLM6UwV7_ns_tdpAbYLlOFgV8,26288
|
|
18
|
+
speechplotlib/analyzers/overview.py,sha256=OdSJTowhWwBoJ5QojNnNXUoCm-Yruznxcmk0FBsCJIc,8447
|
|
19
|
+
speechplotlib/analyzers/relationship.py,sha256=xVoLmRS6tSFmAKdUymqY7zP1nEKFM8pbH1KRPxcqO9I,22973
|
|
20
|
+
speechplotlib/analyzers/trend.py,sha256=1smEEBg-2Bk0hjN3-ApTve-cZS-5_WcXwLnWFE-Y49U,14529
|
|
21
|
+
speechplotlib-0.1.0.dist-info/licenses/LICENSE,sha256=dTqDJvf6oFurGWEZFydskRWhSOnpFJ2HoatPCviGCfc,1066
|
|
22
|
+
speechplotlib-0.1.0.dist-info/METADATA,sha256=ATZQ57D9NPL_yDKo5wXZDMAogavSZXrz96kQwMeRx5I,7229
|
|
23
|
+
speechplotlib-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
24
|
+
speechplotlib-0.1.0.dist-info/top_level.txt,sha256=oIW-RNJ_r-j8R-q90soNRysGFrsp49NmBwFa-mJjois,14
|
|
25
|
+
speechplotlib-0.1.0.dist-info/RECORD,,
|
|
@@ -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 @@
|
|
|
1
|
+
speechplotlib
|