serverlex 1.0.0__py3-none-any.whl
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.
- Clean.py +261 -0
- DataCheck.py +165 -0
- DriftDetector.py +90 -0
- EnsembleBuilder.py +78 -0
- Evaluation.py +191 -0
- Explainability.py +89 -0
- FeatureSelector.py +90 -0
- ModelDeployer.py +89 -0
- ModelHyperparameter.py +162 -0
- Pipeline.py +251 -0
- Visualization.py +362 -0
- serverlex/__init__.py +34 -0
- serverlex-1.0.0.dist-info/METADATA +208 -0
- serverlex-1.0.0.dist-info/RECORD +16 -0
- serverlex-1.0.0.dist-info/WHEEL +5 -0
- serverlex-1.0.0.dist-info/top_level.txt +12 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: serverlex
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: End-to-End Automated Data Cleaning, ML Preprocessing, Diagnostics, and Deployment Platform
|
|
5
|
+
Author: Serverlex Team
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: pandas>=2.0.0
|
|
13
|
+
Requires-Dist: numpy>=1.24.0
|
|
14
|
+
Requires-Dist: scipy>=1.10.0
|
|
15
|
+
Requires-Dist: matplotlib>=3.7.0
|
|
16
|
+
Requires-Dist: scikit-learn>=1.3.0
|
|
17
|
+
Requires-Dist: joblib>=1.3.0
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: classifier
|
|
20
|
+
Dynamic: description
|
|
21
|
+
Dynamic: description-content-type
|
|
22
|
+
Dynamic: requires-dist
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
25
|
+
|
|
26
|
+
# Serverlex ⚡
|
|
27
|
+
**The Production-Safe Machine Learning Preprocessing, Diagnostics, & Serving Platform**
|
|
28
|
+
|
|
29
|
+
[](https://www.python.org/)
|
|
30
|
+
[](https://pypi.org/)
|
|
31
|
+
[](https://opensource.org/licenses/MIT)
|
|
32
|
+
[](https://github.com/)
|
|
33
|
+
|
|
34
|
+
> 🚀 **Coming Soon to PyPI!** Serverlex is currently undergoing final release preparations and will soon be installable with a simple `pip install serverlex`. Star this repository to get notified when the initial PyPI package is published!
|
|
35
|
+
|
|
36
|
+
**Serverlex** is an end-to-end Python library that takes raw, dirty data and transforms it into model-ready features, baseline benchmarks, tuned algorithms, and live production endpoints—all without data leakage or boilerplate code.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📦 Installation
|
|
41
|
+
|
|
42
|
+
### Coming Soon via PyPI:
|
|
43
|
+
```bash
|
|
44
|
+
pip install serverlex
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Current Installation (From GitHub / Source):
|
|
48
|
+
```bash
|
|
49
|
+
# Direct from GitHub:
|
|
50
|
+
pip install git+https://github.com/Uwais-ML/Serverlex.git
|
|
51
|
+
|
|
52
|
+
# Or install locally in editable mode:
|
|
53
|
+
git clone https://github.com/Uwais-ML/Serverlex.git
|
|
54
|
+
cd Serverlex
|
|
55
|
+
pip install -e .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 🏗️ Architecture
|
|
61
|
+
|
|
62
|
+
```mermaid
|
|
63
|
+
flowchart TD
|
|
64
|
+
subgraph 1. Ingestion & Quality
|
|
65
|
+
A["Raw CSV / JSON"] --> B["DataCheck (DataGuard)"]
|
|
66
|
+
B --> C["Clean (Sanitation Engine)"]
|
|
67
|
+
C <--> D["Visualization (Live EDA)"]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
subgraph 2. Preprocessing & Selection
|
|
71
|
+
C --> E["MLPipeline (fit/transform)"]
|
|
72
|
+
E --> F["FeatureSelector (Mutual Info)"]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
subgraph 3. Modeling & Optimization
|
|
76
|
+
F --> G["Baseline Evaluator (.add_model)"]
|
|
77
|
+
G --> H["ModelHyperparameter (Nested CV)"]
|
|
78
|
+
G --> I["EnsembleBuilder (Stacking/Voting)"]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
subgraph 4. Diagnostics & Deployment
|
|
82
|
+
H & I --> J["Evaluation (ModelEvaluator)"]
|
|
83
|
+
H & I --> K["Explainability (ModelExplainer)"]
|
|
84
|
+
E & H --> L["ModelDeployer (Joblib Bundle)"]
|
|
85
|
+
L --> M["Live Raw Inference (1-line predict)"]
|
|
86
|
+
L --> N["DriftDetector (Production Shift Alert)"]
|
|
87
|
+
end
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## ⚡ 60-Second Quickstart
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import pandas as pd
|
|
96
|
+
from serverlex import (
|
|
97
|
+
DataGuard,
|
|
98
|
+
MLPipeline,
|
|
99
|
+
ModelHyperparameter,
|
|
100
|
+
ModelExplainer,
|
|
101
|
+
ModelDeployer
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# 1. Load Raw Messy Data
|
|
105
|
+
df = pd.read_csv("customers.csv")
|
|
106
|
+
|
|
107
|
+
# 2. Automated Quality Audit (catches ID columns, target leakage, class imbalance)
|
|
108
|
+
guard = DataGuard(df)
|
|
109
|
+
guard.run_audit(target="churn")
|
|
110
|
+
|
|
111
|
+
# 3. Fit Pipeline on Training Data (Zero Data Leakage)
|
|
112
|
+
train_df = df.iloc[:800].copy()
|
|
113
|
+
test_df = df.iloc[800:].copy()
|
|
114
|
+
|
|
115
|
+
pipeline = MLPipeline()
|
|
116
|
+
pipeline.fit(
|
|
117
|
+
train_df,
|
|
118
|
+
target="churn",
|
|
119
|
+
encode="onehot",
|
|
120
|
+
scale="standard",
|
|
121
|
+
data_time=["signup_date", "%Y-%m-%d"],
|
|
122
|
+
numeric_string_cols=["monthly_bill"]
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
X_train, y_train = pipeline.transform(train_df)
|
|
126
|
+
X_test, y_test = pipeline.transform(test_df)
|
|
127
|
+
|
|
128
|
+
# 4. Benchmark Baseline Models (+ add custom ones)
|
|
129
|
+
pipeline.evaluate_baseline_models(X_train, y_train, cv=5)
|
|
130
|
+
|
|
131
|
+
# 5. Tune Best Model with Unbiased Nested Cross-Validation
|
|
132
|
+
from sklearn.ensemble import RandomForestClassifier
|
|
133
|
+
tuner = ModelHyperparameter()
|
|
134
|
+
param_grid = tuner.get_default_param_grid("random_forest")
|
|
135
|
+
|
|
136
|
+
tune_res = tuner.tune_nested_cv(
|
|
137
|
+
estimator=RandomForestClassifier(random_state=42),
|
|
138
|
+
param_grid=param_grid,
|
|
139
|
+
X=X_train,
|
|
140
|
+
y=y_train,
|
|
141
|
+
outer_cv=5,
|
|
142
|
+
inner_cv=3
|
|
143
|
+
)
|
|
144
|
+
best_model = tune_res["best_estimator"]
|
|
145
|
+
|
|
146
|
+
# 6. Model Explainability
|
|
147
|
+
explainer = ModelExplainer(best_model, X_train.columns)
|
|
148
|
+
print(explainer.get_feature_importances().head(5))
|
|
149
|
+
|
|
150
|
+
# 7. Bundle & Deploy for Production Serving
|
|
151
|
+
deployer = ModelDeployer(pipeline=pipeline, model=best_model)
|
|
152
|
+
deployer.save("churn_deployer.joblib")
|
|
153
|
+
|
|
154
|
+
# Later in production: Predict directly on raw incoming JSON / dict!
|
|
155
|
+
loaded_deployer = ModelDeployer.load("churn_deployer.joblib")
|
|
156
|
+
raw_input = {"signup_date": "2026-04-01", "monthly_bill": "$89.50", "device": "laptop"}
|
|
157
|
+
print("Predicted Churn:", loaded_deployer.predict(raw_input)[0])
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 📦 Core Module Reference
|
|
163
|
+
|
|
164
|
+
| Module | Core Class | Primary Purpose |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| [`Clean.py`](Clean.py) | `Clean` | Headers, deduplication, IQR/Z-score outlier capping, format parsing. |
|
|
167
|
+
| [`DataCheck.py`](DataCheck.py) | `DataGuard` | Pre-training safety audit (ID detection, target leakage, class imbalance). |
|
|
168
|
+
| [`Visualization.py`](Visualization.py) | `Visualize` | EDA plots (missing, distribution, box, correlation) and real-time `plt.ion()`. |
|
|
169
|
+
| [`Pipeline.py`](Pipeline.py) | `MLPipeline` | Leakage-free `fit`/`transform`, datetime extraction, encoding, scaling. |
|
|
170
|
+
| [`FeatureSelector.py`](FeatureSelector.py) | `FeatureSelector` | Mutual Information ranking, collinearity pruning, variance threshold. |
|
|
171
|
+
| [`ModelHyperparameter.py`](ModelHyperparameter.py) | `ModelHyperparameter` | Non-nested `GridSearchCV` and unbiased Nested Cross-Validation. |
|
|
172
|
+
| [`EnsembleBuilder.py`](EnsembleBuilder.py) | `EnsembleBuilder` | Soft/Hard Voting and Stacking ensembles with meta-learners. |
|
|
173
|
+
| [`Evaluation.py`](Evaluation.py) | `ModelEvaluator` | Confusion matrix, ROC-AUC, PR curves, and regression residuals. |
|
|
174
|
+
| [`Explainability.py`](Explainability.py) | `ModelExplainer` | Native tree feature importances & permutation importance. |
|
|
175
|
+
| [`ModelDeployer.py`](ModelDeployer.py) | `ModelDeployer` | Pipeline-model artifact bundling and 1-line prediction on raw data. |
|
|
176
|
+
| [`DriftDetector.py`](DriftDetector.py) | `DriftDetector` | Kolmogorov-Smirnov (numbers) and Chi-Square (categories) drift tests. |
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 🏆 Real-World Kaggle Benchmarks
|
|
181
|
+
|
|
182
|
+
Serverlex was verified on real-world Kaggle datasets without custom code changes:
|
|
183
|
+
|
|
184
|
+
- **Customer Churn (`muhammadshahidazeem/customer-churn-dataset`)**:
|
|
185
|
+
- `DataGuard` detected `CustomerID` as 100% unique ID and recommended removal.
|
|
186
|
+
- Baseline Gradient Boosting achieved **99.42% accuracy**.
|
|
187
|
+
- `ModelExplainer` identified `support_calls` (0.277) and `total_spend` (0.235) as top drivers.
|
|
188
|
+
|
|
189
|
+
- **Walmart Sales (`mikhail1681/walmart-sales`)**:
|
|
190
|
+
- Extracted cyclical features from date strings (`year`, `month`, `day`, `dayofweek`).
|
|
191
|
+
- Auto-detected regression and trained Random Forest Regressor to **$R^2 = 0.9455$** ($\text{RMSE} = 133,727$).
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 🛠️ Installation
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Clone and install in editable development mode:
|
|
199
|
+
git clone https://github.com/your-username/Serverlex.git
|
|
200
|
+
cd Serverlex
|
|
201
|
+
pip install -e .
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 📖 In-Depth Manual
|
|
207
|
+
|
|
208
|
+
For mathematical concepts, parameter references, and output walkthroughs for every module, see **[`DOCUMENTATION.md`](DOCUMENTATION.md)**.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Clean.py,sha256=5zfAWw2yr5Sk6vDW6OkgjavXQ400OD3xDAqwiRFo5pQ,10903
|
|
2
|
+
DataCheck.py,sha256=zIhMJJ-4DJ1itVzImpgU0AqOFVf3G3DAv9Fg-i3cYkY,6812
|
|
3
|
+
DriftDetector.py,sha256=DQjls7PA-6I8NF7GmA7FtdZxVZxDrrbvhJPMqJFz38k,4096
|
|
4
|
+
EnsembleBuilder.py,sha256=xzyoSeZpoJimCypkwD87MtiBFHQrWrJpv0Tq6cq7bVk,3795
|
|
5
|
+
Evaluation.py,sha256=0xL5csIl5W6vldHGR8zmQrvWKRN8UA7QGJcMzdF2MDc,7916
|
|
6
|
+
Explainability.py,sha256=5JyuKyFIZ3LHBIkKCUc-QcX_z_fIWpcyjy2uHAUyJOs,3713
|
|
7
|
+
FeatureSelector.py,sha256=yuFYuDZxkFBLtnzirBCo7D8yAydXHMaDfVfFhGPvI5M,3457
|
|
8
|
+
ModelDeployer.py,sha256=fceoFaBLGGVpPw53qhGgAAjfX3rJaV-k2DHaNlHrpfE,3005
|
|
9
|
+
ModelHyperparameter.py,sha256=Sp0_Q7fX87BKrvOFkBKmbPIz4jk_CdbHv1PboIa3_5c,6532
|
|
10
|
+
Pipeline.py,sha256=6obzE0ncf9qbgZFHbOFfmV99pTCfE7FCvVu_mY9lOCw,11259
|
|
11
|
+
Visualization.py,sha256=NNF2WxxaQJIJ9pXjn_JTKZTny_3P53M8xTxkJITyJT4,14414
|
|
12
|
+
serverlex/__init__.py,sha256=YhkMrCOndbj46vkBbn8eVfNqnbcnvQ9_sHKA8jZ488c,850
|
|
13
|
+
serverlex-1.0.0.dist-info/METADATA,sha256=B9WgIq3t6m_QFrRyJ6Eipfu3aDqEUDmr2Jbbii9xeTE,7534
|
|
14
|
+
serverlex-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
15
|
+
serverlex-1.0.0.dist-info/top_level.txt,sha256=i8s-BiD6pMXiBHhA--W7sgrsdPlU71WWv5U7MR7SAUw,155
|
|
16
|
+
serverlex-1.0.0.dist-info/RECORD,,
|