serverlex 1.2.2__tar.gz → 1.3.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.
Files changed (37) hide show
  1. {serverlex-1.2.2 → serverlex-1.3.0}/PKG-INFO +25 -16
  2. {serverlex-1.2.2 → serverlex-1.3.0}/README.md +24 -15
  3. {serverlex-1.2.2 → serverlex-1.3.0}/pyproject.toml +1 -1
  4. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/__init__.py +1 -1
  5. serverlex-1.3.0/serverlex/diagnostics/dataguard.py +565 -0
  6. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/diagnostics/drift.py +32 -1
  7. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/modeling/selector.py +68 -0
  8. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/preprocessing/clean.py +16 -0
  9. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/preprocessing/pipeline.py +132 -9
  10. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/serving/deployer.py +272 -4
  11. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex.egg-info/PKG-INFO +25 -16
  12. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex.egg-info/SOURCES.txt +1 -0
  13. {serverlex-1.2.2 → serverlex-1.3.0}/setup.py +1 -1
  14. {serverlex-1.2.2 → serverlex-1.3.0}/tests/test_audit_remediation.py +74 -0
  15. {serverlex-1.2.2 → serverlex-1.3.0}/tests/test_deployer.py +14 -0
  16. serverlex-1.3.0/tests/test_new_features.py +196 -0
  17. serverlex-1.2.2/serverlex/diagnostics/dataguard.py +0 -180
  18. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/diagnostics/__init__.py +0 -0
  19. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/diagnostics/evaluation.py +0 -0
  20. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/diagnostics/explainability.py +0 -0
  21. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/modeling/__init__.py +0 -0
  22. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/modeling/ensemble.py +0 -0
  23. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/modeling/hyperparameter.py +0 -0
  24. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/preprocessing/__init__.py +0 -0
  25. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/serving/__init__.py +0 -0
  26. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/visualization/__init__.py +0 -0
  27. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex/visualization/eda.py +0 -0
  28. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex.egg-info/dependency_links.txt +0 -0
  29. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex.egg-info/requires.txt +0 -0
  30. {serverlex-1.2.2 → serverlex-1.3.0}/serverlex.egg-info/top_level.txt +0 -0
  31. {serverlex-1.2.2 → serverlex-1.3.0}/setup.cfg +0 -0
  32. {serverlex-1.2.2 → serverlex-1.3.0}/tests/test_clean.py +0 -0
  33. {serverlex-1.2.2 → serverlex-1.3.0}/tests/test_dataguard.py +0 -0
  34. {serverlex-1.2.2 → serverlex-1.3.0}/tests/test_drift.py +0 -0
  35. {serverlex-1.2.2 → serverlex-1.3.0}/tests/test_leakage.py +0 -0
  36. {serverlex-1.2.2 → serverlex-1.3.0}/tests/test_parity.py +0 -0
  37. {serverlex-1.2.2 → serverlex-1.3.0}/tests/test_pipeline.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: serverlex
3
- Version: 1.2.2
3
+ Version: 1.3.0
4
4
  Summary: Production-Safe ML Preprocessing, Diagnostics, Tuning, and Serving Platform
5
5
  Author: Serverlex Team
6
6
  License: MIT
@@ -27,22 +27,24 @@ Dynamic: requires-python
27
27
 
