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 …