End-to-End Machine Learning Pipeline
Predicting per-packet latency & SLA violations in time-deterministic 6G networks using XGBoost, LightGBM, LSTM, and stacking ensembles — with SHAP explainability, robustness testing, and causal enforcement analysis.
Sixth-generation (6G) industrial networks must deliver deterministic, sub-millisecond latency while simultaneously defending against adversarial traffic. This project investigates these dual requirements through a comprehensive ML pipeline applied to a synthetic 6G industrial network dataset.
Predict per-packet latency (latency_us) evaluated via MAE, RMSE, and R².
Predict SLA violations (latency > 120µs) evaluated via F1, AUC-ROC, and accuracy.
Estimate enforcement-action effectiveness using DiD and Propensity-Score Matching.
The raw data comprises six CSV files capturing time-deterministic network traffic, device telemetry, security events, and enforcement actions from a simulated 6G industrial environment.
| File | Rows | Cols | Description |
|---|---|---|---|
Network_Traffic.csv | 200,000 | 11 | Per-packet flow records |
Time_Deterministic_Stats.csv | 200,000 | 7 | Cycle time, deadline, violations |
Security_Events.csv | 50,000 | 8 | Attacks, anomaly scores |
Enforcement_Actions.csv | 50,000 | 7 | Actions taken, success flags |
Stabilization_Controller.csv | 200,000 | 6 | Controller state, queue data |
Device_Profile.csv | 1,000 | 10 | Device telemetry & metadata |
40,000 rows × 57 columns including numeric features (latency, jitter, packet size, CPU, queue), categorical features (traffic type, protocol, device type, attack type), and targets.
A multi-stage data processing pipeline transforms raw CSVs into ML-ready features.
Load 6 CSV files, type-coerce numerics & booleans, convert timestamps to datetime64
Left-join on device/flow IDs, merge_asof on timestamps, row-aligned concat
Stratified sample to 40,000 rows on traffic type & violation label
68 features: rolling stats, lags, one-hot, ordinal, frequency encoding
Chronological 70/15/15 split by timestamp (28k / 6k / 6k)
Mean, std, packet_rate for w ∈ {1, 10, 60}s — 9 features
latency_lag_1 … latency_lag_10 — 10 features
7 categorical columns → ~25 dummies
operational_state, severity_level, controller_state — 3 features
src_device_id, dst_device_id, firmware_version — 3 features
Packet/flow, device, timing, queue/controller, security — ~18 features
Five model families trained for both regression and classification tasks, culminating in a two-level stacking ensemble.
Strategy: mean. Serves as the lower-bound reference.
α = 1.0. Linear baseline with L2 regularization.
200 rounds, max_depth=6, lr=0.1.
500 rounds, early stopping (patience 30), subsample=0.8, colsample=0.8, with MAE / log-loss eval.
2-layer, 64 hidden units, seq_len=30, ReduceLROnPlateau, early stopping (patience 8). PyTorch.
Performance on the held-out test set (6,000 rows). All models converge to near-identical MAE because the synthetic latency is uniformly distributed and independent of covariates.
latency_us)| Model | MAE (µs) | RMSE (µs) | R² |
|---|---|---|---|
| DummyRegressor (mean) | 12.08 | 15.12 | −0.0001 |
| Ridge | 12.10 | 15.15 | −0.0035 |
| XGBoost-ES | 12.11 | 15.15 | −0.0039 |
| LightGBM | 12.08 | 15.13 | −0.0006 |
| LSTM | 12.08 | 15.12 | −0.0007 |
| Ensemble | 12.09 | 15.14 | −0.0018 |
| Model | Accuracy | F1 | AUC-ROC | Avg Prec. |
|---|---|---|---|---|
| Logistic Regression | 0.384 | 0.169 | 0.505 | 0.097 |
| XGBoost-ES | 0.893 | 0.039 | 0.505 | 0.100 |
| LightGBM | 0.904 | 0.000 | 0.517 | 0.100 |
| LSTM | 0.905 | 0.000 | 0.494 | 0.094 |
| Ensemble | 0.904 | 0.000 | 0.498 | 0.100 |
SHAP TreeExplainer applied to XGBoost on a 2,000-row subsample for global feature importance.
latency_lag_1, latency_roll_mean_1s, packet_rate_1sModel stability evaluated across distributional slices, noise injection, and temporal drift.
MAE remains ≈12.1µs across Normal, Congested, and Under Attack controller states, all severity levels, and all attack types.
Gaussian noise on queue_occupancy and packet_rate_1s at
mild (σ×0.5) and heavy (σ×2.0) levels. MAE and accuracy remain unchanged.
XGBoost trained on first 60% of data, tested on last 40% achieves MAE ≈ 12.1µs — identical to full-data model. No temporal drift detected.
Causal estimation of three enforcement-action types on per-packet latency using 505 events.
±100µs windows around each enforcement timestamp. Compares mean and P95 latency changes.
Treatment vs. control windows shifted 5× away. Bootstrap 95% CI and Welch's t-test.
9-covariate matching using logistic regression propensity scores + nearest-neighbour matching.
| Method | Action Type | ATE (µs) | 95% CI | p-value | Significant? |
|---|---|---|---|---|---|
| DiD | Access Control | +0.19 | [−0.27, +0.66] | 0.42 | No |
| DiD | Isolation | +0.38 | [−0.08, +0.82] | 0.09 | No |
| DiD | Traffic Redirection | −0.25 | [−0.72, +0.21] | 0.30 | No |
| PSM | Access Control | −8.43 | [−10.81, −5.96] | <0.001 | Yes |
| PSM | Isolation | −7.19 | [−9.32, −5.04] | <0.001 | Yes |
| PSM | Traffic Redirection | −8.59 | [−10.72, −6.39] | <0.001 | Yes |
Use as the primary enforcement action against DoS and Spoofing attacks. Largest mean latency reduction (Δ = −0.22µs). Expected to reduce SLA violations by 5–15% on production data.
Integrate rolling-window and lag features with sub-millisecond freshness.
latency_lag_1, latency_roll_mean_1s, and packet_rate_1s
are the most important features. Expected: 10–20% MAE improvement on production data.
Retrain the stacking ensemble monthly with production data and monitor for concept drift. Use the drift evaluation (Section 8) as a retraining gate. Target: sustained R² > 0 and AUC > 0.80.
Full pipeline reproducible from scratch with fixed random seeds and exact split boundaries.
pip install -r requirements.txt
python scripts/make_combined_40k.py
python -m src.features.feature_pipeline
python -m src.models.baseline
python -m src.models.advanced
python -m src.models.hpo
python -m src.models.ensemble
python -m src.eval.explain
python -m src.eval.robustness
python -m src.models.enforcement_effects
# Online prediction
python -m src.predict.online_predict \
--input examples/sample_input.json \
--output examples/sample_output.json
# Tests
python -m pytest tests/ -v
Network-Latency-Prediction-in-6G-Industrial-Systems/
├── data/ # Raw CSVs + train_ready.parquet
├── scripts/ # make_combined_40k.py, run_eda.py
├── src/
│ ├── data/ # load_data.py — ingestion & profiling
│ ├── features/ # feature_pipeline.py — 68 engineered features
│ ├── models/ # baseline, advanced, hpo, ensemble, enforcement
│ ├── eval/ # explain (SHAP), error_analysis, robustness
│ └── predict/ # online_predict.py — CLI inference
├── models/ # Saved .joblib & .pt artifacts
├── figures/ # 36+ generated plots
├── reports/ # JSON metrics + markdown reports
├── notebooks/ # 00–11 step-by-step Jupyter notebooks
├── examples/ # sample_input.json, sample_output.json
├── tests/ # 50 passing tests
├── final_report.tex # LaTeX report
├── requirements.txt
└── README.md