smartclean-ai 1.0.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.
- smartclean_ai-1.0.0/LICENSE +21 -0
- smartclean_ai-1.0.0/PKG-INFO +215 -0
- smartclean_ai-1.0.0/README.md +186 -0
- smartclean_ai-1.0.0/pyproject.toml +54 -0
- smartclean_ai-1.0.0/setup.cfg +4 -0
- smartclean_ai-1.0.0/smartclean/__init__.py +8 -0
- smartclean_ai-1.0.0/smartclean/cleaner.py +21 -0
- smartclean_ai-1.0.0/smartclean/cleaning/duplicate_handler.py +42 -0
- smartclean_ai-1.0.0/smartclean/cleaning/missing_handler.py +56 -0
- smartclean_ai-1.0.0/smartclean/cleaning/outlier_handler.py +106 -0
- smartclean_ai-1.0.0/smartclean/config/cleaning_config.py +50 -0
- smartclean_ai-1.0.0/smartclean/core/cleaning_result.py +16 -0
- smartclean_ai-1.0.0/smartclean/core/decision_engine.py +128 -0
- smartclean_ai-1.0.0/smartclean/core/execution_engine.py +19 -0
- smartclean_ai-1.0.0/smartclean/core/loader.py +35 -0
- smartclean_ai-1.0.0/smartclean/core/pipeline.py +49 -0
- smartclean_ai-1.0.0/smartclean/core/profiler.py +130 -0
- smartclean_ai-1.0.0/smartclean/core/report_genrator.py +156 -0
- smartclean_ai-1.0.0/smartclean/core/smartclean.py +98 -0
- smartclean_ai-1.0.0/smartclean/handlers/duplicates.py +14 -0
- smartclean_ai-1.0.0/smartclean/handlers/missing.py +21 -0
- smartclean_ai-1.0.0/smartclean/handlers/outliers.py +58 -0
- smartclean_ai-1.0.0/smartclean/main.py +29 -0
- smartclean_ai-1.0.0/smartclean/result.py +23 -0
- smartclean_ai-1.0.0/smartclean/utils/display_manager.py +111 -0
- smartclean_ai-1.0.0/smartclean/utils/missing_normalizer.py +43 -0
- smartclean_ai-1.0.0/smartclean/utils/outliers.py +69 -0
- smartclean_ai-1.0.0/smartclean/utils/profiling_utils.py +5 -0
- smartclean_ai-1.0.0/smartclean_ai.egg-info/PKG-INFO +215 -0
- smartclean_ai-1.0.0/smartclean_ai.egg-info/SOURCES.txt +31 -0
- smartclean_ai-1.0.0/smartclean_ai.egg-info/dependency_links.txt +1 -0
- smartclean_ai-1.0.0/smartclean_ai.egg-info/requires.txt +4 -0
- smartclean_ai-1.0.0/smartclean_ai.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yash Talati
|
|
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,215 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smartclean-ai
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: An intelligent Python library for automated data cleaning.
|
|
5
|
+
Author-email: Yash Talati <YOUR_EMAIL@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yashtalati10/SmartClean
|
|
8
|
+
Project-URL: Repository, https://github.com/yashtalati10/SmartClean
|
|
9
|
+
Project-URL: Issues, https://github.com/yashtalati10/SmartClean/issues
|
|
10
|
+
Keywords: data-cleaning,automation,pandas,machine-learning,preprocessing,eda,python
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=2.0.0
|
|
25
|
+
Requires-Dist: pandas>=2.0.0
|
|
26
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
27
|
+
Requires-Dist: scikit-learn>=1.3.0
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# SmartClean
|
|
31
|
+
|
|
32
|
+
> An intelligent Python library for automated data cleaning with profiling, preprocessing, and detailed reporting.
|
|
33
|
+
|
|
34
|
+
SmartClean simplifies the data cleaning process by automatically identifying and handling common data quality issues such as missing values, duplicate records, and outliers. It generates comprehensive profiling reports before and after cleaning, making datasets ready for analysis and machine learning.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- Automated missing value detection and handling
|
|
41
|
+
- Duplicate row detection and removal
|
|
42
|
+
- Outlier detection using the IQR method
|
|
43
|
+
- Automatic data profiling
|
|
44
|
+
- Before and after cleaning reports
|
|
45
|
+
- Configurable cleaning pipeline
|
|
46
|
+
- Modular and extensible architecture
|
|
47
|
+
- Simple and intuitive API
|
|
48
|
+
- Open-source and developer friendly
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Clone the repository:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/yourusername/SmartClean.git
|
|
58
|
+
|
|
59
|
+
cd SmartClean
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Install dependencies:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install -r requirements.txt
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import pandas as pd
|
|
74
|
+
from smartclean import Cleaner
|
|
75
|
+
|
|
76
|
+
# Load dataset
|
|
77
|
+
df = pd.read_csv("data/raw/Kaggle/1.csv")
|
|
78
|
+
|
|
79
|
+
# Initialize SmartClean
|
|
80
|
+
cleaner = Cleaner()
|
|
81
|
+
|
|
82
|
+
# Clean dataset
|
|
83
|
+
result = cleaner.clean(df)
|
|
84
|
+
|
|
85
|
+
print(result.cleaned_df.head())
|
|
86
|
+
print(result.report)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Example Output
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
========== Missing Value Cleaning ==========
|
|
95
|
+
|
|
96
|
+
✓ Column: Age | Missing: 177 | Strategy: mean
|
|
97
|
+
✓ Column: Cabin | Missing: 687 | Strategy: most_frequent
|
|
98
|
+
✓ Column: Embarked | Missing: 2 | Strategy: most_frequent
|
|
99
|
+
|
|
100
|
+
========== Duplicate Cleaning ==========
|
|
101
|
+
|
|
102
|
+
✓ No duplicate rows found.
|
|
103
|
+
|
|
104
|
+
========== Outlier Cleaning ==========
|
|
105
|
+
|
|
106
|
+
✓ Outlier Values Capped : 441
|
|
107
|
+
|
|
108
|
+
CleaningResult(rows=891, columns=12)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Project Structure
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
SmartClean/
|
|
117
|
+
│
|
|
118
|
+
├── smartclean/
|
|
119
|
+
│ ├── cleaning/
|
|
120
|
+
│ ├── config/
|
|
121
|
+
│ ├── core/
|
|
122
|
+
│ ├── handlers/
|
|
123
|
+
│ ├── utils/
|
|
124
|
+
│ ├── cleaner.py
|
|
125
|
+
│ ├── result.py
|
|
126
|
+
│ └── __init__.py
|
|
127
|
+
│
|
|
128
|
+
├── example/
|
|
129
|
+
│ └── demo.py
|
|
130
|
+
│
|
|
131
|
+
├── data/
|
|
132
|
+
│
|
|
133
|
+
├── reports/
|
|
134
|
+
│
|
|
135
|
+
├── README.md
|
|
136
|
+
└── requirements.txt
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Cleaning Pipeline
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
Dataset
|
|
145
|
+
│
|
|
146
|
+
▼
|
|
147
|
+
Data Profiling
|
|
148
|
+
│
|
|
149
|
+
▼
|
|
150
|
+
Missing Value Handling
|
|
151
|
+
│
|
|
152
|
+
▼
|
|
153
|
+
Duplicate Removal
|
|
154
|
+
│
|
|
155
|
+
▼
|
|
156
|
+
Outlier Detection
|
|
157
|
+
│
|
|
158
|
+
▼
|
|
159
|
+
Updated Profiling
|
|
160
|
+
│
|
|
161
|
+
▼
|
|
162
|
+
Cleaning Report
|
|
163
|
+
│
|
|
164
|
+
▼
|
|
165
|
+
Clean Dataset
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Current Cleaning Capabilities
|
|
171
|
+
|
|
172
|
+
### Missing Values
|
|
173
|
+
|
|
174
|
+
- Mean imputation
|
|
175
|
+
- Median imputation
|
|
176
|
+
- Most frequent value imputation
|
|
177
|
+
- Drop columns with excessive missing values
|
|
178
|
+
|
|
179
|
+
### Duplicates
|
|
180
|
+
|
|
181
|
+
- Detect duplicate rows
|
|
182
|
+
- Remove duplicate records
|
|
183
|
+
|
|
184
|
+
### Outliers
|
|
185
|
+
|
|
186
|
+
- IQR-based outlier detection
|
|
187
|
+
- Outlier capping
|
|
188
|
+
- Outlier removal
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Output
|
|
193
|
+
|
|
194
|
+
SmartClean returns a `CleaningResult` object.
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
result = Cleaner().clean(df)
|
|
198
|
+
|
|
199
|
+
result.cleaned_df
|
|
200
|
+
result.before_profile
|
|
201
|
+
result.after_profile
|
|
202
|
+
result.report
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Roadmap
|
|
208
|
+
|
|
209
|
+
### Version 1.0
|
|
210
|
+
|
|
211
|
+
- Data profiling
|
|
212
|
+
- Missing value handling
|
|
213
|
+
- Duplicate removal
|
|
214
|
+
- Outlier detection
|
|
215
|
+
- Cleaning reports
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# SmartClean
|
|
2
|
+
|
|
3
|
+
> An intelligent Python library for automated data cleaning with profiling, preprocessing, and detailed reporting.
|
|
4
|
+
|
|
5
|
+
SmartClean simplifies the data cleaning process by automatically identifying and handling common data quality issues such as missing values, duplicate records, and outliers. It generates comprehensive profiling reports before and after cleaning, making datasets ready for analysis and machine learning.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Automated missing value detection and handling
|
|
12
|
+
- Duplicate row detection and removal
|
|
13
|
+
- Outlier detection using the IQR method
|
|
14
|
+
- Automatic data profiling
|
|
15
|
+
- Before and after cleaning reports
|
|
16
|
+
- Configurable cleaning pipeline
|
|
17
|
+
- Modular and extensible architecture
|
|
18
|
+
- Simple and intuitive API
|
|
19
|
+
- Open-source and developer friendly
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
Clone the repository:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/yourusername/SmartClean.git
|
|
29
|
+
|
|
30
|
+
cd SmartClean
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Install dependencies:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install -r requirements.txt
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
import pandas as pd
|
|
45
|
+
from smartclean import Cleaner
|
|
46
|
+
|
|
47
|
+
# Load dataset
|
|
48
|
+
df = pd.read_csv("data/raw/Kaggle/1.csv")
|
|
49
|
+
|
|
50
|
+
# Initialize SmartClean
|
|
51
|
+
cleaner = Cleaner()
|
|
52
|
+
|
|
53
|
+
# Clean dataset
|
|
54
|
+
result = cleaner.clean(df)
|
|
55
|
+
|
|
56
|
+
print(result.cleaned_df.head())
|
|
57
|
+
print(result.report)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Example Output
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
========== Missing Value Cleaning ==========
|
|
66
|
+
|
|
67
|
+
✓ Column: Age | Missing: 177 | Strategy: mean
|
|
68
|
+
✓ Column: Cabin | Missing: 687 | Strategy: most_frequent
|
|
69
|
+
✓ Column: Embarked | Missing: 2 | Strategy: most_frequent
|
|
70
|
+
|
|
71
|
+
========== Duplicate Cleaning ==========
|
|
72
|
+
|
|
73
|
+
✓ No duplicate rows found.
|
|
74
|
+
|
|
75
|
+
========== Outlier Cleaning ==========
|
|
76
|
+
|
|
77
|
+
✓ Outlier Values Capped : 441
|
|
78
|
+
|
|
79
|
+
CleaningResult(rows=891, columns=12)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Project Structure
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
SmartClean/
|
|
88
|
+
│
|
|
89
|
+
├── smartclean/
|
|
90
|
+
│ ├── cleaning/
|
|
91
|
+
│ ├── config/
|
|
92
|
+
│ ├── core/
|
|
93
|
+
│ ├── handlers/
|
|
94
|
+
│ ├── utils/
|
|
95
|
+
│ ├── cleaner.py
|
|
96
|
+
│ ├── result.py
|
|
97
|
+
│ └── __init__.py
|
|
98
|
+
│
|
|
99
|
+
├── example/
|
|
100
|
+
│ └── demo.py
|
|
101
|
+
│
|
|
102
|
+
├── data/
|
|
103
|
+
│
|
|
104
|
+
├── reports/
|
|
105
|
+
│
|
|
106
|
+
├── README.md
|
|
107
|
+
└── requirements.txt
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Cleaning Pipeline
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
Dataset
|
|
116
|
+
│
|
|
117
|
+
▼
|
|
118
|
+
Data Profiling
|
|
119
|
+
│
|
|
120
|
+
▼
|
|
121
|
+
Missing Value Handling
|
|
122
|
+
│
|
|
123
|
+
▼
|
|
124
|
+
Duplicate Removal
|
|
125
|
+
│
|
|
126
|
+
▼
|
|
127
|
+
Outlier Detection
|
|
128
|
+
│
|
|
129
|
+
▼
|
|
130
|
+
Updated Profiling
|
|
131
|
+
│
|
|
132
|
+
▼
|
|
133
|
+
Cleaning Report
|
|
134
|
+
│
|
|
135
|
+
▼
|
|
136
|
+
Clean Dataset
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Current Cleaning Capabilities
|
|
142
|
+
|
|
143
|
+
### Missing Values
|
|
144
|
+
|
|
145
|
+
- Mean imputation
|
|
146
|
+
- Median imputation
|
|
147
|
+
- Most frequent value imputation
|
|
148
|
+
- Drop columns with excessive missing values
|
|
149
|
+
|
|
150
|
+
### Duplicates
|
|
151
|
+
|
|
152
|
+
- Detect duplicate rows
|
|
153
|
+
- Remove duplicate records
|
|
154
|
+
|
|
155
|
+
### Outliers
|
|
156
|
+
|
|
157
|
+
- IQR-based outlier detection
|
|
158
|
+
- Outlier capping
|
|
159
|
+
- Outlier removal
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Output
|
|
164
|
+
|
|
165
|
+
SmartClean returns a `CleaningResult` object.
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
result = Cleaner().clean(df)
|
|
169
|
+
|
|
170
|
+
result.cleaned_df
|
|
171
|
+
result.before_profile
|
|
172
|
+
result.after_profile
|
|
173
|
+
result.report
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Roadmap
|
|
179
|
+
|
|
180
|
+
### Version 1.0
|
|
181
|
+
|
|
182
|
+
- Data profiling
|
|
183
|
+
- Missing value handling
|
|
184
|
+
- Duplicate removal
|
|
185
|
+
- Outlier detection
|
|
186
|
+
- Cleaning reports
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "smartclean-ai"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "An intelligent Python library for automated data cleaning."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Yash Talati", email = "YOUR_EMAIL@example.com" }
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
license = { text = "MIT" }
|
|
17
|
+
|
|
18
|
+
keywords = [
|
|
19
|
+
"data-cleaning",
|
|
20
|
+
"automation",
|
|
21
|
+
"pandas",
|
|
22
|
+
"machine-learning",
|
|
23
|
+
"preprocessing",
|
|
24
|
+
"eda",
|
|
25
|
+
"python"
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 3 - Alpha",
|
|
30
|
+
"Intended Audience :: Developers",
|
|
31
|
+
"Intended Audience :: Science/Research",
|
|
32
|
+
"License :: OSI Approved :: MIT License",
|
|
33
|
+
"Operating System :: OS Independent",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3.10",
|
|
36
|
+
"Programming Language :: Python :: 3.11",
|
|
37
|
+
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Programming Language :: Python :: 3.13"
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
dependencies = [
|
|
42
|
+
"numpy>=2.0.0",
|
|
43
|
+
"pandas>=2.0.0",
|
|
44
|
+
"matplotlib>=3.7.0",
|
|
45
|
+
"scikit-learn>=1.3.0"
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://github.com/yashtalati10/SmartClean"
|
|
50
|
+
Repository = "https://github.com/yashtalati10/SmartClean"
|
|
51
|
+
Issues = "https://github.com/yashtalati10/SmartClean/issues"
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.packages.find]
|
|
54
|
+
include = ["smartclean*"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from .core.pipeline import CleaningPipeline
|
|
2
|
+
from .result import CleaningResult
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Cleaner:
|
|
6
|
+
|
|
7
|
+
def __init__(self, config=None):
|
|
8
|
+
self.config = config
|
|
9
|
+
|
|
10
|
+
def clean(self, data):
|
|
11
|
+
|
|
12
|
+
pipeline = CleaningPipeline(data, self.config)
|
|
13
|
+
|
|
14
|
+
cleaned_df, before_profile, after_profile, report = pipeline.run()
|
|
15
|
+
|
|
16
|
+
return CleaningResult(
|
|
17
|
+
cleaned_df=cleaned_df,
|
|
18
|
+
before_profile=before_profile,
|
|
19
|
+
after_profile=after_profile,
|
|
20
|
+
report=report
|
|
21
|
+
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
class DuplicateHandler:
|
|
2
|
+
def __init__(self, df, profile):
|
|
3
|
+
self.df = df.copy()
|
|
4
|
+
self.profile = profile
|
|
5
|
+
|
|
6
|
+
def has_duplicates(self):
|
|
7
|
+
return self.profile["duplicates"] > 0
|
|
8
|
+
|
|
9
|
+
def find_duplicates(self):
|
|
10
|
+
return self.df[self.df.duplicated()]
|
|
11
|
+
|
|
12
|
+
def remove_duplicates(self):
|
|
13
|
+
self.df = self.df.drop_duplicates()
|
|
14
|
+
return self.df
|
|
15
|
+
|
|
16
|
+
def handle_duplicates(self):
|
|
17
|
+
|
|
18
|
+
print("\n========== Duplicate Cleaning ==========\n")
|
|
19
|
+
|
|
20
|
+
report = {
|
|
21
|
+
"duplicates_found": self.profile["duplicates"],
|
|
22
|
+
"duplicates_removed": 0
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if not self.has_duplicates():
|
|
26
|
+
print("✓ No duplicate rows found.\n")
|
|
27
|
+
return self.df, report
|
|
28
|
+
|
|
29
|
+
report["duplicates_removed"] = self.profile["duplicates"]
|
|
30
|
+
|
|
31
|
+
print(
|
|
32
|
+
f"✓ Duplicate Rows Found : {report['duplicates_found']}"
|
|
33
|
+
)
|
|
34
|
+
print(
|
|
35
|
+
f"✓ Duplicate Rows Removed : {report['duplicates_removed']}"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
self.remove_duplicates()
|
|
39
|
+
|
|
40
|
+
print("\n✅ Duplicate cleaning completed.\n")
|
|
41
|
+
|
|
42
|
+
return self.df, report
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from sklearn.impute import SimpleImputer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class MissingValueHandler:
|
|
6
|
+
|
|
7
|
+
def __init__(self, dataframe, profile):
|
|
8
|
+
self.df = dataframe.copy()
|
|
9
|
+
self.profile = profile
|
|
10
|
+
|
|
11
|
+
def handle_missing_values(self):
|
|
12
|
+
|
|
13
|
+
print("\n========== Missing Value Cleaning ==========\n")
|
|
14
|
+
|
|
15
|
+
total_rows = len(self.df)
|
|
16
|
+
|
|
17
|
+
report = {
|
|
18
|
+
"missing_values_before": sum(self.profile["missing_values"].values()),
|
|
19
|
+
"missing_values_filled": 0,
|
|
20
|
+
"skipped_columns": [],
|
|
21
|
+
"strategies": {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for column, missing_count in self.profile["missing_values"].items():
|
|
25
|
+
|
|
26
|
+
if missing_count == 0:
|
|
27
|
+
continue
|
|
28
|
+
|
|
29
|
+
if missing_count == total_rows:
|
|
30
|
+
print(
|
|
31
|
+
f"⚠ Column: {column:<16} | Missing: {missing_count:<4} | Skipped (100% Missing)"
|
|
32
|
+
)
|
|
33
|
+
report["skipped_columns"].append(column)
|
|
34
|
+
continue
|
|
35
|
+
|
|
36
|
+
data_type = self.profile["data_types"][column]
|
|
37
|
+
|
|
38
|
+
if data_type in ["int64", "float64"]:
|
|
39
|
+
strategy = "mean"
|
|
40
|
+
else:
|
|
41
|
+
strategy = "most_frequent"
|
|
42
|
+
|
|
43
|
+
imputer = SimpleImputer(strategy=strategy)
|
|
44
|
+
|
|
45
|
+
self.df[[column]] = imputer.fit_transform(self.df[[column]])
|
|
46
|
+
|
|
47
|
+
report["missing_values_filled"] += missing_count
|
|
48
|
+
report["strategies"][column] = strategy
|
|
49
|
+
|
|
50
|
+
print(
|
|
51
|
+
f"✓ Column: {column:<16} | Missing: {missing_count:<4} | Strategy: {strategy}"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
print("\n✅ Missing value cleaning completed.\n")
|
|
55
|
+
|
|
56
|
+
return self.df, report
|