EnYa32/AccidentRiskPredictor
0
๐ Road Accident Risk Predictor (LightGBM)
This Streamlit app predicts accident_risk (0โ1) using a trained LightGBM regression model.
What this app does
- Takes road & environment features (road type, lanes, curvature, speed limit, weather, lighting, etc.)
- Applies the same feature engineering used in training:
curvature_speedlanes_speedaccidents_laneholiday_schoolsigns_public- Encodes categorical variables with one-hot encoding (
pd.get_dummies(drop_first=True)) - Aligns final features using the saved list in feature_names.pkl
- Outputs a risk score between 0 and 1
Files you must have in the repo root
app.pylgbm_model.pkl(trained model)feature_names.pkl(list of training feature columns)requirements.txt
Run locally
pip install -r requirements.txt
streamlit run app.py
How to use
Manual input
Fill the form and click Predict.
CSV upload
Upload a CSV with the raw columns like Kaggle test.csv (without accident_risk).
The app returns a file with an additional column: accident_risk_pred.
Expected input columns (raw)
road_type (highway/urban/rural)
num_lanes
curvature
speed_limit
lighting (daylight/dim/night)
weather (clear/foggy/rainy)
road_signs_present (True/False or 0/1)
public_road (True/False or 0/1)
time_of_day (morning/afternoon/evening)
holiday (True/False or 0/1)
school_season (True/False or 0/1)
num_reported_accidents
Notes
Predictions are clipped to [0, 1] to match the target range.
For deployment, aligning columns via feature_names.pkl is critical to avoid feature mismatch.