frameprep 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.
- frameprep-0.1.0/LICENSE +21 -0
- frameprep-0.1.0/PKG-INFO +292 -0
- frameprep-0.1.0/README.md +231 -0
- frameprep-0.1.0/frameprep/__init__.py +27 -0
- frameprep-0.1.0/frameprep/core/__init__.py +4 -0
- frameprep-0.1.0/frameprep/core/dtype_inferrer.py +238 -0
- frameprep-0.1.0/frameprep/core/missing_strategy.py +260 -0
- frameprep-0.1.0/frameprep/detectors/__init__.py +3 -0
- frameprep-0.1.0/frameprep/detectors/leakage.py +168 -0
- frameprep-0.1.0/frameprep/encoders/__init__.py +3 -0
- frameprep-0.1.0/frameprep/encoders/categorical.py +201 -0
- frameprep-0.1.0/frameprep/pipeline.py +222 -0
- frameprep-0.1.0/frameprep/reports/__init__.py +3 -0
- frameprep-0.1.0/frameprep/reports/audit.py +221 -0
- frameprep-0.1.0/frameprep/scalers/__init__.py +3 -0
- frameprep-0.1.0/frameprep/scalers/numeric.py +110 -0
- frameprep-0.1.0/frameprep/utils/__init__.py +4 -0
- frameprep-0.1.0/frameprep/utils/logger.py +41 -0
- frameprep-0.1.0/frameprep/utils/validators.py +63 -0
- frameprep-0.1.0/frameprep.egg-info/PKG-INFO +292 -0
- frameprep-0.1.0/frameprep.egg-info/SOURCES.txt +24 -0
- frameprep-0.1.0/frameprep.egg-info/dependency_links.txt +1 -0
- frameprep-0.1.0/frameprep.egg-info/requires.txt +16 -0
- frameprep-0.1.0/frameprep.egg-info/top_level.txt +1 -0
- frameprep-0.1.0/pyproject.toml +109 -0
- frameprep-0.1.0/setup.cfg +4 -0
frameprep-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rahul Reddy
|
|
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.
|
frameprep-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: frameprep
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Automated ML-Ready Data Preparation Library
|
|
5
|
+
Author-email: Rahul Reddy <rahulreddy9725@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Rahul Reddy
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/rahulreddy9725/frameprep
|
|
29
|
+
Project-URL: Documentation, https://github.com/rahulreddy9725/frameprep/blob/main/README.md
|
|
30
|
+
Project-URL: Bug Tracker, https://github.com/rahulreddy9725/frameprep/issues
|
|
31
|
+
Project-URL: Changelog, https://github.com/rahulreddy9725/frameprep/blob/main/CHANGELOG.md
|
|
32
|
+
Keywords: machine learning,data preparation,preprocessing,feature engineering,data science,imputation,encoding,leakage detection
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: Intended Audience :: Science/Research
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
42
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
43
|
+
Requires-Python: >=3.9
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
46
|
+
Requires-Dist: numpy>=1.24
|
|
47
|
+
Requires-Dist: pandas>=2.0
|
|
48
|
+
Requires-Dist: scikit-learn>=1.3
|
|
49
|
+
Requires-Dist: scipy>=1.10
|
|
50
|
+
Provides-Extra: dev
|
|
51
|
+
Requires-Dist: pytest>=7.4; extra == "dev"
|
|
52
|
+
Requires-Dist: pytest-cov>=4.1; extra == "dev"
|
|
53
|
+
Requires-Dist: ruff>=0.1; extra == "dev"
|
|
54
|
+
Requires-Dist: mypy>=1.5; extra == "dev"
|
|
55
|
+
Requires-Dist: pandas-stubs>=2.0; extra == "dev"
|
|
56
|
+
Provides-Extra: docs
|
|
57
|
+
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
58
|
+
Requires-Dist: sphinx-rtd-theme>=1.3; extra == "docs"
|
|
59
|
+
Requires-Dist: myst-parser>=2.0; extra == "docs"
|
|
60
|
+
Dynamic: license-file
|
|
61
|
+
|
|
62
|
+
# frameprep
|
|
63
|
+
|
|
64
|
+
**Automated ML-Ready Data Preparation Library**
|
|
65
|
+
|
|
66
|
+
> One pipeline. Raw DataFrame in. ML-ready DataFrame out.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## The Problem
|
|
71
|
+
|
|
72
|
+
Data teams at mid-size companies spend **60–70 % of project time** cleaning and
|
|
73
|
+
preparing raw data before any model can touch it. `frameprep` automates the
|
|
74
|
+
most repetitive and error-prone parts of that work.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## What It Does
|
|
79
|
+
|
|
80
|
+
| Module | What It Handles |
|
|
81
|
+
|--------|----------------|
|
|
82
|
+
| **Smart dtype inference** | Detects real types (bool stored as string, datetime in text, numeric strings) and downcasts to smallest memory-safe type |
|
|
83
|
+
| **Missing value strategy** | Runs statistical tests (MCAR vs MAR proxy) to pick the right imputer per column — mean, median, KNN, mode, or sentinel |
|
|
84
|
+
| **Encoding + scaling** | Label, OHE, or hashing for categoricals; standard / minmax / robust for numerics |
|
|
85
|
+
| **Leakage detection + audit** | Flags correlated, near-constant, and ID-like columns; produces a full JSON/DataFrame audit report |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Installation
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pip install frameprep
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For development:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
git clone https://github.com/rahulreddy9725/frameprep.git
|
|
99
|
+
cd frameprep
|
|
100
|
+
pip install -e ".[dev]"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Quick Start
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import pandas as pd
|
|
109
|
+
from frameprep import frameprepPipeline
|
|
110
|
+
|
|
111
|
+
df_raw = pd.read_csv("customers.csv")
|
|
112
|
+
|
|
113
|
+
pipeline = frameprepPipeline(
|
|
114
|
+
target_col="churn", # excluded from encoding/scaling
|
|
115
|
+
scaling_strategy="standard", # 'standard' | 'minmax' | 'robust'
|
|
116
|
+
correlation_threshold=0.95, # leakage flag threshold
|
|
117
|
+
verbose=True,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
df_clean, report = pipeline.fit_transform(df_raw)
|
|
121
|
+
|
|
122
|
+
# Inspect the audit
|
|
123
|
+
report.summary() # prints to stdout
|
|
124
|
+
report.to_json() # full JSON string
|
|
125
|
+
report.to_dataframe() # flat pandas DataFrame
|
|
126
|
+
report.save("audit.json") # write to disk
|
|
127
|
+
|
|
128
|
+
# Apply the same transforms to test/prod data
|
|
129
|
+
df_test_clean = pipeline.transform(df_test)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Audit Report Example
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
============================================================
|
|
138
|
+
frameprep — Preparation Audit Report
|
|
139
|
+
============================================================
|
|
140
|
+
Created at : 2024-01-15T10:23:45+00:00
|
|
141
|
+
Elapsed : 0.83s
|
|
142
|
+
|
|
143
|
+
Shape
|
|
144
|
+
Input : 5000 rows × 18 columns
|
|
145
|
+
Output : 5000 rows × 24 columns
|
|
146
|
+
Δ cols : +6
|
|
147
|
+
|
|
148
|
+
Memory Optimisation
|
|
149
|
+
Before : 720.0 KB
|
|
150
|
+
After : 218.4 KB
|
|
151
|
+
Saved : 69.7%
|
|
152
|
+
|
|
153
|
+
Imputation Strategies
|
|
154
|
+
median : 4 column(s)
|
|
155
|
+
knn : 2 column(s)
|
|
156
|
+
mode : 3 column(s)
|
|
157
|
+
none : 9 column(s)
|
|
158
|
+
|
|
159
|
+
Encoding Strategies
|
|
160
|
+
one_hot_encode : 3 column(s)
|
|
161
|
+
label_encode : 2 column(s)
|
|
162
|
+
feature_hash : 1 column(s)
|
|
163
|
+
|
|
164
|
+
Scaling Strategy : standard (8 columns)
|
|
165
|
+
|
|
166
|
+
Leakage Detected : YES ⚠
|
|
167
|
+
• row_id: monotonically increasing integer — likely a row ID
|
|
168
|
+
============================================================
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Configuration Reference
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
frameprepPipeline(
|
|
177
|
+
target_col=None, # str — label column, excluded from transforms
|
|
178
|
+
exclude_cols=[], # list — columns to pass through unchanged
|
|
179
|
+
correlation_threshold=0.95, # float — leakage correlation cutoff
|
|
180
|
+
cardinality_threshold=50, # int — above this → hashing, below → OHE
|
|
181
|
+
scaling_strategy="standard", # str — 'standard' | 'minmax' | 'robust'
|
|
182
|
+
verbose=True, # bool — step-by-step logging
|
|
183
|
+
)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Module Details
|
|
189
|
+
|
|
190
|
+
### 1. DTypeInferrer
|
|
191
|
+
|
|
192
|
+
- Detects boolean strings (`"yes"/"no"`, `"true"/"false"`)
|
|
193
|
+
- Detects datetime strings (`"2023-01-15"`, `"15/01/2023"`)
|
|
194
|
+
- Detects numeric strings (`"100"`, `"3.14"`)
|
|
195
|
+
- Downcasts `float64 → float32`, `int64 → int8/int16/int32`
|
|
196
|
+
- Low-cardinality objects → `pd.Categorical`
|
|
197
|
+
|
|
198
|
+
### 2. MissingValueHandler
|
|
199
|
+
|
|
200
|
+
| Condition | Strategy |
|
|
201
|
+
|-----------|----------|
|
|
202
|
+
| 0 % missing | skip |
|
|
203
|
+
| < 1 % | median / mode (fast) |
|
|
204
|
+
| MAR detected (missingness correlated with other columns) | KNN imputer |
|
|
205
|
+
| \|skew\| > 1 | median |
|
|
206
|
+
| \|skew\| ≤ 1 | mean |
|
|
207
|
+
| > 40 % missing | constant flag (-999) |
|
|
208
|
+
| Categorical < 30 % | mode |
|
|
209
|
+
| Categorical ≥ 30 % | `"__missing__"` sentinel |
|
|
210
|
+
|
|
211
|
+
### 3. CategoricalEncoder
|
|
212
|
+
|
|
213
|
+
| Cardinality | Strategy |
|
|
214
|
+
|-------------|----------|
|
|
215
|
+
| 2 unique values | LabelEncoder |
|
|
216
|
+
| 3 – threshold | OneHotEncoder (drop first) |
|
|
217
|
+
| > threshold | FeatureHasher |
|
|
218
|
+
| Boolean dtype | cast to 0/1 |
|
|
219
|
+
|
|
220
|
+
### 4. LeakageDetector
|
|
221
|
+
|
|
222
|
+
Runs three checks:
|
|
223
|
+
|
|
224
|
+
- **Near-constant**: > 99 % of values identical
|
|
225
|
+
- **High correlation with target**: Pearson |r| ≥ threshold
|
|
226
|
+
- **ID-like column**: monotonically increasing integer
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Development
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Run tests
|
|
234
|
+
pytest
|
|
235
|
+
|
|
236
|
+
# Run tests with coverage
|
|
237
|
+
pytest --cov=frameprep --cov-report=term-missing
|
|
238
|
+
|
|
239
|
+
# Lint
|
|
240
|
+
ruff check frameprep tests
|
|
241
|
+
|
|
242
|
+
# Type check
|
|
243
|
+
mypy frameprep
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Project Structure
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
frameprep/
|
|
252
|
+
├── frameprep/
|
|
253
|
+
│ ├── __init__.py
|
|
254
|
+
│ ├── pipeline.py # Main frameprepPipeline
|
|
255
|
+
│ ├── core/
|
|
256
|
+
│ │ ├── dtype_inferrer.py
|
|
257
|
+
│ │ └── missing_strategy.py
|
|
258
|
+
│ ├── encoders/
|
|
259
|
+
│ │ └── categorical.py
|
|
260
|
+
│ ├── scalers/
|
|
261
|
+
│ │ └── numeric.py
|
|
262
|
+
│ ├── detectors/
|
|
263
|
+
│ │ └── leakage.py
|
|
264
|
+
│ ├── reports/
|
|
265
|
+
│ │ └── audit.py
|
|
266
|
+
│ └── utils/
|
|
267
|
+
│ ├── logger.py
|
|
268
|
+
│ └── validators.py
|
|
269
|
+
├── tests/
|
|
270
|
+
│ ├── conftest.py
|
|
271
|
+
│ ├── unit/
|
|
272
|
+
│ │ ├── test_dtype_inferrer.py
|
|
273
|
+
│ │ ├── test_missing_strategy.py
|
|
274
|
+
│ │ ├── test_categorical_encoder.py
|
|
275
|
+
│ │ ├── test_numeric_scaler.py
|
|
276
|
+
│ │ └── test_leakage_detector.py
|
|
277
|
+
│ └── integration/
|
|
278
|
+
│ └── test_pipeline.py
|
|
279
|
+
├── docs/examples/
|
|
280
|
+
│ └── quickstart.ipynb
|
|
281
|
+
├── pyproject.toml
|
|
282
|
+
├── README.md
|
|
283
|
+
├── CONTRIBUTING.md
|
|
284
|
+
├── CHANGELOG.md
|
|
285
|
+
└── LICENSE
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## License
|
|
291
|
+
|
|
292
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# frameprep
|
|
2
|
+
|
|
3
|
+
**Automated ML-Ready Data Preparation Library**
|
|
4
|
+
|
|
5
|
+
> One pipeline. Raw DataFrame in. ML-ready DataFrame out.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## The Problem
|
|
10
|
+
|
|
11
|
+
Data teams at mid-size companies spend **60–70 % of project time** cleaning and
|
|
12
|
+
preparing raw data before any model can touch it. `frameprep` automates the
|
|
13
|
+
most repetitive and error-prone parts of that work.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## What It Does
|
|
18
|
+
|
|
19
|
+
| Module | What It Handles |
|
|
20
|
+
|--------|----------------|
|
|
21
|
+
| **Smart dtype inference** | Detects real types (bool stored as string, datetime in text, numeric strings) and downcasts to smallest memory-safe type |
|
|
22
|
+
| **Missing value strategy** | Runs statistical tests (MCAR vs MAR proxy) to pick the right imputer per column — mean, median, KNN, mode, or sentinel |
|
|
23
|
+
| **Encoding + scaling** | Label, OHE, or hashing for categoricals; standard / minmax / robust for numerics |
|
|
24
|
+
| **Leakage detection + audit** | Flags correlated, near-constant, and ID-like columns; produces a full JSON/DataFrame audit report |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install frameprep
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For development:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/rahulreddy9725/frameprep.git
|
|
38
|
+
cd frameprep
|
|
39
|
+
pip install -e ".[dev]"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
import pandas as pd
|
|
48
|
+
from frameprep import frameprepPipeline
|
|
49
|
+
|
|
50
|
+
df_raw = pd.read_csv("customers.csv")
|
|
51
|
+
|
|
52
|
+
pipeline = frameprepPipeline(
|
|
53
|
+
target_col="churn", # excluded from encoding/scaling
|
|
54
|
+
scaling_strategy="standard", # 'standard' | 'minmax' | 'robust'
|
|
55
|
+
correlation_threshold=0.95, # leakage flag threshold
|
|
56
|
+
verbose=True,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
df_clean, report = pipeline.fit_transform(df_raw)
|
|
60
|
+
|
|
61
|
+
# Inspect the audit
|
|
62
|
+
report.summary() # prints to stdout
|
|
63
|
+
report.to_json() # full JSON string
|
|
64
|
+
report.to_dataframe() # flat pandas DataFrame
|
|
65
|
+
report.save("audit.json") # write to disk
|
|
66
|
+
|
|
67
|
+
# Apply the same transforms to test/prod data
|
|
68
|
+
df_test_clean = pipeline.transform(df_test)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Audit Report Example
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
============================================================
|
|
77
|
+
frameprep — Preparation Audit Report
|
|
78
|
+
============================================================
|
|
79
|
+
Created at : 2024-01-15T10:23:45+00:00
|
|
80
|
+
Elapsed : 0.83s
|
|
81
|
+
|
|
82
|
+
Shape
|
|
83
|
+
Input : 5000 rows × 18 columns
|
|
84
|
+
Output : 5000 rows × 24 columns
|
|
85
|
+
Δ cols : +6
|
|
86
|
+
|
|
87
|
+
Memory Optimisation
|
|
88
|
+
Before : 720.0 KB
|
|
89
|
+
After : 218.4 KB
|
|
90
|
+
Saved : 69.7%
|
|
91
|
+
|
|
92
|
+
Imputation Strategies
|
|
93
|
+
median : 4 column(s)
|
|
94
|
+
knn : 2 column(s)
|
|
95
|
+
mode : 3 column(s)
|
|
96
|
+
none : 9 column(s)
|
|
97
|
+
|
|
98
|
+
Encoding Strategies
|
|
99
|
+
one_hot_encode : 3 column(s)
|
|
100
|
+
label_encode : 2 column(s)
|
|
101
|
+
feature_hash : 1 column(s)
|
|
102
|
+
|
|
103
|
+
Scaling Strategy : standard (8 columns)
|
|
104
|
+
|
|
105
|
+
Leakage Detected : YES ⚠
|
|
106
|
+
• row_id: monotonically increasing integer — likely a row ID
|
|
107
|
+
============================================================
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Configuration Reference
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
frameprepPipeline(
|
|
116
|
+
target_col=None, # str — label column, excluded from transforms
|
|
117
|
+
exclude_cols=[], # list — columns to pass through unchanged
|
|
118
|
+
correlation_threshold=0.95, # float — leakage correlation cutoff
|
|
119
|
+
cardinality_threshold=50, # int — above this → hashing, below → OHE
|
|
120
|
+
scaling_strategy="standard", # str — 'standard' | 'minmax' | 'robust'
|
|
121
|
+
verbose=True, # bool — step-by-step logging
|
|
122
|
+
)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Module Details
|
|
128
|
+
|
|
129
|
+
### 1. DTypeInferrer
|
|
130
|
+
|
|
131
|
+
- Detects boolean strings (`"yes"/"no"`, `"true"/"false"`)
|
|
132
|
+
- Detects datetime strings (`"2023-01-15"`, `"15/01/2023"`)
|
|
133
|
+
- Detects numeric strings (`"100"`, `"3.14"`)
|
|
134
|
+
- Downcasts `float64 → float32`, `int64 → int8/int16/int32`
|
|
135
|
+
- Low-cardinality objects → `pd.Categorical`
|
|
136
|
+
|
|
137
|
+
### 2. MissingValueHandler
|
|
138
|
+
|
|
139
|
+
| Condition | Strategy |
|
|
140
|
+
|-----------|----------|
|
|
141
|
+
| 0 % missing | skip |
|
|
142
|
+
| < 1 % | median / mode (fast) |
|
|
143
|
+
| MAR detected (missingness correlated with other columns) | KNN imputer |
|
|
144
|
+
| \|skew\| > 1 | median |
|
|
145
|
+
| \|skew\| ≤ 1 | mean |
|
|
146
|
+
| > 40 % missing | constant flag (-999) |
|
|
147
|
+
| Categorical < 30 % | mode |
|
|
148
|
+
| Categorical ≥ 30 % | `"__missing__"` sentinel |
|
|
149
|
+
|
|
150
|
+
### 3. CategoricalEncoder
|
|
151
|
+
|
|
152
|
+
| Cardinality | Strategy |
|
|
153
|
+
|-------------|----------|
|
|
154
|
+
| 2 unique values | LabelEncoder |
|
|
155
|
+
| 3 – threshold | OneHotEncoder (drop first) |
|
|
156
|
+
| > threshold | FeatureHasher |
|
|
157
|
+
| Boolean dtype | cast to 0/1 |
|
|
158
|
+
|
|
159
|
+
### 4. LeakageDetector
|
|
160
|
+
|
|
161
|
+
Runs three checks:
|
|
162
|
+
|
|
163
|
+
- **Near-constant**: > 99 % of values identical
|
|
164
|
+
- **High correlation with target**: Pearson |r| ≥ threshold
|
|
165
|
+
- **ID-like column**: monotonically increasing integer
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Development
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Run tests
|
|
173
|
+
pytest
|
|
174
|
+
|
|
175
|
+
# Run tests with coverage
|
|
176
|
+
pytest --cov=frameprep --cov-report=term-missing
|
|
177
|
+
|
|
178
|
+
# Lint
|
|
179
|
+
ruff check frameprep tests
|
|
180
|
+
|
|
181
|
+
# Type check
|
|
182
|
+
mypy frameprep
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Project Structure
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
frameprep/
|
|
191
|
+
├── frameprep/
|
|
192
|
+
│ ├── __init__.py
|
|
193
|
+
│ ├── pipeline.py # Main frameprepPipeline
|
|
194
|
+
│ ├── core/
|
|
195
|
+
│ │ ├── dtype_inferrer.py
|
|
196
|
+
│ │ └── missing_strategy.py
|
|
197
|
+
│ ├── encoders/
|
|
198
|
+
│ │ └── categorical.py
|
|
199
|
+
│ ├── scalers/
|
|
200
|
+
│ │ └── numeric.py
|
|
201
|
+
│ ├── detectors/
|
|
202
|
+
│ │ └── leakage.py
|
|
203
|
+
│ ├── reports/
|
|
204
|
+
│ │ └── audit.py
|
|
205
|
+
│ └── utils/
|
|
206
|
+
│ ├── logger.py
|
|
207
|
+
│ └── validators.py
|
|
208
|
+
├── tests/
|
|
209
|
+
│ ├── conftest.py
|
|
210
|
+
│ ├── unit/
|
|
211
|
+
│ │ ├── test_dtype_inferrer.py
|
|
212
|
+
│ │ ├── test_missing_strategy.py
|
|
213
|
+
│ │ ├── test_categorical_encoder.py
|
|
214
|
+
│ │ ├── test_numeric_scaler.py
|
|
215
|
+
│ │ └── test_leakage_detector.py
|
|
216
|
+
│ └── integration/
|
|
217
|
+
│ └── test_pipeline.py
|
|
218
|
+
├── docs/examples/
|
|
219
|
+
│ └── quickstart.ipynb
|
|
220
|
+
├── pyproject.toml
|
|
221
|
+
├── README.md
|
|
222
|
+
├── CONTRIBUTING.md
|
|
223
|
+
├── CHANGELOG.md
|
|
224
|
+
└── LICENSE
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
frameprep — Automated ML-Ready Data Preparation Library
|
|
3
|
+
=======================================================
|
|
4
|
+
A single pipeline object that ingests a raw DataFrame and outputs a fully
|
|
5
|
+
ML-ready dataset: dtype inference, missing value imputation, encoding,
|
|
6
|
+
scaling, leakage detection, and audit reporting.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from frameprep.pipeline import frameprepPipeline
|
|
10
|
+
from frameprep.core.dtype_inferrer import DTypeInferrer
|
|
11
|
+
from frameprep.core.missing_strategy import MissingValueHandler
|
|
12
|
+
from frameprep.encoders.categorical import CategoricalEncoder
|
|
13
|
+
from frameprep.scalers.numeric import NumericScaler
|
|
14
|
+
from frameprep.detectors.leakage import LeakageDetector
|
|
15
|
+
from frameprep.reports.audit import AuditReport
|
|
16
|
+
|
|
17
|
+
__version__ = "0.1.0"
|
|
18
|
+
__author__ = "frameprep contributors"
|
|
19
|
+
__all__ = [
|
|
20
|
+
"frameprepPipeline",
|
|
21
|
+
"DTypeInferrer",
|
|
22
|
+
"MissingValueHandler",
|
|
23
|
+
"CategoricalEncoder",
|
|
24
|
+
"NumericScaler",
|
|
25
|
+
"LeakageDetector",
|
|
26
|
+
"AuditReport",
|
|
27
|
+
]
|