pypreml 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.
- pypreml-0.1.0/PKG-INFO +223 -0
- pypreml-0.1.0/README.md +190 -0
- pypreml-0.1.0/preml/__init__.py +87 -0
- pypreml-0.1.0/preml/config.py +115 -0
- pypreml-0.1.0/preml/eda.py +294 -0
- pypreml-0.1.0/preml/exceptions.py +126 -0
- pypreml-0.1.0/preml/feature_engineering.py +350 -0
- pypreml-0.1.0/preml/model_utils.py +444 -0
- pypreml-0.1.0/preml/preprocessing.py +251 -0
- pypreml-0.1.0/preml/recommendation_engine.py +1301 -0
- pypreml-0.1.0/preml/recommendation_utils.py +25 -0
- pypreml-0.1.0/preml/report.py +692 -0
- pypreml-0.1.0/preml/schema.py +307 -0
- pypreml-0.1.0/preml/statistics_engine.py +560 -0
- pypreml-0.1.0/preml/visualization.py +773 -0
- pypreml-0.1.0/pypreml.egg-info/PKG-INFO +223 -0
- pypreml-0.1.0/pypreml.egg-info/SOURCES.txt +24 -0
- pypreml-0.1.0/pypreml.egg-info/dependency_links.txt +1 -0
- pypreml-0.1.0/pypreml.egg-info/requires.txt +10 -0
- pypreml-0.1.0/pypreml.egg-info/top_level.txt +1 -0
- pypreml-0.1.0/pyproject.toml +57 -0
- pypreml-0.1.0/setup.cfg +4 -0
- pypreml-0.1.0/tests/test_eda.py +86 -0
- pypreml-0.1.0/tests/test_preprocessing.py +182 -0
- pypreml-0.1.0/tests/test_recommendations.py +621 -0
- pypreml-0.1.0/tests/test_statistics.py +249 -0
pypreml-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pypreml
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Production‑ready machine learning toolkit for EDA, preprocessing, and modelling.
|
|
5
|
+
Author-email: Ali Nazer <alinazer30@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/alinazer30/preml
|
|
8
|
+
Project-URL: Repository, https://github.com/alinazer30/preml
|
|
9
|
+
Project-URL: Issues, https://github.com/alinazer30/preml/issues
|
|
10
|
+
Keywords: machine learning,eda,preprocessing,feature engineering,scikit-learn
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
Requires-Dist: pandas>=1.3.0
|
|
25
|
+
Requires-Dist: numpy>=1.21.0
|
|
26
|
+
Requires-Dist: scipy>=1.7.0
|
|
27
|
+
Requires-Dist: matplotlib>=3.4.0
|
|
28
|
+
Requires-Dist: seaborn>=0.11.0
|
|
29
|
+
Requires-Dist: scikit-learn>=1.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=3.0; extra == "dev"
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
# PreML
|
|
36
|
+
|
|
37
|
+
PreML is a modular Python library for exploratory data analysis, statistical recommendations, preprocessing pipeline generation, and feature engineering guidance for tabular datasets.
|
|
38
|
+
|
|
39
|
+
The source code now lives inside the `preml/` package directory, which keeps the project organized and matches the installed namespace.
|
|
40
|
+
|
|
41
|
+
## What This Project Does
|
|
42
|
+
|
|
43
|
+
- Computes statistical facts from tabular data.
|
|
44
|
+
- Turns those facts into evidence-based recommendations.
|
|
45
|
+
- Builds scikit-learn compatible preprocessing pipelines.
|
|
46
|
+
- Suggests feature engineering ideas from measurable patterns.
|
|
47
|
+
- Keeps analysis, recommendations, and preprocessing separated into focused modules.
|
|
48
|
+
|
|
49
|
+
## File Guide
|
|
50
|
+
|
|
51
|
+
Use this map to understand how the current files fit together:
|
|
52
|
+
|
|
53
|
+
| File | Purpose |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| [preml/__init__.py](preml/__init__.py) | Package exports and top-level public API. |
|
|
56
|
+
| [preml/config.py](preml/config.py) | Central thresholds and defaults via `MLToolkitConfig`. |
|
|
57
|
+
| [preml/statistics_engine.py](preml/statistics_engine.py) | Computes dataset facts such as profiles, missingness, outliers, and correlations. |
|
|
58
|
+
| [preml/recommendation_engine.py](preml/recommendation_engine.py) | Converts statistics into recommendations and model guidance. |
|
|
59
|
+
| [preml/eda.py](preml/eda.py) | Orchestrates the full EDA flow and produces summaries. |
|
|
60
|
+
| [preml/preprocessing.py](preml/preprocessing.py) | Builds scikit-learn preprocessing pipelines from EDA results. |
|
|
61
|
+
| [preml/feature_engineering.py](preml/feature_engineering.py) | Proposes new features from statistical evidence. |
|
|
62
|
+
| [preml/visualization.py](preml/visualization.py) | Plotting and visual analysis helpers. |
|
|
63
|
+
| [preml/schema.py](preml/schema.py) | Shared dataclasses used across the library. |
|
|
64
|
+
| [preml/exceptions.py](preml/exceptions.py) | Custom exception hierarchy. |
|
|
65
|
+
| [requirements.txt](requirements.txt) | Runtime dependencies for local installs. |
|
|
66
|
+
| [pyproject.toml](pyproject.toml) | Build metadata and packaging configuration. |
|
|
67
|
+
| [.gitignore](.gitignore) | Ignores caches, build artifacts, notebooks, and local environments. |
|
|
68
|
+
| [tests/](tests/) | Test suite. |
|
|
69
|
+
|
|
70
|
+
## Highlights
|
|
71
|
+
|
|
72
|
+
- Automatic EDA for missing values, outliers, correlation, and feature profiling.
|
|
73
|
+
- Evidence-based recommendations for imputation, encoding, scaling, transformation, and feature selection.
|
|
74
|
+
- Scikit-learn compatible preprocessing pipelines tailored to feature types and data quality signals.
|
|
75
|
+
- Feature engineering suggestions grounded in statistical evidence rather than column names.
|
|
76
|
+
- Clean module boundaries that make the package easier to test, extend, and maintain.
|
|
77
|
+
|
|
78
|
+
## Installation
|
|
79
|
+
|
|
80
|
+
### From source
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/alinazer30/preml.git
|
|
84
|
+
cd preml
|
|
85
|
+
python -m pip install -e .
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Dependencies
|
|
89
|
+
|
|
90
|
+
The project targets Python 3.9+ and uses:
|
|
91
|
+
|
|
92
|
+
- pandas
|
|
93
|
+
- numpy
|
|
94
|
+
- scipy
|
|
95
|
+
- matplotlib
|
|
96
|
+
- seaborn
|
|
97
|
+
- scikit-learn
|
|
98
|
+
|
|
99
|
+
## Quick Start
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import pandas as pd
|
|
103
|
+
|
|
104
|
+
from preml.eda import EDAAnalyzer, quick_eda
|
|
105
|
+
from preml.preprocessing import PreprocessingBuilder
|
|
106
|
+
|
|
107
|
+
df = pd.read_csv("your_dataset.csv")
|
|
108
|
+
|
|
109
|
+
# Run the full analysis
|
|
110
|
+
analysis = quick_eda(df, target="target_column")
|
|
111
|
+
|
|
112
|
+
# Or use the orchestrator directly
|
|
113
|
+
analyzer = EDAAnalyzer(df, target="target_column")
|
|
114
|
+
analysis = analyzer.run()
|
|
115
|
+
print(analyzer.summary())
|
|
116
|
+
|
|
117
|
+
# Build a preprocessing pipeline from the analysis output
|
|
118
|
+
builder = PreprocessingBuilder(analysis)
|
|
119
|
+
pipeline = builder.build_pipeline()
|
|
120
|
+
X = builder.fit_transform(df)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Typical Workflow
|
|
124
|
+
|
|
125
|
+
1. Load your tabular dataset into a pandas DataFrame.
|
|
126
|
+
2. Run `EDAAnalyzer` or `quick_eda` to compute facts and recommendations.
|
|
127
|
+
3. Build a preprocessing pipeline with `PreprocessingBuilder`.
|
|
128
|
+
4. Inspect the returned schema objects and recommendations to guide modelling decisions.
|
|
129
|
+
|
|
130
|
+
## Public API
|
|
131
|
+
|
|
132
|
+
The package exposes the most common shared types at the package root:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from preml import MLToolkitConfig, default_config
|
|
136
|
+
from preml import DataValidationError, RecommendationError
|
|
137
|
+
from preml import FeatureProfile, Recommendation, TargetProfile
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Useful module entry points:
|
|
141
|
+
|
|
142
|
+
- `preml.eda.EDAAnalyzer`
|
|
143
|
+
- `preml.eda.quick_eda`
|
|
144
|
+
- `preml.preprocessing.PreprocessingBuilder`
|
|
145
|
+
- `preml.recommendation_engine.RecommendationEngine`
|
|
146
|
+
- `preml.statistics_engine.StatisticsEngine`
|
|
147
|
+
|
|
148
|
+
## Configuration
|
|
149
|
+
|
|
150
|
+
All thresholds and defaults are defined in `MLToolkitConfig`.
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from preml.config import MLToolkitConfig
|
|
154
|
+
from preml.eda import EDAAnalyzer
|
|
155
|
+
|
|
156
|
+
config = MLToolkitConfig(
|
|
157
|
+
missing_threshold=0.2,
|
|
158
|
+
correlation_threshold=0.85,
|
|
159
|
+
random_state=42,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
analyzer = EDAAnalyzer(df, target="target_column", config=config)
|
|
163
|
+
analysis = analyzer.run()
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Key configuration values include:
|
|
167
|
+
|
|
168
|
+
- `missing_threshold`
|
|
169
|
+
- `high_cardinality_threshold`
|
|
170
|
+
- `max_unique_for_categorical_like`
|
|
171
|
+
- `correlation_threshold`
|
|
172
|
+
- `skewness_threshold`
|
|
173
|
+
- `outlier_method`
|
|
174
|
+
- `iqr_multiplier`
|
|
175
|
+
- `random_state`
|
|
176
|
+
|
|
177
|
+
## GitHub Workflow
|
|
178
|
+
|
|
179
|
+
Recommended commands to publish the project cleanly:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
git init
|
|
183
|
+
git add README.md pyproject.toml requirements.txt .gitignore preml/ tests/
|
|
184
|
+
git status
|
|
185
|
+
git commit -m "Prepare packaged ML toolkit"
|
|
186
|
+
git branch -M main
|
|
187
|
+
git remote add origin https://github.com/<your-username>/preml.git
|
|
188
|
+
git push -u origin main
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Best practices when pushing:
|
|
192
|
+
|
|
193
|
+
- Commit only the files you intended to change.
|
|
194
|
+
- Run the test suite before pushing.
|
|
195
|
+
- Keep the README synchronized with the real repository layout.
|
|
196
|
+
- Avoid committing virtual environments, caches, notebooks, and build artifacts.
|
|
197
|
+
- Prefer small, descriptive commits such as `docs: reorganize README` or `fix: align packaging layout`.
|
|
198
|
+
|
|
199
|
+
## Development
|
|
200
|
+
|
|
201
|
+
Run the test suite with:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
pytest tests/
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
If you want to sanity-check the edited modules locally, you can also run:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
python -m py_compile preml/preprocessing.py preml/eda.py preml/recommendation_engine.py
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Contributing
|
|
214
|
+
|
|
215
|
+
Contributions are welcome. Keep changes aligned with the existing architecture, preserve the separation between facts and recommendations, and add tests when you change behaviour.
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
MIT License.
|
|
220
|
+
|
|
221
|
+
## Author
|
|
222
|
+
|
|
223
|
+
Ali Nazer – alinazer30@gmail.com
|
pypreml-0.1.0/README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+

|
|
2
|
+
# PreML
|
|
3
|
+
|
|
4
|
+
PreML is a modular Python library for exploratory data analysis, statistical recommendations, preprocessing pipeline generation, and feature engineering guidance for tabular datasets.
|
|
5
|
+
|
|
6
|
+
The source code now lives inside the `preml/` package directory, which keeps the project organized and matches the installed namespace.
|
|
7
|
+
|
|
8
|
+
## What This Project Does
|
|
9
|
+
|
|
10
|
+
- Computes statistical facts from tabular data.
|
|
11
|
+
- Turns those facts into evidence-based recommendations.
|
|
12
|
+
- Builds scikit-learn compatible preprocessing pipelines.
|
|
13
|
+
- Suggests feature engineering ideas from measurable patterns.
|
|
14
|
+
- Keeps analysis, recommendations, and preprocessing separated into focused modules.
|
|
15
|
+
|
|
16
|
+
## File Guide
|
|
17
|
+
|
|
18
|
+
Use this map to understand how the current files fit together:
|
|
19
|
+
|
|
20
|
+
| File | Purpose |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| [preml/__init__.py](preml/__init__.py) | Package exports and top-level public API. |
|
|
23
|
+
| [preml/config.py](preml/config.py) | Central thresholds and defaults via `MLToolkitConfig`. |
|
|
24
|
+
| [preml/statistics_engine.py](preml/statistics_engine.py) | Computes dataset facts such as profiles, missingness, outliers, and correlations. |
|
|
25
|
+
| [preml/recommendation_engine.py](preml/recommendation_engine.py) | Converts statistics into recommendations and model guidance. |
|
|
26
|
+
| [preml/eda.py](preml/eda.py) | Orchestrates the full EDA flow and produces summaries. |
|
|
27
|
+
| [preml/preprocessing.py](preml/preprocessing.py) | Builds scikit-learn preprocessing pipelines from EDA results. |
|
|
28
|
+
| [preml/feature_engineering.py](preml/feature_engineering.py) | Proposes new features from statistical evidence. |
|
|
29
|
+
| [preml/visualization.py](preml/visualization.py) | Plotting and visual analysis helpers. |
|
|
30
|
+
| [preml/schema.py](preml/schema.py) | Shared dataclasses used across the library. |
|
|
31
|
+
| [preml/exceptions.py](preml/exceptions.py) | Custom exception hierarchy. |
|
|
32
|
+
| [requirements.txt](requirements.txt) | Runtime dependencies for local installs. |
|
|
33
|
+
| [pyproject.toml](pyproject.toml) | Build metadata and packaging configuration. |
|
|
34
|
+
| [.gitignore](.gitignore) | Ignores caches, build artifacts, notebooks, and local environments. |
|
|
35
|
+
| [tests/](tests/) | Test suite. |
|
|
36
|
+
|
|
37
|
+
## Highlights
|
|
38
|
+
|
|
39
|
+
- Automatic EDA for missing values, outliers, correlation, and feature profiling.
|
|
40
|
+
- Evidence-based recommendations for imputation, encoding, scaling, transformation, and feature selection.
|
|
41
|
+
- Scikit-learn compatible preprocessing pipelines tailored to feature types and data quality signals.
|
|
42
|
+
- Feature engineering suggestions grounded in statistical evidence rather than column names.
|
|
43
|
+
- Clean module boundaries that make the package easier to test, extend, and maintain.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
### From source
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
git clone https://github.com/alinazer30/preml.git
|
|
51
|
+
cd preml
|
|
52
|
+
python -m pip install -e .
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Dependencies
|
|
56
|
+
|
|
57
|
+
The project targets Python 3.9+ and uses:
|
|
58
|
+
|
|
59
|
+
- pandas
|
|
60
|
+
- numpy
|
|
61
|
+
- scipy
|
|
62
|
+
- matplotlib
|
|
63
|
+
- seaborn
|
|
64
|
+
- scikit-learn
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import pandas as pd
|
|
70
|
+
|
|
71
|
+
from preml.eda import EDAAnalyzer, quick_eda
|
|
72
|
+
from preml.preprocessing import PreprocessingBuilder
|
|
73
|
+
|
|
74
|
+
df = pd.read_csv("your_dataset.csv")
|
|
75
|
+
|
|
76
|
+
# Run the full analysis
|
|
77
|
+
analysis = quick_eda(df, target="target_column")
|
|
78
|
+
|
|
79
|
+
# Or use the orchestrator directly
|
|
80
|
+
analyzer = EDAAnalyzer(df, target="target_column")
|
|
81
|
+
analysis = analyzer.run()
|
|
82
|
+
print(analyzer.summary())
|
|
83
|
+
|
|
84
|
+
# Build a preprocessing pipeline from the analysis output
|
|
85
|
+
builder = PreprocessingBuilder(analysis)
|
|
86
|
+
pipeline = builder.build_pipeline()
|
|
87
|
+
X = builder.fit_transform(df)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Typical Workflow
|
|
91
|
+
|
|
92
|
+
1. Load your tabular dataset into a pandas DataFrame.
|
|
93
|
+
2. Run `EDAAnalyzer` or `quick_eda` to compute facts and recommendations.
|
|
94
|
+
3. Build a preprocessing pipeline with `PreprocessingBuilder`.
|
|
95
|
+
4. Inspect the returned schema objects and recommendations to guide modelling decisions.
|
|
96
|
+
|
|
97
|
+
## Public API
|
|
98
|
+
|
|
99
|
+
The package exposes the most common shared types at the package root:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from preml import MLToolkitConfig, default_config
|
|
103
|
+
from preml import DataValidationError, RecommendationError
|
|
104
|
+
from preml import FeatureProfile, Recommendation, TargetProfile
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Useful module entry points:
|
|
108
|
+
|
|
109
|
+
- `preml.eda.EDAAnalyzer`
|
|
110
|
+
- `preml.eda.quick_eda`
|
|
111
|
+
- `preml.preprocessing.PreprocessingBuilder`
|
|
112
|
+
- `preml.recommendation_engine.RecommendationEngine`
|
|
113
|
+
- `preml.statistics_engine.StatisticsEngine`
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
All thresholds and defaults are defined in `MLToolkitConfig`.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from preml.config import MLToolkitConfig
|
|
121
|
+
from preml.eda import EDAAnalyzer
|
|
122
|
+
|
|
123
|
+
config = MLToolkitConfig(
|
|
124
|
+
missing_threshold=0.2,
|
|
125
|
+
correlation_threshold=0.85,
|
|
126
|
+
random_state=42,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
analyzer = EDAAnalyzer(df, target="target_column", config=config)
|
|
130
|
+
analysis = analyzer.run()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Key configuration values include:
|
|
134
|
+
|
|
135
|
+
- `missing_threshold`
|
|
136
|
+
- `high_cardinality_threshold`
|
|
137
|
+
- `max_unique_for_categorical_like`
|
|
138
|
+
- `correlation_threshold`
|
|
139
|
+
- `skewness_threshold`
|
|
140
|
+
- `outlier_method`
|
|
141
|
+
- `iqr_multiplier`
|
|
142
|
+
- `random_state`
|
|
143
|
+
|
|
144
|
+
## GitHub Workflow
|
|
145
|
+
|
|
146
|
+
Recommended commands to publish the project cleanly:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
git init
|
|
150
|
+
git add README.md pyproject.toml requirements.txt .gitignore preml/ tests/
|
|
151
|
+
git status
|
|
152
|
+
git commit -m "Prepare packaged ML toolkit"
|
|
153
|
+
git branch -M main
|
|
154
|
+
git remote add origin https://github.com/<your-username>/preml.git
|
|
155
|
+
git push -u origin main
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Best practices when pushing:
|
|
159
|
+
|
|
160
|
+
- Commit only the files you intended to change.
|
|
161
|
+
- Run the test suite before pushing.
|
|
162
|
+
- Keep the README synchronized with the real repository layout.
|
|
163
|
+
- Avoid committing virtual environments, caches, notebooks, and build artifacts.
|
|
164
|
+
- Prefer small, descriptive commits such as `docs: reorganize README` or `fix: align packaging layout`.
|
|
165
|
+
|
|
166
|
+
## Development
|
|
167
|
+
|
|
168
|
+
Run the test suite with:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pytest tests/
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
If you want to sanity-check the edited modules locally, you can also run:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
python -m py_compile preml/preprocessing.py preml/eda.py preml/recommendation_engine.py
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Contributing
|
|
181
|
+
|
|
182
|
+
Contributions are welcome. Keep changes aligned with the existing architecture, preserve the separation between facts and recommendations, and add tests when you change behaviour.
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
MIT License.
|
|
187
|
+
|
|
188
|
+
## Author
|
|
189
|
+
|
|
190
|
+
Ali Nazer – alinazer30@gmail.com
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Copyright (c) 2026 Ali Nazer
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
# See the LICENSE file in the project root for license information.
|
|
4
|
+
"""
|
|
5
|
+
preml — A professional machine learning toolkit for EDA,
|
|
6
|
+
preprocessing, feature engineering, and modeling.
|
|
7
|
+
|
|
8
|
+
The package is organized into clearly separated modules, each
|
|
9
|
+
responsible for a single domain concern:
|
|
10
|
+
|
|
11
|
+
- config : Central configuration and thresholds.
|
|
12
|
+
- exceptions : Custom exception hierarchy.
|
|
13
|
+
- schema : Strongly‑typed data models (dataclasses).
|
|
14
|
+
- statistics_engine: Extracts statistical facts from data.
|
|
15
|
+
- recommendation_engine: Generates evidence‑based recommendations.
|
|
16
|
+
- eda : Orchestrates analysis and produces insights.
|
|
17
|
+
- visualization : Creates plots (statistics‑free).
|
|
18
|
+
- preprocessing : Builds sklearn‑compatible pipelines.
|
|
19
|
+
- feature_engineering: Suggests and creates new features.
|
|
20
|
+
- model_utils : Baseline models, cross‑validation, metrics.
|
|
21
|
+
- report : Generates reports in various formats.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
__version__ = "0.1.0"
|
|
25
|
+
__author__ = "Your Name <your.email@example.com>"
|
|
26
|
+
|
|
27
|
+
# Expose the most commonly used classes at package level
|
|
28
|
+
from preml.config import MLToolkitConfig, default_config
|
|
29
|
+
from preml.exceptions import (
|
|
30
|
+
MLToolkitError,
|
|
31
|
+
DataValidationError,
|
|
32
|
+
StatisticsError,
|
|
33
|
+
RecommendationError,
|
|
34
|
+
PreprocessingError,
|
|
35
|
+
FeatureEngineeringError,
|
|
36
|
+
ModelError,
|
|
37
|
+
ReportError,
|
|
38
|
+
VisualizationError,
|
|
39
|
+
)
|
|
40
|
+
from preml.schema import (
|
|
41
|
+
DatasetMetadata,
|
|
42
|
+
DuplicateReport,
|
|
43
|
+
InfiniteReport,
|
|
44
|
+
MissingColumnReport,
|
|
45
|
+
MissingReport,
|
|
46
|
+
OutlierReport,
|
|
47
|
+
NumericDistributionProfile,
|
|
48
|
+
CategoricalProfile,
|
|
49
|
+
FeatureProfile,
|
|
50
|
+
CorrelationPair,
|
|
51
|
+
TargetProfile,
|
|
52
|
+
Evidence,
|
|
53
|
+
Recommendation,
|
|
54
|
+
PipelineSuggestion,
|
|
55
|
+
ModelRecommendation,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
__all__ = [
|
|
59
|
+
"MLToolkitConfig",
|
|
60
|
+
"default_config",
|
|
61
|
+
# Exceptions
|
|
62
|
+
"MLToolkitError",
|
|
63
|
+
"DataValidationError",
|
|
64
|
+
"StatisticsError",
|
|
65
|
+
"RecommendationError",
|
|
66
|
+
"PreprocessingError",
|
|
67
|
+
"FeatureEngineeringError",
|
|
68
|
+
"ModelError",
|
|
69
|
+
"ReportError",
|
|
70
|
+
"VisualizationError",
|
|
71
|
+
# Schema
|
|
72
|
+
"DatasetMetadata",
|
|
73
|
+
"DuplicateReport",
|
|
74
|
+
"InfiniteReport",
|
|
75
|
+
"MissingColumnReport",
|
|
76
|
+
"MissingReport",
|
|
77
|
+
"OutlierReport",
|
|
78
|
+
"NumericDistributionProfile",
|
|
79
|
+
"CategoricalProfile",
|
|
80
|
+
"FeatureProfile",
|
|
81
|
+
"CorrelationPair",
|
|
82
|
+
"TargetProfile",
|
|
83
|
+
"Evidence",
|
|
84
|
+
"Recommendation",
|
|
85
|
+
"PipelineSuggestion",
|
|
86
|
+
"ModelRecommendation",
|
|
87
|
+
]
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Central configuration module for preml.
|
|
2
|
+
|
|
3
|
+
This module defines all tunable parameters, thresholds, and defaults
|
|
4
|
+
used throughout the library. It is designed to be imported anywhere
|
|
5
|
+
without creating circular dependencies and does not rely on any
|
|
6
|
+
heavy external packages (only the standard library).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from typing import Literal, Optional
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class MLToolkitConfig:
|
|
15
|
+
"""Immutable configuration container for preml.
|
|
16
|
+
|
|
17
|
+
All parameters have sensible defaults, but can be overridden
|
|
18
|
+
by creating a new instance or modifying attributes directly.
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
missing_threshold: Ratio above which a column is flagged as
|
|
22
|
+
having high missingness (0.0 to 1.0).
|
|
23
|
+
high_cardinality_threshold: Number of unique values above which
|
|
24
|
+
a categorical column is considered high cardinality.
|
|
25
|
+
max_unique_for_categorical_like: Maximum unique values for a
|
|
26
|
+
numeric column to be considered as categorical-like.
|
|
27
|
+
correlation_threshold: Absolute correlation coefficient above
|
|
28
|
+
which a pair of features is flagged as highly correlated.
|
|
29
|
+
skewness_threshold: Absolute skewness above which a distribution
|
|
30
|
+
is considered heavily skewed.
|
|
31
|
+
kurtosis_threshold: Absolute kurtosis above which a distribution
|
|
32
|
+
is considered heavily tailed (not currently used).
|
|
33
|
+
cv_threshold: Coefficient of Variation above which a feature
|
|
34
|
+
is marked as highly dispersed.
|
|
35
|
+
zero_percent_threshold: Percentage of zeros in a numeric column
|
|
36
|
+
that triggers a "consider binary flag" suggestion.
|
|
37
|
+
negative_percent_threshold: Similar for negative values.
|
|
38
|
+
outlier_method: Method used for outlier detection.
|
|
39
|
+
'iqr': Interquartile Range (robust).
|
|
40
|
+
'zscore': Z‑score (sensitive to skew, generally discouraged).
|
|
41
|
+
iqr_multiplier: Multiplier for IQR bounds (default 1.5).
|
|
42
|
+
zscore_threshold: Threshold for Z‑score outlier detection.
|
|
43
|
+
constant_variance_threshold: Variance below this value is
|
|
44
|
+
considered constant/quasi‑constant.
|
|
45
|
+
enable_feature_engineering: If True, the recommendation engine
|
|
46
|
+
may suggest feature engineering techniques (ratios, interactions,
|
|
47
|
+
etc.). They are always based on statistical evidence, never on
|
|
48
|
+
column names.
|
|
49
|
+
max_plot_cols: Maximum number of individual feature plots to
|
|
50
|
+
generate in one go (avoid overwhelming the user).
|
|
51
|
+
plot_style: Seaborn style to use for all visualizations.
|
|
52
|
+
color_palette: Seaborn color palette.
|
|
53
|
+
figure_size: Default (width, height) for main figures.
|
|
54
|
+
random_state: Random seed for reproducibility in imputation,
|
|
55
|
+
encoding, etc.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
# ----------------------------------------------------------------
|
|
59
|
+
# Missingness & Data Quality
|
|
60
|
+
# ----------------------------------------------------------------
|
|
61
|
+
missing_threshold: float = 0.4
|
|
62
|
+
high_cardinality_threshold: int = 50
|
|
63
|
+
max_unique_for_categorical_like: int = 15
|
|
64
|
+
|
|
65
|
+
# ----------------------------------------------------------------
|
|
66
|
+
# Correlation & Distribution
|
|
67
|
+
# ----------------------------------------------------------------
|
|
68
|
+
correlation_threshold: float = 0.9
|
|
69
|
+
skewness_threshold: float = 1.5
|
|
70
|
+
kurtosis_threshold: float = 4.0 # Not actively used
|
|
71
|
+
cv_threshold: float = 2.0
|
|
72
|
+
zero_percent_threshold: float = 50.0
|
|
73
|
+
negative_percent_threshold: float = 5.0
|
|
74
|
+
|
|
75
|
+
# ----------------------------------------------------------------
|
|
76
|
+
# Outlier Detection
|
|
77
|
+
# ----------------------------------------------------------------
|
|
78
|
+
outlier_method: Literal["iqr", "zscore"] = "iqr"
|
|
79
|
+
iqr_multiplier: float = 1.5
|
|
80
|
+
zscore_threshold: float = 3.0
|
|
81
|
+
|
|
82
|
+
# ----------------------------------------------------------------
|
|
83
|
+
# Variance & Constants
|
|
84
|
+
# ----------------------------------------------------------------
|
|
85
|
+
constant_variance_threshold: float = 1e-6
|
|
86
|
+
|
|
87
|
+
# ----------------------------------------------------------------
|
|
88
|
+
# Feature Engineering Toggle
|
|
89
|
+
# ----------------------------------------------------------------
|
|
90
|
+
enable_feature_engineering: bool = True
|
|
91
|
+
|
|
92
|
+
# ----------------------------------------------------------------
|
|
93
|
+
# Visualization
|
|
94
|
+
# ----------------------------------------------------------------
|
|
95
|
+
max_plot_cols: int = 20
|
|
96
|
+
plot_style: str = "whitegrid"
|
|
97
|
+
color_palette: str = "muted"
|
|
98
|
+
figure_size: tuple = (12, 6)
|
|
99
|
+
|
|
100
|
+
# ----------------------------------------------------------------
|
|
101
|
+
# Reproducibility
|
|
102
|
+
# ----------------------------------------------------------------
|
|
103
|
+
random_state: int = 42
|
|
104
|
+
|
|
105
|
+
# ----------------------------------------------------------------
|
|
106
|
+
# Additional settings may be added in the future.
|
|
107
|
+
# ----------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# ----------------------------------------------------------------------
|
|
111
|
+
# Default configuration instance
|
|
112
|
+
# ----------------------------------------------------------------------
|
|
113
|
+
# Users can import this singleton and modify attributes at runtime,
|
|
114
|
+
# or pass their own MLToolkitConfig instance to functions that accept one.
|
|
115
|
+
default_config = MLToolkitConfig()
|