Prediction of the functional status of water pumps in Tanzania β a Machine Learning project using Random Forest (DrivenData)
# π§ Water Pump Predictor - Tanzania
**Machine Learning app to predict the operational status of water pumps in Tanzania**, based on the DrivenData "Pump It Up" challenge.
---
## Project Overview / DescripciΓ³n del Proyecto
## π Project Overview
This app uses a trained `Random Forest` model to classify water pumps as:
- β
`functional`
- β οΈ `functional needs repair`
- β `non functional`
It features a full ML pipeline, from preprocessing to prediction, live evaluation and interactive dashboards.
---
## Final Score / Resultado Final
## π Try it Online
You can test the live app hosted on **Streamlit Cloud**:
---
## π§ Model & Techniques Used
- RandomForestClassifier (Scikit-learn)
- KNNImputer for missing values
- TargetEncoder for categorical variables
- LabelEncoder for final mapping
- Feature importance visualization
- Geo-mapping with Pydeck
---
## π§ App Functionalities
### π 1. Prediction Mode
- Upload a test dataset (`Testsetvalues.csv`)
- Predict status using the trained model
- Download enriched CSV with predictions
- Interactive prediction map
### π 2. Evaluation Mode
- Upload training and label datasets
- Shows classification report + confusion matrix
- Validates the model's performance on full data
### π 3. Interactive Dashboard
- Upload prediction results (`predictions_full.csv`)
- Filter by `region`, `status`, or `construction_year`
- Explore data visually + map filtered results
---
## ποΈ Project Structure
```
π water-pump-predictor/
βββ app_v4_final.py # Streamlit App (v4 with all features)
βββ model_rf.joblib # Trained RandomForest model
βββ target_encoder.joblib # Encoder for categorical vars
βββ knn_imputer.joblib # Fitted KNN imputer
βββ final_columns.joblib # Ordered feature columns
βββ Trainingsetvalues.csv # Training data
βββ Trainginsetlabels.csv # Labels for training data
βββ Testsetvalues.csv # Data to predict
βββ predictions_full.csv β¦