XGBoost classifier that predicts laser weld quality outcomes from process parameters, with SHAP explainability to identify which parameter caused each defect. Built for laser welding cells where process engineers need fast, interpretable feedback when quality drops.
| Metric | Value |
|---|---|
| Test Accuracy | ~93% |
| Classes | 5 (Good / Spatter / Porosity / Undercut / Cold Weld) |
| Training set | 4,800 records (stratified 80/20 split) |
| Most important feature | Laser Power / Travel Speed ratio (energy density) |
| Inference time | < 5 ms per prediction |
| Capability | Detail |
|---|---|
| 5-class quality prediction | Good / Spatter / Porosity / Undercut / Cold_Weld |
| SHAP waterfall explanation | Shows which parameter pushed the prediction toward a defect |
| Process window map | Scatter of power vs speed coloured by quality — see the qualified window visually |
| Real-time parameter tuning | Slider-driven sidebar updates prediction instantly |
| Confidence scores | Per-class probability bar for uncertainty quantification |
| Class | Root cause |
|---|---|
| Good | Process parameters within the qualified window |
| Spatter | Excessive energy density — molten pool becomes unstable |
| Porosity | Focal offset error or insufficient shielding gas flow |
| Undercut | High power + high speed — groove forms at weld toes |
| Cold_Weld | Insufficient heat input — fusion incomplete |
| Parameter | Unit | Typical range |
|---|---|---|
| Laser Power | W | 800–5000 |
| Travel Speed | mm/s | 10–120 |
| Focal Offset | mm | −4 to +4 |
| Wire Feed Rate | mm/s | 20–90 |
| Shielding Gas Flow | L/min | 5–30 |
| Material Thickness | mm | 1.5 / 2.0 / 3.0 / 4.0 / 6.0 |
git clone https://github.com/Jimmply/weld-quality-classifier
cd weld-quality-classifier
pip install -r requirements.txt
# Generate training data
python scripts/generate_data.py
# Train model
python scripts/train.py
# Launch dashboard
streamlit run src/app.pyweld-quality-classifier/
├── .github/workflows/ci.yml # pytest + smoke test
├── config/settings.yaml # model hyperparameters and thresholds
├── scripts/
│ ├── generate_data.py # generate and save synthetic dataset
│ └── train.py # train, evaluate, save model
├── src/
│ ├── data_generator.py # physics-based rule engine → 6,000 labelled records
│ ├── classifier.py # XGBClassifier + SHAP TreeExplainer
│ └── app.py # Streamlit dashboard with live SHAP waterfall
├── tests/
│ └── test_generator.py
└── requirements.txt
Data generation — A physics-informed rule engine assigns defect labels based on normalised energy density (power/speed ratio), focal offset magnitude, and shielding gas flow. Rules are derived from published laser welding process windows for austenitic stainless steel and mild steel. 6,000 records across five material thickness bands.
Modeling — XGBoost with 400 estimators, learning rate 0.04, stratified 80/20 split. Test accuracy: ~93%.
Explainability — SHAP TreeExplainer computes per-prediction feature contributions. The waterfall chart in the dashboard answers the exact question a process engineer asks: "Why did this weld fail, and which knob do I turn?"
In a production laser welding cell, quality prediction from process parameters (rather than post-weld inspection) enables:
- In-process correction before a bad part reaches downstream assembly
- Root cause triage in seconds instead of hours of metallurgical analysis
- Process window documentation — the model's decision boundary becomes the qualified process window
Python · XGBoost · SHAP · Scikit-learn · Pandas · NumPy · Streamlit · Plotly · Matplotlib
MIT © Dmitri Shurkhai