saurabh0962's picture
Update README.md
5ed6c30 verified
|
Raw
History Blame Contribute Delete
7.94 kB
---
title: DCG Slag Viscosity Controller
emoji: 🏭
colorFrom: red
colorTo: indigo
sdk: gradio
app_file: app.py
pinned: true
short_description: "Real-time ML Viscosity & RPM Control for BF Slag DCG"
tags:
- track:backyard
- achievement:welltuned
- achievement:sharing
- achievement:fieldnotes
---
# 🏭 Real-Time Slag Viscosity Prediction for Dry Centrifugal Granulation (DCG)
**Mineral & Metallurgical Engineering Β· IIT (ISM) Dhanbad**
> A machine learning system that predicts blast furnace slag viscosity in real time
> and recommends disc RPM adjustments for Dry Centrifugal Granulation heat recovery.
> Built with 4 ML models, Bayesian hyperparameter tuning, SHAP explainability,
> PCA anomaly detection, and a Qwen2.5-7B LLM expert report panel.
---
## Hackathon Submission Links
- **Video Demo**: [https://youtu.be/s66GEb0iviw](https://youtu.be/s66GEb0iviw)
- **LinkedIn Post**: [https://www.linkedin.com/posts/saurabh-gupta0962_dcg-slag-viscosity-controller-a-hugging-share-7472381303036805120-M-gt](https://www.linkedin.com/posts/saurabh-gupta0962_dcg-slag-viscosity-controller-a-hugging-share-7472381303036805120-M-gt)
- **Hugging Face Space**: [https://huggingface.co/spaces/saurabh0962/dcg-slag-viscosity-controller](https://huggingface.co/spaces/saurabh0962/dcg-slag-viscosity-controller)
---
## Why This Problem Matters
In **Dry Centrifugal Granulation (DCG)**, molten blast furnace slag at 1450–1550 Β°C
is poured onto a spinning disc (1000–3000 RPM). The disc breaks the slag into fine
droplets for waste-heat recovery β€” but only if the slag viscosity is in a narrow window:
| Viscosity | What Happens | RPM Action |
|-----------|-------------|------------|
| < 0.055 PaΒ·s | Slag too fluid β†’ large irregular blobs | πŸ”΅ Reduce RPM |
| 0.055 – 0.080 PaΒ·s | βœ… Fine spherical granules β€” optimal heat transfer | 🟒 Maintain RPM |
| > 0.080 PaΒ·s | Slag too viscous β†’ fibres form, system clogs | πŸ”΄ Increase RPM |
Viscosity changes every tap depending on temperature and chemistry.
**No commercial real-time control system exists globally.**
This project solves that with a deployed ML demo.
---
## How It Works
### Input Features
| Feature | Range | Physical Meaning |
|---------|-------|-----------------|
| Temperature | 1400 – 1600 Β°C | Tap temperature |
| Basicity (CaO/SiOβ‚‚) | 0.8 – 1.4 | Higher = less viscous (CaO breaks Si–O network) |
| Alβ‚‚O₃ | 8 – 18 wt% | Network former β€” raises viscosity |
| MgO | 4 – 12 wt% | Network modifier β€” slightly reduces viscosity |
| Coke Rate | 450 – 550 kg/t | Proxy for furnace heat input |
| Tap Time | 0 – 90 min | Elapsed time since tap β€” slag cools over time |
| Optical Basicity Ξ› | 0.55 – 0.75 | Auto-computed from mole fractions (Duffy & Ingram 1976) |
Optical Basicity is derived from the slag composition:
```
Ξ› = X_CaO Γ— 1.00 + X_SiOβ‚‚ Γ— 0.48 + X_Alβ‚‚O₃ Γ— 0.60 + X_MgO Γ— 0.78
```
where X values are mole fractions. Higher Ξ› β†’ more basic β†’ lower viscosity.
### Viscosity Model (Data Generation)
Synthetic training data (5,000 points) is generated using the **Urbain model**:
```
Ξ· = A Β· exp(B / T_K)
```
where A and B are empirical functions of the slag oxide composition, with Β±5% Gaussian noise
to simulate real plant measurement variation.
---
## ML Pipeline
### Four Models Trained and Compared
| Model | Architecture | Expected CV RΒ² |
|-------|-------------|----------------|
| Random Forest | 300 trees, max_depth=15 | ~0.97 |
| XGBoost | 300 estimators, lr=0.05, depth=6 | ~0.97–0.98 |
| CatBoost | 500 iterations, lr=0.05, depth=6 | ~0.97–0.98 |
| Neural Network | 64β†’32β†’16, BatchNorm + Dropout | ~0.95–0.96 |
> *Note: Exact numbers depend on the random seed and training run.
> Run the notebook to see your actual results.*
### Bayesian Hyperparameter Tuning (Optuna)
The best model by test RΒ² is automatically selected and tuned with **50 Optuna trials**
(TPE sampler, minimising 5-fold CV RMSE). The tuned model is what drives all predictions
in the Gradio demo.
### SHAP Explainability
**SHAP (SHapley Additive exPlanations)** values are computed on the tuned model:
- Beeswarm plot β€” how each feature affects every prediction
- Bar chart β€” global average feature importance (embedded in the demo)
- Dependence plots β€” how the top 2 features relate to viscosity individually
The SHAP bar chart is saved as `plot_shap_bar.png` and displayed live in the app.
### PCA Anomaly Detector
A 5-component PCA is fitted on the training data. For each new input, the Mean
Squared Reconstruction Error (MSRE) is computed. If MSRE > training mean + 3Οƒ,
the input is flagged as **out-of-distribution** and a warning is shown β€” the
prediction is still made but marked as an extrapolation.
---
## Gradio Demo β€” How to Use
1. **Adjust the sliders** on the left panel to your current slag conditions.
Optical Basicity Ξ› is auto-computed from your inputs β€” the slider is display only.
2. **Click "Predict"** to get viscosity predictions from all four models instantly.
The Tuned Best Model drives the RPM recommendation.
3. **Check the Data Quality panel** β€” the PCA anomaly detector confirms whether
your inputs are within the model's training range.
4. **Click "Expert LLM Report"** to get a Qwen2.5-7B metallurgist explanation.
The LLM prompt includes your exact SHAP attribution values for this prediction,
not just generic feature importance. Requires `HF_TOKEN` secret to be set.
Falls back to a rule-based explanation if the API is unavailable.
---
## Repository Structure
```
β”œβ”€β”€ app.py ← Gradio demo (loads saved models, runs UI)
β”œβ”€β”€ requirements.txt ← Python dependencies for the HF Space
β”œβ”€β”€ README.md ← This file
β”œβ”€β”€ dcg_slag_viscosity_ml.py ← Training script (run on Colab)
β”œβ”€β”€ dcg_slag_viscosity_ml.ipynb ← Jupyter Notebook version for easy reading
β”‚
└── [Generated after running Colab β€” uploaded to HF Space separately]
β”œβ”€β”€ model_rf_reg.joblib
β”œβ”€β”€ model_xgb_reg.joblib
β”œβ”€β”€ model_cat_reg.joblib
β”œβ”€β”€ model_nn_reg.keras
β”œβ”€β”€ model_tuned_best.joblib ← or .keras if NN wins
β”œβ”€β”€ scaler.joblib
β”œβ”€β”€ label_encoder.joblib
β”œβ”€β”€ model_metadata.json
β”œβ”€β”€ pca_detector.joblib
β”œβ”€β”€ anomaly_config.json
└── plot_shap_bar.png
```
---
## Running the Training Notebook
1. Open `dcg_slag_viscosity_ml_final.py` in Google Colab as a notebook.
2. Change `SAVE_DIR = "./"` to `SAVE_DIR = "/content/"` (line ~85).
3. Set Runtime β†’ GPU (optional, speeds up Neural Network training).
4. Run All β€” takes approximately 20–30 minutes.
5. Download all `.joblib`, `.keras`, `.json` files and `plot_shap_bar.png`
from the `/content/` directory.
---
## References
1. **Xin et al. (2025)** β€” Bayesian-Optimized CatBoost + SHAP for BF slag viscosity.
Achieved RΒ²=0.9897, RMSE=1.0619, hit ratio 95.1%.
*Journal of Non-Crystalline Solids.*
https://doi.org/10.1007/s42243-025-01608-z
2. **Zhang et al. (2025)** β€” RF, GBRT, and ANN for BF slag performance prediction.
RΒ² consistently above 0.97 on the CaO–SiO₂–Alβ‚‚O₃–MgO system.
*Ironmaking & Steelmaking.*
https://doi.org/10.1177/03019233251353314
3. **Chen et al. (2026)** β€” Optical basicity as domain-knowledge feature for ML
viscosity prediction. Validation error reduced to 8–15%.
*International Journal of Minerals, Metallurgy and Materials.*
https://doi.org/10.1007/s12613-025-3189-4
4. **Shankar et al. (2020)** β€” PCA-KNN model for BF slag viscosity, 99% accuracy.
*JOM, 72, 3687–3696.*
https://doi.org/10.1007/s11837-020-04360-9
---
*Mineral & Metallurgical Engineering Β· IIT (ISM) Dhanbad*
*Presented as Innovation 1 in a proposed DCG heat-recovery control system*