| --- |
| 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* |