noweda 0.2.2__tar.gz → 0.2.4__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.
- {noweda-0.2.2/noweda.egg-info → noweda-0.2.4}/PKG-INFO +29 -26
- {noweda-0.2.2 → noweda-0.2.4}/README.md +26 -25
- noweda-0.2.4/noweda/_version.py +1 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/accessor.py +18 -9
- {noweda-0.2.2 → noweda-0.2.4}/noweda/cli.py +3 -3
- {noweda-0.2.2 → noweda-0.2.4}/noweda/core/engine.py +8 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/large.py +30 -10
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/correlation.py +1 -1
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/outliers.py +1 -1
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/pii.py +33 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/report/html.py +15 -1
- {noweda-0.2.2 → noweda-0.2.4}/noweda/visualization.py +482 -31
- {noweda-0.2.2 → noweda-0.2.4/noweda.egg-info}/PKG-INFO +29 -26
- {noweda-0.2.2 → noweda-0.2.4}/noweda.egg-info/requires.txt +2 -0
- {noweda-0.2.2 → noweda-0.2.4}/pyproject.toml +2 -2
- {noweda-0.2.2 → noweda-0.2.4}/tests/test_large_mode.py +40 -0
- {noweda-0.2.2 → noweda-0.2.4}/tests/test_release_014.py +32 -0
- noweda-0.2.4/tests/test_vizall_ml.py +359 -0
- noweda-0.2.2/noweda/_version.py +0 -1
- noweda-0.2.2/tests/test_vizall_ml.py +0 -160
- {noweda-0.2.2 → noweda-0.2.4}/LICENSE +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/MANIFEST.in +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/examples/sample.csv +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/__init__.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/core/__init__.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/dtypes.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/insights/__init__.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/insights/generator.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/io.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/ml_recommendations.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/ml_tasks.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/ml_utils.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/__init__.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/base.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/duplicates.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/encoding.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/missing.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/schema.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/plugins/stats.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/report/__init__.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/report/json.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/scoring/__init__.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/scoring/scorer.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/temporal_utils.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda/ui.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda.egg-info/SOURCES.txt +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda.egg-info/dependency_links.txt +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda.egg-info/entry_points.txt +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/noweda.egg-info/top_level.txt +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/setup.cfg +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/setup.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/tests/test_basic.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/tests/test_formats.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/tests/test_ml_tasks.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/tests/test_progress.py +0 -0
- {noweda-0.2.2 → noweda-0.2.4}/tests/test_regressions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: noweda
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Automated EDA with insights, scoring, and security-aware detection — built as a native pandas extension.
|
|
5
5
|
Author-email: Daniel Peng <danielpeng95@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -38,6 +38,7 @@ Requires-Dist: odfpy>=1.4.1; extra == "excel"
|
|
|
38
38
|
Provides-Extra: viz
|
|
39
39
|
Requires-Dist: matplotlib>=3.5; extra == "viz"
|
|
40
40
|
Requires-Dist: scipy>=1.7; extra == "viz"
|
|
41
|
+
Requires-Dist: scikit-learn>=1.0; extra == "viz"
|
|
41
42
|
Provides-Extra: ml
|
|
42
43
|
Requires-Dist: statsmodels>=0.13; extra == "ml"
|
|
43
44
|
Requires-Dist: scikit-learn>=1.0; extra == "ml"
|
|
@@ -46,6 +47,7 @@ Requires-Dist: pytest>=7; extra == "test"
|
|
|
46
47
|
Requires-Dist: odfpy>=1.4.1; extra == "test"
|
|
47
48
|
Requires-Dist: matplotlib>=3.5; extra == "test"
|
|
48
49
|
Requires-Dist: scipy>=1.7; extra == "test"
|
|
50
|
+
Requires-Dist: scikit-learn>=1.0; extra == "test"
|
|
49
51
|
Provides-Extra: hdf
|
|
50
52
|
Requires-Dist: tables>=3.7; extra == "hdf"
|
|
51
53
|
Provides-Extra: spss
|
|
@@ -70,9 +72,7 @@ Dynamic: license-file
|
|
|
70
72
|
|
|
71
73
|
# NowEDA
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
find missing data and duplicates, flag potential PII, explore relationships,
|
|
75
|
-
and generate reports with `df.eda` or its equivalent alias `df.noweda`.
|
|
75
|
+
NowEDA helps you explore a pandas table and choose a first machine learning model to try. Use `df.eda` to inspect your data, see how columns relate to an outcome, and get a shortlist of models to test.
|
|
76
76
|
|
|
77
77
|
[Documentation](https://codewithdaniel1.github.io/NowEDA/) ·
|
|
78
78
|
[API reference](https://codewithdaniel1.github.io/NowEDA/api-reference/) ·
|
|
@@ -91,31 +91,31 @@ pip install "noweda[viz]" # Add charts and density overlays
|
|
|
91
91
|
|
|
92
92
|
## Quick start
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
Which flower species can we predict from its measurements? In this example, the
|
|
95
|
+
**target** is the species we want to predict. The **features** are the measurements
|
|
96
|
+
we will know when we make a prediction.
|
|
97
|
+
|
|
98
|
+
Install `noweda[viz]` for this example. The flower dataset comes with scikit-learn
|
|
99
|
+
and runs offline.
|
|
95
100
|
|
|
96
101
|
```python
|
|
97
|
-
import pandas as pd
|
|
98
102
|
import noweda as eda
|
|
103
|
+
from sklearn.datasets import load_iris
|
|
99
104
|
|
|
100
|
-
#
|
|
101
|
-
df
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
# Start with one complete assessment.
|
|
108
|
-
df.eda.statsall()
|
|
109
|
-
|
|
110
|
-
# With noweda[viz], rank general charts within a panel budget.
|
|
111
|
-
# df.eda.vizall(max_plots=10)
|
|
105
|
+
df = load_iris(as_frame=True).frame # For your own table: eda.read("flowers.csv")
|
|
106
|
+
df.eda.statsall() # Are there missing values or duplicates?
|
|
107
|
+
charts = df.eda.vizall(target="target")
|
|
108
|
+
df.eda.mlall(target="target") # Which models are worth trying first?
|
|
109
|
+
```
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
In the boundary charts, each dot is a flower the models did not see during
|
|
112
|
+
training. Look for crosses where a model predicted the wrong species. If a
|
|
113
|
+
straight boundary and a curved boundary make similar mistakes, try the simpler
|
|
114
|
+
linear model first. A prediction of a number, such as a price, is a regression
|
|
115
|
+
task. Its chart shows how far each prediction falls from the observed value.
|
|
115
116
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
```
|
|
117
|
+
Follow a complete customer churn example in the
|
|
118
|
+
[playground notebook](https://github.com/codewithdaniel1/NowEDA/blob/main/playground.ipynb).
|
|
119
119
|
|
|
120
120
|
### Large files
|
|
121
121
|
|
|
@@ -131,8 +131,8 @@ data.eda.mlall(target="fraud_flag")
|
|
|
131
131
|
```
|
|
132
132
|
|
|
133
133
|
Large mode calculates the dataset dimensions exactly. Exploratory findings,
|
|
134
|
-
charts, profiles, comparisons, and ML guidance use a
|
|
135
|
-
|
|
134
|
+
charts, profiles, comparisons, and ML guidance use a repeatable sample drawn
|
|
135
|
+
from across the file. Each method prints how many rows it used.
|
|
136
136
|
`statsall()`, `vizall()`, and `mlall()` use `sample=10_000` by default in large
|
|
137
137
|
mode; pass another positive integer to adjust that scope. In small mode those
|
|
138
138
|
methods use every loaded row by default, and accept the same `sample=` override.
|
|
@@ -203,6 +203,8 @@ missingness, outliers, feature scales, and applicable temporal plots. Supply the
|
|
|
203
203
|
prediction target to add classification or regression diagnostics. NowEDA ranks
|
|
204
204
|
useful features, excludes likely identifiers and detected PII, and describes
|
|
205
205
|
model-family signals without claiming that a chart proves the best model.
|
|
206
|
+
Where applicable, it fits bounded visual baselines for linear regression,
|
|
207
|
+
logistic probability, linear and nonlinear SVM boundaries, and K-Means.
|
|
206
208
|
|
|
207
209
|
```python
|
|
208
210
|
df.eda.vizall() # General and unsupervised structure
|
|
@@ -212,6 +214,7 @@ visuals = df.eda.vizall(
|
|
|
212
214
|
max_plots=15,
|
|
213
215
|
)
|
|
214
216
|
print(visuals["model_signals"])
|
|
217
|
+
print(visuals["diagnostic_models"])
|
|
215
218
|
|
|
216
219
|
df.eda.vizall(sample=5_000) # Optional bounded sample
|
|
217
220
|
```
|
|
@@ -284,7 +287,7 @@ df = eda.read("data.csv", dtype={"customer_id": str})
|
|
|
284
287
|
| Parquet, Feather, ORC | Included with `pip install noweda` |
|
|
285
288
|
| HDF5 | `pip install "noweda[hdf]"` |
|
|
286
289
|
| SPSS | `pip install "noweda[spss]"` |
|
|
287
|
-
| Charts
|
|
290
|
+
| Charts, KDE overlays, and fitted visual diagnostics | `pip install "noweda[viz]"` |
|
|
288
291
|
| Stationarity and seasonality dependencies | `pip install "noweda[ml]"` |
|
|
289
292
|
| All optional analysis and format dependencies | `pip install "noweda[full]"` |
|
|
290
293
|
|
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# NowEDA
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
find missing data and duplicates, flag potential PII, explore relationships,
|
|
11
|
-
and generate reports with `df.eda` or its equivalent alias `df.noweda`.
|
|
9
|
+
NowEDA helps you explore a pandas table and choose a first machine learning model to try. Use `df.eda` to inspect your data, see how columns relate to an outcome, and get a shortlist of models to test.
|
|
12
10
|
|
|
13
11
|
[Documentation](https://codewithdaniel1.github.io/NowEDA/) ·
|
|
14
12
|
[API reference](https://codewithdaniel1.github.io/NowEDA/api-reference/) ·
|
|
@@ -27,31 +25,31 @@ pip install "noweda[viz]" # Add charts and density overlays
|
|
|
27
25
|
|
|
28
26
|
## Quick start
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
Which flower species can we predict from its measurements? In this example, the
|
|
29
|
+
**target** is the species we want to predict. The **features** are the measurements
|
|
30
|
+
we will know when we make a prediction.
|
|
31
|
+
|
|
32
|
+
Install `noweda[viz]` for this example. The flower dataset comes with scikit-learn
|
|
33
|
+
and runs offline.
|
|
31
34
|
|
|
32
35
|
```python
|
|
33
|
-
import pandas as pd
|
|
34
36
|
import noweda as eda
|
|
37
|
+
from sklearn.datasets import load_iris
|
|
35
38
|
|
|
36
|
-
#
|
|
37
|
-
df
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
# Start with one complete assessment.
|
|
44
|
-
df.eda.statsall()
|
|
45
|
-
|
|
46
|
-
# With noweda[viz], rank general charts within a panel budget.
|
|
47
|
-
# df.eda.vizall(max_plots=10)
|
|
39
|
+
df = load_iris(as_frame=True).frame # For your own table: eda.read("flowers.csv")
|
|
40
|
+
df.eda.statsall() # Are there missing values or duplicates?
|
|
41
|
+
charts = df.eda.vizall(target="target")
|
|
42
|
+
df.eda.mlall(target="target") # Which models are worth trying first?
|
|
43
|
+
```
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
In the boundary charts, each dot is a flower the models did not see during
|
|
46
|
+
training. Look for crosses where a model predicted the wrong species. If a
|
|
47
|
+
straight boundary and a curved boundary make similar mistakes, try the simpler
|
|
48
|
+
linear model first. A prediction of a number, such as a price, is a regression
|
|
49
|
+
task. Its chart shows how far each prediction falls from the observed value.
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
```
|
|
51
|
+
Follow a complete customer churn example in the
|
|
52
|
+
[playground notebook](https://github.com/codewithdaniel1/NowEDA/blob/main/playground.ipynb).
|
|
55
53
|
|
|
56
54
|
### Large files
|
|
57
55
|
|
|
@@ -67,8 +65,8 @@ data.eda.mlall(target="fraud_flag")
|
|
|
67
65
|
```
|
|
68
66
|
|
|
69
67
|
Large mode calculates the dataset dimensions exactly. Exploratory findings,
|
|
70
|
-
charts, profiles, comparisons, and ML guidance use a
|
|
71
|
-
|
|
68
|
+
charts, profiles, comparisons, and ML guidance use a repeatable sample drawn
|
|
69
|
+
from across the file. Each method prints how many rows it used.
|
|
72
70
|
`statsall()`, `vizall()`, and `mlall()` use `sample=10_000` by default in large
|
|
73
71
|
mode; pass another positive integer to adjust that scope. In small mode those
|
|
74
72
|
methods use every loaded row by default, and accept the same `sample=` override.
|
|
@@ -139,6 +137,8 @@ missingness, outliers, feature scales, and applicable temporal plots. Supply the
|
|
|
139
137
|
prediction target to add classification or regression diagnostics. NowEDA ranks
|
|
140
138
|
useful features, excludes likely identifiers and detected PII, and describes
|
|
141
139
|
model-family signals without claiming that a chart proves the best model.
|
|
140
|
+
Where applicable, it fits bounded visual baselines for linear regression,
|
|
141
|
+
logistic probability, linear and nonlinear SVM boundaries, and K-Means.
|
|
142
142
|
|
|
143
143
|
```python
|
|
144
144
|
df.eda.vizall() # General and unsupervised structure
|
|
@@ -148,6 +148,7 @@ visuals = df.eda.vizall(
|
|
|
148
148
|
max_plots=15,
|
|
149
149
|
)
|
|
150
150
|
print(visuals["model_signals"])
|
|
151
|
+
print(visuals["diagnostic_models"])
|
|
151
152
|
|
|
152
153
|
df.eda.vizall(sample=5_000) # Optional bounded sample
|
|
153
154
|
```
|
|
@@ -220,7 +221,7 @@ df = eda.read("data.csv", dtype={"customer_id": str})
|
|
|
220
221
|
| Parquet, Feather, ORC | Included with `pip install noweda` |
|
|
221
222
|
| HDF5 | `pip install "noweda[hdf]"` |
|
|
222
223
|
| SPSS | `pip install "noweda[spss]"` |
|
|
223
|
-
| Charts
|
|
224
|
+
| Charts, KDE overlays, and fitted visual diagnostics | `pip install "noweda[viz]"` |
|
|
224
225
|
| Stationarity and seasonality dependencies | `pip install "noweda[ml]"` |
|
|
225
226
|
| All optional analysis and format dependencies | `pip install "noweda[full]"` |
|
|
226
227
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.4"
|
|
@@ -360,6 +360,7 @@ class NowEDAAccessor:
|
|
|
360
360
|
insights = report["insights"]
|
|
361
361
|
stats = results.get("stats", {})
|
|
362
362
|
schema = results.get("schema", {})
|
|
363
|
+
pii = results.get("pii", {})
|
|
363
364
|
|
|
364
365
|
_BOLD = "\033[1m"
|
|
365
366
|
_CYAN = "\033[36m"
|
|
@@ -401,7 +402,7 @@ class NowEDAAccessor:
|
|
|
401
402
|
risk = scores.get("risk", "N/A")
|
|
402
403
|
print(f" Data Quality : {score_color(dq) if isinstance(dq, (int,float)) else dq} out of 100")
|
|
403
404
|
print(f" Model Readiness : {score_color(mr) if isinstance(mr, (int,float)) else mr} out of 100")
|
|
404
|
-
print(f" Risk : {_RED if isinstance(risk,(int,float)) and risk>0 else _GREEN}{risk}{_RESET} (0 = no
|
|
405
|
+
print(f" Risk : {_RED if isinstance(risk,(int,float)) and risk>0 else _GREEN}{risk}{_RESET} (0 = no signals detected)")
|
|
405
406
|
|
|
406
407
|
# ── Dtypes ───────────────────────────────────────────────────────────
|
|
407
408
|
h2("Column Types")
|
|
@@ -426,7 +427,7 @@ class NowEDAAccessor:
|
|
|
426
427
|
h2("Descriptive Statistics")
|
|
427
428
|
|
|
428
429
|
# Numeric columns
|
|
429
|
-
num_cols = [c for c in df.columns if df[c].dtype.kind in ("i", "u", "f")]
|
|
430
|
+
num_cols = [c for c in df.columns if df[c].dtype.kind in ("i", "u", "f") and c not in pii]
|
|
430
431
|
if num_cols:
|
|
431
432
|
print(f"\n {'Column':<{col_w}} {'Count':>8} {'Mean':>12} {'Std':>12} {'Min':>10} {'25%':>10} {'50%':>10} {'75%':>10} {'Max':>10} {'Skew':>8}")
|
|
432
433
|
print(f" {'-'*col_w} {'--------':>8} {'------------':>12} {'------------':>12} {'----------':>10} {'----------':>10} {'----------':>10} {'----------':>10} {'----------':>10} {'--------':>8}")
|
|
@@ -461,7 +462,7 @@ class NowEDAAccessor:
|
|
|
461
462
|
s = stats.get(col, {})
|
|
462
463
|
count = s.get("count", 0)
|
|
463
464
|
uniq = s.get("unique", 0)
|
|
464
|
-
top = str(s.get("top_value", "N/A"))[:26]
|
|
465
|
+
top = str(s.get("top_value", "Hidden" if col in pii else "N/A"))[:26]
|
|
465
466
|
freq = s.get("top_freq", 0)
|
|
466
467
|
|
|
467
468
|
# Calculate diversity: entropy-based (0=one dominant, 1=uniform)
|
|
@@ -583,7 +584,6 @@ class NowEDAAccessor:
|
|
|
583
584
|
else:
|
|
584
585
|
print(" Outliers : none")
|
|
585
586
|
|
|
586
|
-
pii = results.get("pii", {})
|
|
587
587
|
if pii:
|
|
588
588
|
pii_columns = ", ".join(map(str, list(pii)[:4]))
|
|
589
589
|
suffix = f" and {len(pii) - 4} more" if len(pii) > 4 else ""
|
|
@@ -603,7 +603,6 @@ class NowEDAAccessor:
|
|
|
603
603
|
h2("ML Preprocessing Recommendations")
|
|
604
604
|
|
|
605
605
|
# Multicollinearity
|
|
606
|
-
num_cols = [c for c in df.columns if df[c].dtype.kind in ("i", "u", "f")]
|
|
607
606
|
preprocessing_cols = []
|
|
608
607
|
vif_cols = []
|
|
609
608
|
excluded_preprocessing_cols = []
|
|
@@ -673,7 +672,6 @@ class NowEDAAccessor:
|
|
|
673
672
|
# Role-aware feature review. High uniqueness is normal for continuous
|
|
674
673
|
# numeric values and means something different for IDs, PII, dates,
|
|
675
674
|
# free text, and true categorical values.
|
|
676
|
-
pii = results.get("pii", {})
|
|
677
675
|
feature_review = []
|
|
678
676
|
for col in df.columns:
|
|
679
677
|
role = schema.get(col, {}).get("role", "unknown")
|
|
@@ -693,6 +691,8 @@ class NowEDAAccessor:
|
|
|
693
691
|
# Rare categories
|
|
694
692
|
rare_issues = {}
|
|
695
693
|
for col in df.columns:
|
|
694
|
+
if col in pii:
|
|
695
|
+
continue
|
|
696
696
|
role = schema.get(col, {}).get("role", "unknown")
|
|
697
697
|
rare = rare_category_detection(df[col], threshold=0.01, role=role)
|
|
698
698
|
if rare:
|
|
@@ -732,7 +732,9 @@ class NowEDAAccessor:
|
|
|
732
732
|
``vizall()`` selects a bounded set of general diagnostics. Supplying a
|
|
733
733
|
target adds supervised feature-versus-target charts while preserving
|
|
734
734
|
the existing workflow. The returned dictionary-like result contains
|
|
735
|
-
the figures, ranked evidence, selected features,
|
|
735
|
+
the figures, ranked evidence, selected features, fitted diagnostic
|
|
736
|
+
baselines, and scope metadata. These bounded visual fits are examples
|
|
737
|
+
for comparison rather than final model recommendations.
|
|
736
738
|
|
|
737
739
|
Parameters
|
|
738
740
|
----------
|
|
@@ -788,9 +790,12 @@ class NowEDAAccessor:
|
|
|
788
790
|
|
|
789
791
|
target_values = self._df.iloc[:, self._df.columns.get_loc(target)]
|
|
790
792
|
if target_values.notna().any():
|
|
793
|
+
positions = [self._df.columns.get_loc(column) for column in result["features"] + [target]]
|
|
791
794
|
visual = build_visual_diagnostics(
|
|
792
|
-
self._df, self._report,
|
|
795
|
+
self._df.iloc[:, positions], self._report,
|
|
796
|
+
target=target, problem_type=result["problem_type"],
|
|
793
797
|
)
|
|
798
|
+
visual["target_summary"]["inference_reason"] = result["inference_reason"] or "user-selected prediction task"
|
|
794
799
|
result["visual_diagnostics"] = {
|
|
795
800
|
key: value for key, value in visual.items()
|
|
796
801
|
if key not in {"numeric_scales"}
|
|
@@ -798,7 +803,7 @@ class NowEDAAccessor:
|
|
|
798
803
|
format_ml_plan(result)
|
|
799
804
|
visual = result.get("visual_diagnostics")
|
|
800
805
|
if visual and visual.get("model_signals"):
|
|
801
|
-
print("\n
|
|
806
|
+
print("\n What the selected features suggest:")
|
|
802
807
|
for signal in visual["model_signals"]:
|
|
803
808
|
print(" - {}".format(signal))
|
|
804
809
|
if plan:
|
|
@@ -846,6 +851,10 @@ class NowEDAAccessor:
|
|
|
846
851
|
print(f" Unique Values : {col.nunique()}")
|
|
847
852
|
print(f" Missing : {col.isna().sum()} ({col.isna().sum() / len(col) * 100:.1f}%)")
|
|
848
853
|
|
|
854
|
+
if column_name in results.get("pii", {}):
|
|
855
|
+
print(" Values hidden because this column contains personal data signals.")
|
|
856
|
+
return
|
|
857
|
+
|
|
849
858
|
# Numeric-specific analysis
|
|
850
859
|
if col.dtype.kind in ('i', 'u', 'f'):
|
|
851
860
|
print(f"\n{_BOLD}Numeric Statistics:{_RESET}")
|
|
@@ -65,7 +65,7 @@ def main():
|
|
|
65
65
|
print(f" Data Quality : {_score_color(dq)} out of 100")
|
|
66
66
|
print(f" Model Readiness : {_score_color(mr)} out of 100")
|
|
67
67
|
risk_col = f"{_RED}{risk}{_RESET}" if isinstance(risk, (int, float)) and risk > 0 else f"{_GREEN}{risk}{_RESET}"
|
|
68
|
-
print(f" Risk : {risk_col} (0 = no
|
|
68
|
+
print(f" Risk : {risk_col} (0 = no signals detected)")
|
|
69
69
|
|
|
70
70
|
# ── Column Overview ───────────────────────────────────────────────────────
|
|
71
71
|
print(f"\n{_BOLD}Columns{_RESET}\n{thin}")
|
|
@@ -82,7 +82,7 @@ def main():
|
|
|
82
82
|
print(f" {str(col):<{col_w}} {dtype:<14} {role:<{role_w}} {uniq:>8} {miss_s:>8}")
|
|
83
83
|
|
|
84
84
|
# ── Numeric Stats ────────────────────────────────────────────────────────
|
|
85
|
-
num_cols = [c for c in df.columns if df[c].dtype.kind in ("i", "u", "f")]
|
|
85
|
+
num_cols = [c for c in df.columns if df[c].dtype.kind in ("i", "u", "f") and c not in results.get("pii", {})]
|
|
86
86
|
if num_cols:
|
|
87
87
|
print(f"\n{_BOLD}Numeric Statistics{_RESET}\n{thin}")
|
|
88
88
|
print(f" {'Column':<{col_w}} {'Count':>8} {'Mean':>12} {'Std':>12} {'Min':>10} {'25%':>10} {'50%':>10} {'75%':>10} {'Max':>10} {'Skew':>8}")
|
|
@@ -113,7 +113,7 @@ def main():
|
|
|
113
113
|
s = stats.get(col, {})
|
|
114
114
|
count = s.get("count", 0)
|
|
115
115
|
uniq = s.get("unique", 0)
|
|
116
|
-
top = str(s.get("top_value", "N/A"))[:28]
|
|
116
|
+
top = str(s.get("top_value", "Hidden" if col in results.get("pii", {}) else "N/A"))[:28]
|
|
117
117
|
freq = s.get("top_freq", 0)
|
|
118
118
|
print(f" {str(col):<{col_w}} {count:>8,} {uniq:>8} {top:<30} {freq:>8,}")
|
|
119
119
|
|
|
@@ -17,6 +17,14 @@ class AutoEDAEngine:
|
|
|
17
17
|
if plugin.name == "encoding":
|
|
18
18
|
encoding_details = getattr(plugin, "details", {})
|
|
19
19
|
|
|
20
|
+
# A most common value, a minimum, or even the mean of one record can
|
|
21
|
+
# expose a contact detail. Keep counts for flagged columns in reports.
|
|
22
|
+
stats = results.get("stats", {})
|
|
23
|
+
counts = {"dtype", "count", "missing", "unique", "top_freq"}
|
|
24
|
+
for column in results.get("pii", {}):
|
|
25
|
+
if column in stats:
|
|
26
|
+
stats[column] = {key: value for key, value in stats[column].items() if key in counts}
|
|
27
|
+
|
|
20
28
|
scores, breakdown = Scorer().compute(results, explain=True)
|
|
21
29
|
insights = (["Empty DataFrame: no rows or no columns to analyze. Scores are not informative."]
|
|
22
30
|
if df.empty else InsightGenerator().generate(results, scores))
|
|
@@ -8,7 +8,6 @@ Every method that uses that sample announces it before returning a result.
|
|
|
8
8
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
-
import os
|
|
12
11
|
from pathlib import Path
|
|
13
12
|
from typing import Any, Optional
|
|
14
13
|
|
|
@@ -18,6 +17,14 @@ import pandas as pd
|
|
|
18
17
|
_LARGE_FORMATS = {".csv", ".tsv", ".tab", ".txt", ".parquet"}
|
|
19
18
|
|
|
20
19
|
|
|
20
|
+
def _analysis_rows(sample):
|
|
21
|
+
if sample is None:
|
|
22
|
+
return 10_000
|
|
23
|
+
if isinstance(sample, bool) or not isinstance(sample, int) or sample <= 0:
|
|
24
|
+
raise ValueError("sample must be a positive integer")
|
|
25
|
+
return sample
|
|
26
|
+
|
|
27
|
+
|
|
21
28
|
class LargeDataset:
|
|
22
29
|
"""A disk-backed NowEDA dataset returned by ``eda.read(mode='large')``.
|
|
23
30
|
|
|
@@ -31,13 +38,14 @@ class LargeDataset:
|
|
|
31
38
|
self.path = str(Path(file_path))
|
|
32
39
|
self.chunksize = chunksize
|
|
33
40
|
self.read_kwargs = read_kwargs
|
|
34
|
-
self.
|
|
41
|
+
self._cached_sample = None
|
|
35
42
|
self._row_count: Optional[int] = None
|
|
36
43
|
self._columns: Optional[list[str]] = None
|
|
37
44
|
self._accessor: Optional[LargeEDAAccessor] = None
|
|
38
45
|
|
|
39
46
|
self._duckdb = self._require_duckdb()
|
|
40
|
-
|
|
47
|
+
# A seeded reservoir is repeatable when the file scan uses one thread.
|
|
48
|
+
self._connection = self._duckdb.connect(":memory:", config={"threads": 1})
|
|
41
49
|
self._create_source_view()
|
|
42
50
|
|
|
43
51
|
@staticmethod
|
|
@@ -106,13 +114,22 @@ class LargeDataset:
|
|
|
106
114
|
|
|
107
115
|
def _sample(self, rows: Optional[int] = None) -> pd.DataFrame:
|
|
108
116
|
rows = min(rows if rows is not None else self.chunksize, self.row_count)
|
|
109
|
-
if
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
if self._cached_sample is None or len(self._cached_sample) != rows:
|
|
118
|
+
if rows == self.row_count:
|
|
119
|
+
self._cached_sample = self.head(rows)
|
|
120
|
+
else:
|
|
121
|
+
# Keep original order for temporal analysis. DuckDB needs a
|
|
122
|
+
# literal reservoir size; rows comes from validated integers.
|
|
123
|
+
ordinal = "_noweda_row"
|
|
124
|
+
names = {name.lower() for name in self.columns}
|
|
125
|
+
while ordinal in names:
|
|
126
|
+
ordinal += "_"
|
|
127
|
+
self._cached_sample = self._connection.execute(
|
|
128
|
+
f"SELECT * EXCLUDE ({ordinal}) FROM "
|
|
129
|
+
f"(SELECT *, row_number() OVER () AS {ordinal} FROM noweda_source) "
|
|
130
|
+
f"USING SAMPLE reservoir({rows} ROWS) REPEATABLE (42) ORDER BY {ordinal}"
|
|
131
|
+
).fetchdf()
|
|
132
|
+
return self._cached_sample
|
|
116
133
|
|
|
117
134
|
@property
|
|
118
135
|
def eda(self) -> "LargeEDAAccessor":
|
|
@@ -151,6 +168,7 @@ class LargeEDAAccessor:
|
|
|
151
168
|
|
|
152
169
|
def statsall(self, sample=10_000):
|
|
153
170
|
"""Print exploratory analysis from a bounded sample; row count is exact."""
|
|
171
|
+
sample = _analysis_rows(sample)
|
|
154
172
|
self._announce_sample("statsall()", rows=sample)
|
|
155
173
|
print(f"Exact dataset size: {self._dataset.row_count:,} rows × {len(self._dataset.columns)} columns")
|
|
156
174
|
return self._pandas_accessor(sample).statsall(sample=sample)
|
|
@@ -174,6 +192,7 @@ class LargeEDAAccessor:
|
|
|
174
192
|
|
|
175
193
|
def vizall(self, sample=10_000, target=None, max_plots=15):
|
|
176
194
|
"""Render ranked charts from the large-mode sample."""
|
|
195
|
+
sample = _analysis_rows(sample)
|
|
177
196
|
self._announce_sample("vizall()", rows=sample)
|
|
178
197
|
# Do not let the pandas accessor take a second, hidden sample of the
|
|
179
198
|
# already bounded large-mode sample. An explicit ``sample=`` remains
|
|
@@ -190,6 +209,7 @@ class LargeEDAAccessor:
|
|
|
190
209
|
|
|
191
210
|
def mlall(self, target=None, problem_type=None, features=None, plan=False, sample=10_000):
|
|
192
211
|
"""Create ML guidance from the sample and identify it as estimated."""
|
|
212
|
+
sample = _analysis_rows(sample)
|
|
193
213
|
self._announce_sample("mlall()", rows=sample)
|
|
194
214
|
return self._pandas_accessor(sample).mlall(
|
|
195
215
|
target=target, problem_type=problem_type, features=features, plan=plan,
|
|
@@ -4,7 +4,7 @@ class CorrelationPlugin(BasePlugin):
|
|
|
4
4
|
name = "correlation"
|
|
5
5
|
|
|
6
6
|
def run(self, df):
|
|
7
|
-
numeric_df = df.select_dtypes(include="number")
|
|
7
|
+
numeric_df = df.select_dtypes(include="number", exclude="bool")
|
|
8
8
|
if numeric_df.empty:
|
|
9
9
|
return {}
|
|
10
10
|
return numeric_df.corr().to_dict()
|
|
@@ -6,7 +6,7 @@ class OutlierPlugin(BasePlugin):
|
|
|
6
6
|
def run(self, df):
|
|
7
7
|
result = {}
|
|
8
8
|
|
|
9
|
-
for col in df.select_dtypes(include="number").columns:
|
|
9
|
+
for col in df.select_dtypes(include="number", exclude="bool").columns:
|
|
10
10
|
q1 = df[col].quantile(0.25)
|
|
11
11
|
q3 = df[col].quantile(0.75)
|
|
12
12
|
iqr = q3 - q1
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Pattern-based PII signals, counted once per matching cell and type."""
|
|
2
2
|
import re
|
|
3
|
+
import math
|
|
3
4
|
|
|
4
5
|
from noweda.dtypes import is_textual
|
|
5
6
|
from .base import BasePlugin
|
|
@@ -22,6 +23,11 @@ class PIIDetectorPlugin(BasePlugin):
|
|
|
22
23
|
findings = {}
|
|
23
24
|
patterns = dict(self.PATTERNS)
|
|
24
25
|
for col in df.columns:
|
|
26
|
+
if df[col].dtype.kind in ("i", "u", "f"):
|
|
27
|
+
finding = self._numeric_signal(col, df[col])
|
|
28
|
+
if finding:
|
|
29
|
+
findings[col] = finding
|
|
30
|
+
continue
|
|
25
31
|
if not is_textual(df[col]):
|
|
26
32
|
continue
|
|
27
33
|
counts = dict.fromkeys(patterns, 0)
|
|
@@ -43,6 +49,33 @@ class PIIDetectorPlugin(BasePlugin):
|
|
|
43
49
|
findings[col] = {kind: count for kind, count in counts.items() if count}
|
|
44
50
|
return findings
|
|
45
51
|
|
|
52
|
+
def _numeric_signal(self, column, series):
|
|
53
|
+
# CSV readers often infer phone and card columns as numbers.
|
|
54
|
+
name = re.sub(r"([a-z])([A-Z])", r"\1_\2", str(column)).lower()
|
|
55
|
+
words = set(re.findall(r"[a-z]+", name))
|
|
56
|
+
if words & {"phone", "telephone", "mobile", "cellphone"}:
|
|
57
|
+
kind = "phone"
|
|
58
|
+
elif "card" in words:
|
|
59
|
+
kind = "credit_card"
|
|
60
|
+
elif "ssn" in words:
|
|
61
|
+
kind = "ssn"
|
|
62
|
+
else:
|
|
63
|
+
return {}
|
|
64
|
+
count = 0
|
|
65
|
+
for value in series.dropna():
|
|
66
|
+
if series.dtype.kind == "f" and (
|
|
67
|
+
not math.isfinite(value) or not value.is_integer() or abs(value) >= 2**53
|
|
68
|
+
):
|
|
69
|
+
continue
|
|
70
|
+
digits = str(int(value))
|
|
71
|
+
if kind == "credit_card":
|
|
72
|
+
count += self._valid_card(digits)
|
|
73
|
+
elif kind == "phone":
|
|
74
|
+
count += bool(re.fullmatch(r"1?[0-9]{10}", digits))
|
|
75
|
+
else:
|
|
76
|
+
count += bool(re.fullmatch(r"[0-9]{9}", digits))
|
|
77
|
+
return {kind: count} if count else {}
|
|
78
|
+
|
|
46
79
|
def _valid_card(self, value):
|
|
47
80
|
digits = re.sub(r"[ -]", "", value)
|
|
48
81
|
return bool(self._CARD_NUMBER.fullmatch(digits)) and self._luhn_check(digits)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
|
+
from math import isfinite
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
def generate_html_report(report, output_path):
|
|
@@ -27,6 +28,15 @@ def generate_html_report(report, output_path):
|
|
|
27
28
|
breakdown_html = _score_breakdown_table(report.get("score_breakdown", []))
|
|
28
29
|
|
|
29
30
|
generated_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
31
|
+
scope_html = ""
|
|
32
|
+
if "large_mode" in report:
|
|
33
|
+
scope = report["large_mode"]
|
|
34
|
+
rows, analyzed = scope["rows"], scope["sample_rows"]
|
|
35
|
+
description = (
|
|
36
|
+
f"Results use a sample of {analyzed:,} of {rows:,} rows drawn across the file."
|
|
37
|
+
if analyzed < rows else f"Results use all {rows:,} rows."
|
|
38
|
+
)
|
|
39
|
+
scope_html = f'<p>{description} The file has {scope["columns"]:,} columns.</p>'
|
|
30
40
|
|
|
31
41
|
html = f"""<!DOCTYPE html>
|
|
32
42
|
<html lang="en">
|
|
@@ -86,6 +96,7 @@ def generate_html_report(report, output_path):
|
|
|
86
96
|
<div class="header">
|
|
87
97
|
<h1>NowEDA Report</h1>
|
|
88
98
|
<div class="meta">Generated: {generated_at}</div>
|
|
99
|
+
{scope_html}
|
|
89
100
|
</div>
|
|
90
101
|
|
|
91
102
|
<div class="scores-grid">
|
|
@@ -97,7 +108,7 @@ def generate_html_report(report, output_path):
|
|
|
97
108
|
<div class="score-card">
|
|
98
109
|
<div class="label">Risk Level</div>
|
|
99
110
|
<div class="value" style="color:{risk_color}">{risk}</div>
|
|
100
|
-
<div class="sub">
|
|
111
|
+
<div class="sub">0 = no signals detected</div>
|
|
101
112
|
</div>
|
|
102
113
|
<div class="score-card">
|
|
103
114
|
<div class="label">Model Readiness</div>
|
|
@@ -200,6 +211,9 @@ def _missing_table(missing):
|
|
|
200
211
|
return ""
|
|
201
212
|
rows = ""
|
|
202
213
|
for col, pct in sorted(missing.items(), key=lambda x: -x[1]):
|
|
214
|
+
if not isfinite(pct):
|
|
215
|
+
rows += f"<tr><td>{_escape(col)}</td><td>No observations</td></tr>"
|
|
216
|
+
continue
|
|
203
217
|
pct_int = int(pct * 100)
|
|
204
218
|
bar_color = "#f87171" if pct > 0.3 else ("#facc15" if pct > 0 else "#4ade80")
|
|
205
219
|
bar = (
|