28
28
  [![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue.svg)](https://www.python.org/)
29
29
  [![PyPI version](https://img.shields.io/pypi/v/serverlex.svg?color=blue)](https://pypi.org/project/serverlex/)
30
- [![Tests](https://img.shields.io/badge/tests-35%20passed-brightgreen.svg)](https://github.com/Uwais-ML/Serverlex/actions)
30
+ [![Tests](https://img.shields.io/badge/tests-47%20passed-brightgreen.svg)](https://github.com/Uwais-ML/Serverlex/actions)
31
31
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
32
32
  [![Code Style](https://img.shields.io/badge/code%20style-production%20safe-green.svg)](https://github.com/Uwais-ML/Serverlex)
33
33
 
34
- **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—with mathematical guarantees against data leakage, train/serve skew, and corrupted inference.
34
+ **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 — with leakage-safe preprocessing (pipeline params are fit on training data only and locked at inference), train/serve parity guarantees, and cryptographically signed model artifacts.
35
35
 
36
36
  ---
37
37
 
38
38
  ## 🚀 Key Highlights & Guarantees
39
39
 
40
- - **Zero Data Leakage**: Pipeline parameters (medians, modes, one-hot category vocabularies, scaler stats) are strictly computed on training splits and locked during inference.
41
- - **Exact Train/Serve Parity**: Predict on single records (`dict`), small micro-batches, or large DataFrames with exact prediction equivalence and zero categorical drift.
42
- - **Degenerate-Safe Outlier Cleaning**: Cell-wise IQR and Z-score handling protects binary flags, class targets, and degenerate discrete distributions from collapsing bounds.
40
+ - **Zero Data Leakage & Auto-Remediation**: Pipeline parameters are strictly computed on training splits. `auto_remediate=True` auto-drops ID columns, PII, and target proxies ($r \ge 0.90$).
41
+ - **Turnkey FastAPI & Docker Export**: `ModelDeployer.export_api()` generates a production REST microservice with Swagger docs, Pydantic validation, and a Dockerfile in 1 line.
42
+ - **Pre-Inference Latency & SLA Profiler**: `ModelDeployer.benchmark()` calculates p50, p95, p99 latency (ms) and throughput (req/s) before deployment.
43
+ - **Standalone HTML Audit Dashboards**: `DataGuard.to_html_report()` creates a self-contained, dark-mode report with dataset Health Scores (A+ to F).
44
+ - **Production Drift Webhook Alerts**: `DriftDetector.detect_drift(alert_webhook=...)` fires automated JSON alerts to Slack/PagerDuty when population shift exceeds thresholds.
45
+ - **Collinearity & Ratio Pruning**: `FeatureSelector.prune_collinear()` removes redundant collinear duplicates while preserving features with higher predictive power.
46
+ - **Exact Train/Serve Parity**: Predict on single records (`dict`), micro-batches, or DataFrames with exact prediction equivalence and zero categorical drift.
43
47
  - **Enterprise Serving Security**: Cryptographic SHA-256 sidecar verification and HMAC-SHA256 authenticity checks prevent untrusted model deserialization.
44
- - **Statistical Drift Monitoring**: Combines Kolmogorov-Smirnov, Chi-Square, Wasserstein distance, and finite-sample corrected Population Stability Index (PSI) to eliminate small-batch false alarms.
45
- - **High-Throughput Serving**: Sub-10ms p50 single-record inference latency ready for microservices and API gateways.
46
48
 
47
49
  ---
48
50
 
@@ -109,10 +111,17 @@ from serverlex import (
109
111
  df = pd.read_csv("customers.csv")
110
112
 
111
113
  # 2. Automated Quality Audit (catches ID columns, target leakage, class imbalance)
112
- guard = DataGuard(df)
113
- audit_report = guard.run_audit(target="churn")
114
+ guard = DataGuard(df, target="churn")
115
+ audit_report = guard.run_audit(leakage_threshold=0.90, id_threshold=0.95)
116
+
117
+ # Drop detected ID / PII columns before fitting — DataGuard advises, pipeline enforces.
118
+ # MLPipeline also auto-skips ID columns internally (drop_id_cols=True by default),
119
+ # but explicit dropping here keeps your training frame clean.
120
+ cols_to_drop = [c for c in guard.id_cols if c in df.columns]
121
+ if cols_to_drop:
122
+ df = df.drop(columns=cols_to_drop)
114
123
 
115
- # 3. Fit Pipeline on Training Data (Zero Data Leakage)
124
+ # 3. Fit Pipeline on Training Data (Leakage-Safe)
116
125
  train_df = df.iloc[:800].copy()
117
126
  test_df = df.iloc[800:].copy()
118
127
 
@@ -258,7 +267,7 @@ evaluator.plot_confusion_matrix(y_test, preds, save_path="confusion_matrix.png")
258
267
 
259
268
  ## 🧪 Testing & Verification
260
269
 
261
- Serverlex features a comprehensive automated test suite with **35 unit and regression tests** covering train/serve parity, outlier preservation, crypto authenticity, and drift edge cases:
270
+ Serverlex features a comprehensive automated test suite with **47 unit and regression tests** covering train/serve parity, outlier preservation, crypto authenticity, and drift edge cases:
262
271
 
263
272
  ```bash
264
273
  # Run the test suite:
@@ -272,17 +281,17 @@ python benchmarks/reproduce_benchmarks.py
272
281
 
273
282
  ---
274
283
 
275
- ## 🏆 Real-World Kaggle Verification
284
+ ## 🏆 Real-World Validation
276
285
 
277
286
  Serverlex has been validated on benchmark datasets:
278
287
 
279
288
  - **Customer Churn (`muhammadshahidazeem/customer-churn-dataset`)**:
280
- - `DataGuard` detected `CustomerID` as 100% unique identifier and pruned it.
289
+ - `DataGuard` correctly flagged `CustomerID` as a 100% unique identifier and excluded it from encoding.
281
290
  - Cell-wise outlier clipping preserved `churn` distribution with zero label alteration.
282
- - Baseline Gradient Boosting achieved **99.42% accuracy**.
291
+ - Cross-validated accuracy on clean data (no ID leakage): results vary by CV split and hyperparameters — benchmark on your own data.
283
292
  - **Walmart Store Sales (`mikhail1681/walmart-sales`)**:
284
293
  - Extracted temporal features from dates (`year`, `month`, `day`, `dayofweek`).
285
- - Random Forest Regressor trained to **$R^2 = 0.9455$** ($\text{RMSE} = 133,727$).
294
+ - Random Forest Regressor trained to **$R^2 = 0.9455$** ($\text{RMSE} = 133{,}727$).
286
295
 
287
296
  ---
288
297
 
@@ -3,22 +3,24 @@
3
3
 
4
4
  [![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue.svg)](https://www.python.org/)
5
5
  [![PyPI version](https://img.shields.io/pypi/v/serverlex.svg?color=blue)](https://pypi.org/project/serverlex/)
6
- [![Tests](https://img.shields.io/badge/tests-35%20passed-brightgreen.svg)](https://github.com/Uwais-ML/Serverlex/actions)
6
+ [![Tests](https://img.shields.io/badge/tests-47%20passed-brightgreen.svg)](https://github.com/Uwais-ML/Serverlex/actions)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
  [![Code Style](https://img.shields.io/badge/code%20style-production%20safe-green.svg)](https://github.com/Uwais-ML/Serverlex)
9
9
 
10
- **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—with mathematical guarantees against data leakage, train/serve skew, and corrupted inference.
10
+ **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 — with leakage-safe preprocessing (pipeline params are fit on training data only and locked at inference), train/serve parity guarantees, and cryptographically signed model artifacts.
11
11
 
12
12
  ---
13
13
 
14
14
  ## 🚀 Key Highlights & Guarantees
15
15
 
16
- - **Zero Data Leakage**: Pipeline parameters (medians, modes, one-hot category vocabularies, scaler stats) are strictly computed on training splits and locked during inference.
17
- - **Exact Train/Serve Parity**: Predict on single records (`dict`), small micro-batches, or large DataFrames with exact prediction equivalence and zero categorical drift.
18
- - **Degenerate-Safe Outlier Cleaning**: Cell-wise IQR and Z-score handling protects binary flags, class targets, and degenerate discrete distributions from collapsing bounds.
16
+ - **Zero Data Leakage & Auto-Remediation**: Pipeline parameters are strictly computed on training splits. `auto_remediate=True` auto-drops ID columns, PII, and target proxies ($r \ge 0.90$).
17
+ - **Turnkey FastAPI & Docker Export**: `ModelDeployer.export_api()` generates a production REST microservice with Swagger docs, Pydantic validation, and a Dockerfile in 1 line.
18
+ - **Pre-Inference Latency & SLA Profiler**: `ModelDeployer.benchmark()` calculates p50, p95, p99 latency (ms) and throughput (req/s) before deployment.
19
+ - **Standalone HTML Audit Dashboards**: `DataGuard.to_html_report()` creates a self-contained, dark-mode report with dataset Health Scores (A+ to F).
20
+ - **Production Drift Webhook Alerts**: `DriftDetector.detect_drift(alert_webhook=...)` fires automated JSON alerts to Slack/PagerDuty when population shift exceeds thresholds.
21
+ - **Collinearity & Ratio Pruning**: `FeatureSelector.prune_collinear()` removes redundant collinear duplicates while preserving features with higher predictive power.
22
+ - **Exact Train/Serve Parity**: Predict on single records (`dict`), micro-batches, or DataFrames with exact prediction equivalence and zero categorical drift.
19
23
  - **Enterprise Serving Security**: Cryptographic SHA-256 sidecar verification and HMAC-SHA256 authenticity checks prevent untrusted model deserialization.
20
- - **Statistical Drift Monitoring**: Combines Kolmogorov-Smirnov, Chi-Square, Wasserstein distance, and finite-sample corrected Population Stability Index (PSI) to eliminate small-batch false alarms.
21
- - **High-Throughput Serving**: Sub-10ms p50 single-record inference latency ready for microservices and API gateways.
22
24
 
23
25
  ---
24
26
 
@@ -85,10 +87,17 @@ from serverlex import (
85
87
  df = pd.read_csv("customers.csv")
86
88
 
87
89
  # 2. Automated Quality Audit (catches ID columns, target leakage, class imbalance)
88
- guard = DataGuard(df)
89
- audit_report = guard.run_audit(target="churn")
90
+ guard = DataGuard(df, target="churn")
91
+ audit_report = guard.run_audit(leakage_threshold=0.90, id_threshold=0.95)
92
+
93
+ # Drop detected ID / PII columns before fitting — DataGuard advises, pipeline enforces.
94
+ # MLPipeline also auto-skips ID columns internally (drop_id_cols=True by default),
95
+ # but explicit dropping here keeps your training frame clean.
96
+ cols_to_drop = [c for c in guard.id_cols if c in df.columns]
97
+ if cols_to_drop:
98
+ df = df.drop(columns=cols_to_drop)
90
99
 
91
- # 3. Fit Pipeline on Training Data (Zero Data Leakage)
100
+ # 3. Fit Pipeline on Training Data (Leakage-Safe)
92
101
  train_df = df.iloc[:800].copy()
93
102
  test_df = df.iloc[800:].copy()
94
103
 
@@ -234,7 +243,7 @@ evaluator.plot_confusion_matrix(y_test, preds, save_path="confusion_matrix.png")
234
243
 
235
244
  ## 🧪 Testing & Verification
236
245
 
237
- Serverlex features a comprehensive automated test suite with **35 unit and regression tests** covering train/serve parity, outlier preservation, crypto authenticity, and drift edge cases:
246
+ Serverlex features a comprehensive automated test suite with **47 unit and regression tests** covering train/serve parity, outlier preservation, crypto authenticity, and drift edge cases:
238
247
 
239
248
  ```bash
240
249
  # Run the test suite:
@@ -248,17 +257,17 @@ python benchmarks/reproduce_benchmarks.py
248
257
 
249
258
  ---
250
259
 
251
- ## 🏆 Real-World Kaggle Verification
260
+ ## 🏆 Real-World Validation
252
261
 
253
262
  Serverlex has been validated on benchmark datasets:
254
263
 
255
264
  - **Customer Churn (`muhammadshahidazeem/customer-churn-dataset`)**:
256
- - `DataGuard` detected `CustomerID` as 100% unique identifier and pruned it.
265
+ - `DataGuard` correctly flagged `CustomerID` as a 100% unique identifier and excluded it from encoding.
257
266
  - Cell-wise outlier clipping preserved `churn` distribution with zero label alteration.
258
- - Baseline Gradient Boosting achieved **99.42% accuracy**.
267
+ - Cross-validated accuracy on clean data (no ID leakage): results vary by CV split and hyperparameters — benchmark on your own data.
259
268
  - **Walmart Store Sales (`mikhail1681/walmart-sales`)**:
260
269
  - Extracted temporal features from dates (`year`, `month`, `day`, `dayofweek`).
261
- - Random Forest Regressor trained to **$R^2 = 0.9455$** ($\text{RMSE} = 133,727$).
270
+ - Random Forest Regressor trained to **$R^2 = 0.9455$** ($\text{RMSE} = 133{,}727$).
262
271
 
263
272
  ---
264
273
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "serverlex"
7
- version = "1.2.2"
7
+ version = "1.3.0"
8
8
  description = "Production-Safe ML Preprocessing, Diagnostics, Tuning, and Serving Platform"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Serverlex Team" }]
@@ -24,4 +24,4 @@ __all__ = [
24
24
  "ModelDeployer",
25
25
  ]
26
26
 
27
- __version__ = "1.2.2"
27
+ __version__ = "1.3.0"