CoolFace
Apppublic

EnYa32/steel-plate-defect-prediction

sourceHugging Facemitupdated 9mo agoView on Hugging Face
0likes
App README

๐Ÿงฑ Steel Plate Defect Predictor (XGBoost)

This Streamlit app predicts the probability of 7 steel plate defect types:

  • โ€”Pastry
  • โ€”Z_Scratch
  • โ€”K_Scatch
  • โ€”Stains
  • โ€”Dirtiness
  • โ€”Bumps
  • โ€”Other_Faults

It uses 7 saved XGBoost models (one model per target) and outputs probabilities in the same spirit as the Kaggle submission format.


โœ… Files you must have in the same folder as app.py

Models (7 files):

  • โ€”xgb_Pastry.json
  • โ€”xgb_Z_Scratch.json
  • โ€”xgb_K_Scatch.json
  • โ€”xgb_Stains.json
  • โ€”xgb_Dirtiness.json
  • โ€”xgb_Bumps.json
  • โ€”xgb_Other_Faults.json

Metadata:

  • โ€”feature_names.pkl (list of feature columns in the exact training order)
  • โ€”target_names.pkl (optional but recommended; list of targets)
  • โ€”feature_engineering.json (optional; documentation only)

๐Ÿง  Feature Engineering inside the app (same as training)

The app recomputes these engineered features automatically:

  • โ€”area_perimeter_ratio = Pixels_Areas / (X_Perimeter + Y_Perimeter + 1)
  • โ€”luminosity_range = Maximum_of_Luminosity - Minimum_of_Luminosity

So your input CSV should contain the raw columns required to compute them (e.g. PixelsAreas, XPerimeter, YPerimeter, MaximumofLuminosity, Minimumof_Luminosity).


โ–ถ๏ธ Run locally

bash
pip install -r requirements.txt
streamlit run app.py
๐Ÿ“„ How to use
Option 1: Upload CSV
Upload a CSV containing the raw feature columns (and optionally an id column).
The app will:

compute engineered features

select/reorder features using feature_names.pkl

output probabilities for all 7 targets

allow you to download predictions.csv

Option 2: Single row (manual)
Enter values for the raw features and get a probability table + bar chart.

๐Ÿงช Test input example (quick CSV idea)
Create a small CSV with the same raw feature columns as your dataset (like test.csv).
If your file includes id, the app will keep it in the output.

๐Ÿ“Œ Notes
Probabilities are between 0 and 1.

The model expects the exact same feature order as training (feature_names.pkl ensures this).

If you change feature engineering in the notebook, you must update the Streamlit app accordingly.