autocure 0.2.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.
- autocure-0.2.0/LICENSE +21 -0
- autocure-0.2.0/PKG-INFO +136 -0
- autocure-0.2.0/README.md +114 -0
- autocure-0.2.0/autocure/__init__.py +8 -0
- autocure-0.2.0/autocure/cli/__init__.py +0 -0
- autocure-0.2.0/autocure/cli/main.py +33 -0
- autocure-0.2.0/autocure/cure.py +55 -0
- autocure-0.2.0/autocure/pipeline.py +22 -0
- autocure-0.2.0/autocure/scan.py +24 -0
- autocure-0.2.0/autocure/train.py +136 -0
- autocure-0.2.0/autocure.egg-info/PKG-INFO +136 -0
- autocure-0.2.0/autocure.egg-info/SOURCES.txt +19 -0
- autocure-0.2.0/autocure.egg-info/dependency_links.txt +1 -0
- autocure-0.2.0/autocure.egg-info/entry_points.txt +2 -0
- autocure-0.2.0/autocure.egg-info/requires.txt +3 -0
- autocure-0.2.0/autocure.egg-info/top_level.txt +1 -0
- autocure-0.2.0/pyproject.toml +3 -0
- autocure-0.2.0/setup.cfg +34 -0
- autocure-0.2.0/setup.py +17 -0
- autocure-0.2.0/test/test.py +65 -0
autocure-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Vishal More
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
autocure-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autocure
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Automated data cleaning and auto ML training with hyperparameter tuning.
|
|
5
|
+
Home-page: https://pypi.org/project/autocure/
|
|
6
|
+
Author: Vishal More
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Source, https://github.com/YOUR_GITHUB/autocure
|
|
9
|
+
Project-URL: Tracker, https://github.com/YOUR_GITHUB/autocure/issues
|
|
10
|
+
Keywords: data-cleaning,machine-learning,automation,sklearn,pipeline
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: pandas
|
|
18
|
+
Requires-Dist: scikit-learn
|
|
19
|
+
Requires-Dist: click
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
|
|
23
|
+
# Autocure
|
|
24
|
+
|
|
25
|
+
Automated data cleaning + AutoML model training with hyperparameter tuning.
|
|
26
|
+
|
|
27
|
+
## Key features
|
|
28
|
+
|
|
29
|
+
- Data scan
|
|
30
|
+
- Missing values summary
|
|
31
|
+
- Dtype inference
|
|
32
|
+
- Outlier counts (IQR method)
|
|
33
|
+
- Duplicate rows count
|
|
34
|
+
|
|
35
|
+
- Data cleaning (cure)
|
|
36
|
+
- Numeric imputation (median)
|
|
37
|
+
- Categorical imputation (mode / fallback "Unknown")
|
|
38
|
+
- Text preprocessing (applies only to text columns):
|
|
39
|
+
- remove punctuation
|
|
40
|
+
- lowercase
|
|
41
|
+
- tokenize
|
|
42
|
+
- remove stopwords
|
|
43
|
+
- lemmatize
|
|
44
|
+
- Drop duplicates
|
|
45
|
+
|
|
46
|
+
- Pipeline & AutoML
|
|
47
|
+
- Automatic ColumnTransformer (StandardScaler for numeric, OneHotEncoder for categorical)
|
|
48
|
+
- Support for classification and regression
|
|
49
|
+
- Multiple algorithms with GridSearchCV hyperparameter search
|
|
50
|
+
- Model leaderboard and best-model selection
|
|
51
|
+
|
|
52
|
+
- CLI
|
|
53
|
+
- scan-data, fix, train-model commands for quick workflows
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
From project root (editable install for development):
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
python -m pip install -e .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or install dependencies:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install -r requirements.txt
|
|
67
|
+
pip install nltk
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
NLTK data used by cure() is downloaded at runtime (punkt, stopwords, wordnet).
|
|
71
|
+
|
|
72
|
+
## Quick usage
|
|
73
|
+
|
|
74
|
+
Python:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import autocure as ac
|
|
78
|
+
import pandas as pd
|
|
79
|
+
|
|
80
|
+
df = pd.read_csv("your_dataset.csv")
|
|
81
|
+
|
|
82
|
+
# 1) Inspect dataset
|
|
83
|
+
report = ac.scan(df)
|
|
84
|
+
print(report)
|
|
85
|
+
|
|
86
|
+
# 2) Clean dataset
|
|
87
|
+
clean = ac.cure(df)
|
|
88
|
+
|
|
89
|
+
# 3) Create pipeline (optional)
|
|
90
|
+
pipeline = ac.make_pipeline(clean, target="target_column")
|
|
91
|
+
|
|
92
|
+
# 4) Train models (returns a dict)
|
|
93
|
+
result = ac.train(clean, target="target_column")
|
|
94
|
+
|
|
95
|
+
print(result["best_model_name"])
|
|
96
|
+
print("score:", result["best_score"])
|
|
97
|
+
# Best model object for predict:
|
|
98
|
+
best_model = result["best_model"]
|
|
99
|
+
preds = best_model.predict(clean.drop(columns=["target_column"]).iloc[:5])
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Returned keys from train():
|
|
103
|
+
- best_model (fitted sklearn estimator / pipeline)
|
|
104
|
+
- best_model_name
|
|
105
|
+
- best_score
|
|
106
|
+
- best_params
|
|
107
|
+
- leaderboard (list/dict of model results)
|
|
108
|
+
|
|
109
|
+
## CLI
|
|
110
|
+
|
|
111
|
+
Examples:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Scan a CSV
|
|
115
|
+
autocure scan-data data.csv
|
|
116
|
+
|
|
117
|
+
# Clean and save
|
|
118
|
+
autocure fix data.csv --out cleaned.csv
|
|
119
|
+
|
|
120
|
+
# Train via CLI
|
|
121
|
+
autocure train-model data.csv --target target_column
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Tips & notes
|
|
125
|
+
|
|
126
|
+
- cure() applies text preprocessing only to columns detected as object/string dtype.
|
|
127
|
+
- For small categorical cardinality detection and problem-type heuristics, train() uses simple rules; override by preparing the DataFrame appropriately.
|
|
128
|
+
- If you use large text datasets, consider vectorization or specialized NLP pipelines before heavy GridSearchCV.
|
|
129
|
+
|
|
130
|
+
## Contributing
|
|
131
|
+
|
|
132
|
+
Bug reports and PRs welcome. Follow repository guidelines and add tests for new behavior.
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT License
|
autocure-0.2.0/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Autocure
|
|
2
|
+
|
|
3
|
+
Automated data cleaning + AutoML model training with hyperparameter tuning.
|
|
4
|
+
|
|
5
|
+
## Key features
|
|
6
|
+
|
|
7
|
+
- Data scan
|
|
8
|
+
- Missing values summary
|
|
9
|
+
- Dtype inference
|
|
10
|
+
- Outlier counts (IQR method)
|
|
11
|
+
- Duplicate rows count
|
|
12
|
+
|
|
13
|
+
- Data cleaning (cure)
|
|
14
|
+
- Numeric imputation (median)
|
|
15
|
+
- Categorical imputation (mode / fallback "Unknown")
|
|
16
|
+
- Text preprocessing (applies only to text columns):
|
|
17
|
+
- remove punctuation
|
|
18
|
+
- lowercase
|
|
19
|
+
- tokenize
|
|
20
|
+
- remove stopwords
|
|
21
|
+
- lemmatize
|
|
22
|
+
- Drop duplicates
|
|
23
|
+
|
|
24
|
+
- Pipeline & AutoML
|
|
25
|
+
- Automatic ColumnTransformer (StandardScaler for numeric, OneHotEncoder for categorical)
|
|
26
|
+
- Support for classification and regression
|
|
27
|
+
- Multiple algorithms with GridSearchCV hyperparameter search
|
|
28
|
+
- Model leaderboard and best-model selection
|
|
29
|
+
|
|
30
|
+
- CLI
|
|
31
|
+
- scan-data, fix, train-model commands for quick workflows
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
From project root (editable install for development):
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
python -m pip install -e .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or install dependencies:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install -r requirements.txt
|
|
45
|
+
pip install nltk
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
NLTK data used by cure() is downloaded at runtime (punkt, stopwords, wordnet).
|
|
49
|
+
|
|
50
|
+
## Quick usage
|
|
51
|
+
|
|
52
|
+
Python:
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import autocure as ac
|
|
56
|
+
import pandas as pd
|
|
57
|
+
|
|
58
|
+
df = pd.read_csv("your_dataset.csv")
|
|
59
|
+
|
|
60
|
+
# 1) Inspect dataset
|
|
61
|
+
report = ac.scan(df)
|
|
62
|
+
print(report)
|
|
63
|
+
|
|
64
|
+
# 2) Clean dataset
|
|
65
|
+
clean = ac.cure(df)
|
|
66
|
+
|
|
67
|
+
# 3) Create pipeline (optional)
|
|
68
|
+
pipeline = ac.make_pipeline(clean, target="target_column")
|
|
69
|
+
|
|
70
|
+
# 4) Train models (returns a dict)
|
|
71
|
+
result = ac.train(clean, target="target_column")
|
|
72
|
+
|
|
73
|
+
print(result["best_model_name"])
|
|
74
|
+
print("score:", result["best_score"])
|
|
75
|
+
# Best model object for predict:
|
|
76
|
+
best_model = result["best_model"]
|
|
77
|
+
preds = best_model.predict(clean.drop(columns=["target_column"]).iloc[:5])
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Returned keys from train():
|
|
81
|
+
- best_model (fitted sklearn estimator / pipeline)
|
|
82
|
+
- best_model_name
|
|
83
|
+
- best_score
|
|
84
|
+
- best_params
|
|
85
|
+
- leaderboard (list/dict of model results)
|
|
86
|
+
|
|
87
|
+
## CLI
|
|
88
|
+
|
|
89
|
+
Examples:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Scan a CSV
|
|
93
|
+
autocure scan-data data.csv
|
|
94
|
+
|
|
95
|
+
# Clean and save
|
|
96
|
+
autocure fix data.csv --out cleaned.csv
|
|
97
|
+
|
|
98
|
+
# Train via CLI
|
|
99
|
+
autocure train-model data.csv --target target_column
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Tips & notes
|
|
103
|
+
|
|
104
|
+
- cure() applies text preprocessing only to columns detected as object/string dtype.
|
|
105
|
+
- For small categorical cardinality detection and problem-type heuristics, train() uses simple rules; override by preparing the DataFrame appropriately.
|
|
106
|
+
- If you use large text datasets, consider vectorization or specialized NLP pipelines before heavy GridSearchCV.
|
|
107
|
+
|
|
108
|
+
## Contributing
|
|
109
|
+
|
|
110
|
+
Bug reports and PRs welcome. Follow repository guidelines and add tests for new behavior.
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT License
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import click
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from autocure import scan, cure, train
|
|
4
|
+
|
|
5
|
+
@click.group()
|
|
6
|
+
def cli():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@cli.command()
|
|
10
|
+
@click.argument("file")
|
|
11
|
+
def scan_data(file):
|
|
12
|
+
df = pd.read_csv(file)
|
|
13
|
+
click.echo(scan(df))
|
|
14
|
+
|
|
15
|
+
@cli.command()
|
|
16
|
+
@click.argument("file")
|
|
17
|
+
@click.option("--out", default="clean.csv")
|
|
18
|
+
def fix(file, out):
|
|
19
|
+
df = pd.read_csv(file)
|
|
20
|
+
clean = cure(df)
|
|
21
|
+
clean.to_csv(out, index=False)
|
|
22
|
+
click.echo(f"Cleaned file saved: {out}")
|
|
23
|
+
|
|
24
|
+
@cli.command()
|
|
25
|
+
@click.argument("file")
|
|
26
|
+
@click.option("--target", required=True)
|
|
27
|
+
def train_model(file, target):
|
|
28
|
+
df = pd.read_csv(file)
|
|
29
|
+
result = train(df, target)
|
|
30
|
+
click.echo(result)
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
cli()
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import re
|
|
3
|
+
import nltk
|
|
4
|
+
from nltk.corpus import stopwords
|
|
5
|
+
from nltk.tokenize import word_tokenize
|
|
6
|
+
from nltk.stem import WordNetLemmatizer
|
|
7
|
+
|
|
8
|
+
# Download required NLTK data
|
|
9
|
+
nltk.download('punkt', quiet=True)
|
|
10
|
+
nltk.download('stopwords', quiet=True)
|
|
11
|
+
nltk.download('wordnet', quiet=True)
|
|
12
|
+
|
|
13
|
+
def cure(df: pd.DataFrame) -> pd.DataFrame:
|
|
14
|
+
df = df.copy()
|
|
15
|
+
|
|
16
|
+
# Fill numeric
|
|
17
|
+
for col in df.select_dtypes(include=["int", "float"]):
|
|
18
|
+
df[col] = df[col].fillna(df[col].median())
|
|
19
|
+
|
|
20
|
+
# Fill categorical
|
|
21
|
+
for col in df.select_dtypes(include=["object"]):
|
|
22
|
+
if df[col].isnull().any():
|
|
23
|
+
mode_vals = df[col].mode()
|
|
24
|
+
df[col] = df[col].fillna(mode_vals[0] if not mode_vals.empty else "Unknown")
|
|
25
|
+
|
|
26
|
+
# Text preprocessing
|
|
27
|
+
stop_words = set(stopwords.words('english'))
|
|
28
|
+
lemmatizer = WordNetLemmatizer()
|
|
29
|
+
|
|
30
|
+
for col in df.select_dtypes(include=["object"]):
|
|
31
|
+
df[col] = df[col].apply(lambda x: _process_text(x, stop_words, lemmatizer) if isinstance(x, str) else x)
|
|
32
|
+
|
|
33
|
+
# Drop duplicates
|
|
34
|
+
df = df.drop_duplicates()
|
|
35
|
+
|
|
36
|
+
return df
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _process_text(text, stop_words, lemmatizer):
|
|
40
|
+
# Remove punctuation
|
|
41
|
+
text = re.sub(r'[^\w\s]', '', text)
|
|
42
|
+
|
|
43
|
+
# Lowercase
|
|
44
|
+
text = text.lower()
|
|
45
|
+
|
|
46
|
+
# Tokenize
|
|
47
|
+
tokens = word_tokenize(text)
|
|
48
|
+
|
|
49
|
+
# Remove stopwords
|
|
50
|
+
tokens = [word for word in tokens if word not in stop_words]
|
|
51
|
+
|
|
52
|
+
# Lemmatize
|
|
53
|
+
tokens = [lemmatizer.lemmatize(word) for word in tokens]
|
|
54
|
+
|
|
55
|
+
return ' '.join(tokens)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from sklearn.compose import ColumnTransformer
|
|
2
|
+
from sklearn.preprocessing import StandardScaler, OneHotEncoder
|
|
3
|
+
from sklearn.pipeline import Pipeline
|
|
4
|
+
|
|
5
|
+
def make_pipeline(df, target):
|
|
6
|
+
features = df.drop(columns=[target])
|
|
7
|
+
|
|
8
|
+
numeric = features.select_dtypes(include=["int", "float"]).columns
|
|
9
|
+
categorical = features.select_dtypes(include=["object"]).columns
|
|
10
|
+
|
|
11
|
+
transformer = ColumnTransformer(
|
|
12
|
+
transformers=[
|
|
13
|
+
("num", StandardScaler(), numeric),
|
|
14
|
+
("cat", OneHotEncoder(handle_unknown="ignore"), categorical)
|
|
15
|
+
]
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
pipeline = Pipeline([
|
|
19
|
+
("preprocess", transformer)
|
|
20
|
+
])
|
|
21
|
+
|
|
22
|
+
return pipeline
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
|
|
3
|
+
def scan(df: pd.DataFrame):
|
|
4
|
+
report = {}
|
|
5
|
+
|
|
6
|
+
# Missing values
|
|
7
|
+
report["missing_values"] = df.isnull().sum().to_dict()
|
|
8
|
+
|
|
9
|
+
# Dtypes
|
|
10
|
+
report["dtypes"] = df.dtypes.astype(str).to_dict()
|
|
11
|
+
|
|
12
|
+
# Outliers
|
|
13
|
+
outliers = {}
|
|
14
|
+
for col in df.select_dtypes(include=["int", "float"]):
|
|
15
|
+
q1, q3 = df[col].quantile([0.25, 0.75])
|
|
16
|
+
iqr = q3 - q1
|
|
17
|
+
upper, lower = q3 + 1.5 * iqr, q1 - 1.5 * iqr
|
|
18
|
+
outliers[col] = int(((df[col] < lower) | (df[col] > upper)).sum())
|
|
19
|
+
report["outliers"] = outliers
|
|
20
|
+
|
|
21
|
+
# Duplicates
|
|
22
|
+
report["duplicate_rows"] = int(df.duplicated().sum())
|
|
23
|
+
|
|
24
|
+
return report
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from sklearn.model_selection import train_test_split, GridSearchCV
|
|
3
|
+
from sklearn.metrics import accuracy_score, r2_score
|
|
4
|
+
from sklearn.compose import ColumnTransformer
|
|
5
|
+
from sklearn.preprocessing import OneHotEncoder, StandardScaler
|
|
6
|
+
from sklearn.pipeline import Pipeline
|
|
7
|
+
|
|
8
|
+
# ML models
|
|
9
|
+
from sklearn.linear_model import LogisticRegression, LinearRegression
|
|
10
|
+
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
|
|
11
|
+
from sklearn.svm import SVC, SVR
|
|
12
|
+
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
|
|
13
|
+
from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor
|
|
14
|
+
from sklearn.naive_bayes import GaussianNB
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def train(df: pd.DataFrame, target: str):
|
|
18
|
+
X = df.drop(columns=[target])
|
|
19
|
+
y = df[target]
|
|
20
|
+
|
|
21
|
+
# Determine if classification problem
|
|
22
|
+
is_classification = y.dtype == "object" or y.nunique() < 20
|
|
23
|
+
|
|
24
|
+
# Preprocessing
|
|
25
|
+
numeric_cols = X.select_dtypes(include=["int", "float"]).columns
|
|
26
|
+
cat_cols = X.select_dtypes(include=["object"]).columns
|
|
27
|
+
|
|
28
|
+
preprocessor = ColumnTransformer(
|
|
29
|
+
transformers=[
|
|
30
|
+
("num", StandardScaler(), numeric_cols),
|
|
31
|
+
("cat", OneHotEncoder(handle_unknown="ignore"), cat_cols)
|
|
32
|
+
]
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# Split
|
|
36
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
37
|
+
X, y, test_size=0.2, random_state=42
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# ML Algorithms + Params
|
|
41
|
+
if is_classification:
|
|
42
|
+
models = {
|
|
43
|
+
"logistic_regression": (
|
|
44
|
+
LogisticRegression(max_iter=200),
|
|
45
|
+
{"clf__C": [0.1, 1, 10]}
|
|
46
|
+
),
|
|
47
|
+
"random_forest_classifier": (
|
|
48
|
+
RandomForestClassifier(),
|
|
49
|
+
{"clf__n_estimators": [50, 100],
|
|
50
|
+
"clf__max_depth": [5, 10, None]}
|
|
51
|
+
),
|
|
52
|
+
"svm_classifier": (
|
|
53
|
+
SVC(),
|
|
54
|
+
{"clf__C": [0.1, 1, 10],
|
|
55
|
+
"clf__kernel": ["linear", "rbf"]}
|
|
56
|
+
),
|
|
57
|
+
"decision_tree_classifier": (
|
|
58
|
+
DecisionTreeClassifier(),
|
|
59
|
+
{"clf__max_depth": [3, 5, 10, None]}
|
|
60
|
+
),
|
|
61
|
+
"knn_classifier": (
|
|
62
|
+
KNeighborsClassifier(),
|
|
63
|
+
{"clf__n_neighbors": [3, 5, 7]}
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
else:
|
|
68
|
+
models = {
|
|
69
|
+
"linear_regression": (
|
|
70
|
+
LinearRegression(),
|
|
71
|
+
{}
|
|
72
|
+
),
|
|
73
|
+
"random_forest_regressor": (
|
|
74
|
+
RandomForestRegressor(),
|
|
75
|
+
{"clf__n_estimators": [50, 100],
|
|
76
|
+
"clf__max_depth": [5, 10, None]}
|
|
77
|
+
),
|
|
78
|
+
"svm_regressor": (
|
|
79
|
+
SVR(),
|
|
80
|
+
{"clf__C": [0.1, 1, 10],
|
|
81
|
+
"clf__kernel": ["linear", "rbf"]}
|
|
82
|
+
),
|
|
83
|
+
"decision_tree_regressor": (
|
|
84
|
+
DecisionTreeRegressor(),
|
|
85
|
+
{"clf__max_depth": [5, 10, None]}
|
|
86
|
+
),
|
|
87
|
+
"knn_regressor": (
|
|
88
|
+
KNeighborsRegressor(),
|
|
89
|
+
{"clf__n_neighbors": [3, 5, 7]}
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# Train ALL models
|
|
94
|
+
results = []
|
|
95
|
+
best_model, best_params, best_score, best_model_name = None, None, -999, None
|
|
96
|
+
|
|
97
|
+
for name, (model, params) in models.items():
|
|
98
|
+
print(f"Training model: {name}")
|
|
99
|
+
|
|
100
|
+
pipeline = Pipeline([
|
|
101
|
+
("preprocess", preprocessor),
|
|
102
|
+
("clf", model)
|
|
103
|
+
])
|
|
104
|
+
|
|
105
|
+
grid = GridSearchCV(
|
|
106
|
+
pipeline,
|
|
107
|
+
params,
|
|
108
|
+
cv=3,
|
|
109
|
+
n_jobs=-1,
|
|
110
|
+
scoring="accuracy" if is_classification else "r2"
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
grid.fit(X_train, y_train)
|
|
114
|
+
|
|
115
|
+
preds = grid.predict(X_test)
|
|
116
|
+
score = accuracy_score(y_test, preds) if is_classification else r2_score(y_test, preds)
|
|
117
|
+
|
|
118
|
+
results.append({
|
|
119
|
+
"model": name,
|
|
120
|
+
"best_params": grid.best_params_,
|
|
121
|
+
"score": score
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
if score > best_score:
|
|
125
|
+
best_score = score
|
|
126
|
+
best_model = grid.best_estimator_
|
|
127
|
+
best_model_name = name
|
|
128
|
+
best_params = grid.best_params_
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
"best_model": best_model,
|
|
132
|
+
"best_model_name": best_model_name,
|
|
133
|
+
"best_score": best_score,
|
|
134
|
+
"best_params": best_params,
|
|
135
|
+
"leaderboard": results
|
|
136
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autocure
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Automated data cleaning and auto ML training with hyperparameter tuning.
|
|
5
|
+
Home-page: https://pypi.org/project/autocure/
|
|
6
|
+
Author: Vishal More
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Source, https://github.com/YOUR_GITHUB/autocure
|
|
9
|
+
Project-URL: Tracker, https://github.com/YOUR_GITHUB/autocure/issues
|
|
10
|
+
Keywords: data-cleaning,machine-learning,automation,sklearn,pipeline
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: pandas
|
|
18
|
+
Requires-Dist: scikit-learn
|
|
19
|
+
Requires-Dist: click
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
|
|
23
|
+
# Autocure
|
|
24
|
+
|
|
25
|
+
Automated data cleaning + AutoML model training with hyperparameter tuning.
|
|
26
|
+
|
|
27
|
+
## Key features
|
|
28
|
+
|
|
29
|
+
- Data scan
|
|
30
|
+
- Missing values summary
|
|
31
|
+
- Dtype inference
|
|
32
|
+
- Outlier counts (IQR method)
|
|
33
|
+
- Duplicate rows count
|
|
34
|
+
|
|
35
|
+
- Data cleaning (cure)
|
|
36
|
+
- Numeric imputation (median)
|
|
37
|
+
- Categorical imputation (mode / fallback "Unknown")
|
|
38
|
+
- Text preprocessing (applies only to text columns):
|
|
39
|
+
- remove punctuation
|
|
40
|
+
- lowercase
|
|
41
|
+
- tokenize
|
|
42
|
+
- remove stopwords
|
|
43
|
+
- lemmatize
|
|
44
|
+
- Drop duplicates
|
|
45
|
+
|
|
46
|
+
- Pipeline & AutoML
|
|
47
|
+
- Automatic ColumnTransformer (StandardScaler for numeric, OneHotEncoder for categorical)
|
|
48
|
+
- Support for classification and regression
|
|
49
|
+
- Multiple algorithms with GridSearchCV hyperparameter search
|
|
50
|
+
- Model leaderboard and best-model selection
|
|
51
|
+
|
|
52
|
+
- CLI
|
|
53
|
+
- scan-data, fix, train-model commands for quick workflows
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
From project root (editable install for development):
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
python -m pip install -e .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or install dependencies:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install -r requirements.txt
|
|
67
|
+
pip install nltk
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
NLTK data used by cure() is downloaded at runtime (punkt, stopwords, wordnet).
|
|
71
|
+
|
|
72
|
+
## Quick usage
|
|
73
|
+
|
|
74
|
+
Python:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import autocure as ac
|
|
78
|
+
import pandas as pd
|
|
79
|
+
|
|
80
|
+
df = pd.read_csv("your_dataset.csv")
|
|
81
|
+
|
|
82
|
+
# 1) Inspect dataset
|
|
83
|
+
report = ac.scan(df)
|
|
84
|
+
print(report)
|
|
85
|
+
|
|
86
|
+
# 2) Clean dataset
|
|
87
|
+
clean = ac.cure(df)
|
|
88
|
+
|
|
89
|
+
# 3) Create pipeline (optional)
|
|
90
|
+
pipeline = ac.make_pipeline(clean, target="target_column")
|
|
91
|
+
|
|
92
|
+
# 4) Train models (returns a dict)
|
|
93
|
+
result = ac.train(clean, target="target_column")
|
|
94
|
+
|
|
95
|
+
print(result["best_model_name"])
|
|
96
|
+
print("score:", result["best_score"])
|
|
97
|
+
# Best model object for predict:
|
|
98
|
+
best_model = result["best_model"]
|
|
99
|
+
preds = best_model.predict(clean.drop(columns=["target_column"]).iloc[:5])
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Returned keys from train():
|
|
103
|
+
- best_model (fitted sklearn estimator / pipeline)
|
|
104
|
+
- best_model_name
|
|
105
|
+
- best_score
|
|
106
|
+
- best_params
|
|
107
|
+
- leaderboard (list/dict of model results)
|
|
108
|
+
|
|
109
|
+
## CLI
|
|
110
|
+
|
|
111
|
+
Examples:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Scan a CSV
|
|
115
|
+
autocure scan-data data.csv
|
|
116
|
+
|
|
117
|
+
# Clean and save
|
|
118
|
+
autocure fix data.csv --out cleaned.csv
|
|
119
|
+
|
|
120
|
+
# Train via CLI
|
|
121
|
+
autocure train-model data.csv --target target_column
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Tips & notes
|
|
125
|
+
|
|
126
|
+
- cure() applies text preprocessing only to columns detected as object/string dtype.
|
|
127
|
+
- For small categorical cardinality detection and problem-type heuristics, train() uses simple rules; override by preparing the DataFrame appropriately.
|
|
128
|
+
- If you use large text datasets, consider vectorization or specialized NLP pipelines before heavy GridSearchCV.
|
|
129
|
+
|
|
130
|
+
## Contributing
|
|
131
|
+
|
|
132
|
+
Bug reports and PRs welcome. Follow repository guidelines and add tests for new behavior.
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT License
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.cfg
|
|
5
|
+
setup.py
|
|
6
|
+
autocure/__init__.py
|
|
7
|
+
autocure/cure.py
|
|
8
|
+
autocure/pipeline.py
|
|
9
|
+
autocure/scan.py
|
|
10
|
+
autocure/train.py
|
|
11
|
+
autocure.egg-info/PKG-INFO
|
|
12
|
+
autocure.egg-info/SOURCES.txt
|
|
13
|
+
autocure.egg-info/dependency_links.txt
|
|
14
|
+
autocure.egg-info/entry_points.txt
|
|
15
|
+
autocure.egg-info/requires.txt
|
|
16
|
+
autocure.egg-info/top_level.txt
|
|
17
|
+
autocure/cli/__init__.py
|
|
18
|
+
autocure/cli/main.py
|
|
19
|
+
test/test.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
autocure
|
autocure-0.2.0/setup.cfg
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = autocure
|
|
3
|
+
version = 0.2.0
|
|
4
|
+
author = Vishal More
|
|
5
|
+
description = Automated data cleaning and auto ML training with hyperparameter tuning.
|
|
6
|
+
long_description = file: README.md
|
|
7
|
+
long_description_content_type = text/markdown
|
|
8
|
+
license = MIT
|
|
9
|
+
keywords = data-cleaning, machine-learning, automation, sklearn, pipeline
|
|
10
|
+
url = https://pypi.org/project/autocure/
|
|
11
|
+
project_urls =
|
|
12
|
+
Source = https://github.com/YOUR_GITHUB/autocure
|
|
13
|
+
Tracker = https://github.com/YOUR_GITHUB/autocure/issues
|
|
14
|
+
classifiers =
|
|
15
|
+
Programming Language :: Python :: 3
|
|
16
|
+
License :: OSI Approved :: MIT License
|
|
17
|
+
Operating System :: OS Independent
|
|
18
|
+
|
|
19
|
+
[options]
|
|
20
|
+
packages = find:
|
|
21
|
+
python_requires = >=3.8
|
|
22
|
+
install_requires =
|
|
23
|
+
pandas
|
|
24
|
+
scikit-learn
|
|
25
|
+
click
|
|
26
|
+
|
|
27
|
+
[options.entry_points]
|
|
28
|
+
console_scripts =
|
|
29
|
+
autocure=autocure.cli.main:cli
|
|
30
|
+
|
|
31
|
+
[egg_info]
|
|
32
|
+
tag_build =
|
|
33
|
+
tag_date = 0
|
|
34
|
+
|
autocure-0.2.0/setup.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="autocure",
|
|
5
|
+
version="0.2.0",
|
|
6
|
+
packages=find_packages(),
|
|
7
|
+
install_requires=[
|
|
8
|
+
"pandas",
|
|
9
|
+
"scikit-learn",
|
|
10
|
+
"click"
|
|
11
|
+
],
|
|
12
|
+
entry_points={
|
|
13
|
+
"console_scripts": [
|
|
14
|
+
"autocure=autocure.cli.main:cli"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Autocure test script using IMDB Sentiment Dataset
|
|
3
|
+
(review, sentiment)
|
|
4
|
+
|
|
5
|
+
Steps:
|
|
6
|
+
- load dataset from URL
|
|
7
|
+
- scan
|
|
8
|
+
- cure
|
|
9
|
+
- make_pipeline
|
|
10
|
+
- train
|
|
11
|
+
- predict
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from autocure import scan, cure, make_pipeline, train
|
|
15
|
+
import pandas as pd
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main():
|
|
19
|
+
|
|
20
|
+
print("๐ฌ Loading IMDB Sentiment Dataset...")
|
|
21
|
+
url = "https://raw.githubusercontent.com/Ankit152/IMDB-sentiment-analysis/master/IMDB-Dataset.csv"
|
|
22
|
+
df = pd.read_csv(url)
|
|
23
|
+
|
|
24
|
+
print(df.head())
|
|
25
|
+
|
|
26
|
+
print("\n๐ Rename columns for consistency...")
|
|
27
|
+
df["content"] = df["review"]
|
|
28
|
+
df["label"] = df["sentiment"].map({"positive": 1, "negative": 0})
|
|
29
|
+
df = df[["content", "label"]]
|
|
30
|
+
|
|
31
|
+
print(df.head())
|
|
32
|
+
|
|
33
|
+
print("\n๐ Running scan()...")
|
|
34
|
+
issues = scan(df)
|
|
35
|
+
print("Issues found:", issues)
|
|
36
|
+
|
|
37
|
+
print("\n๐งน Running cure()...")
|
|
38
|
+
df_clean = cure(df)
|
|
39
|
+
print("Cleaned data sample:")
|
|
40
|
+
print(df_clean.head())
|
|
41
|
+
|
|
42
|
+
print("\n๐ Creating pipeline...")
|
|
43
|
+
pipeline = make_pipeline(df_clean, target="label")
|
|
44
|
+
print("Pipeline created:")
|
|
45
|
+
print(pipeline)
|
|
46
|
+
|
|
47
|
+
print("\n๐ค Training using train()...")
|
|
48
|
+
result = train(df_clean, target="label")
|
|
49
|
+
|
|
50
|
+
best_model = result["best_model"]
|
|
51
|
+
best_score = result["best_score"]
|
|
52
|
+
|
|
53
|
+
print("\n๐ Best model:")
|
|
54
|
+
print(result["best_model_name"])
|
|
55
|
+
print(f"Best score: {best_score:.4f}")
|
|
56
|
+
print("Best parameters:", result["best_params"])
|
|
57
|
+
|
|
58
|
+
print("\n๐ฎ Predictions on sample data:")
|
|
59
|
+
sample_data = df_clean.drop("label", axis=1).iloc[:5]
|
|
60
|
+
preds = best_model.predict(sample_data)
|
|
61
|
+
print(preds)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if __name__ == "__main__":
|
|
65
|
+
main()
|