Transforming Public Sanitation through Real-Time Monitoring & Digital Trust
This directory contains the complete AI model infrastructure for the Smart Toilet Hygiene Monitoring System, designed to restore public trust in toilets using IoT sensors, real-time hygiene scoring, and automated sanitation actions.
The IoT Hygiene Ecosystem is a smart sanitation solution targeting urban, rural, and institutional public toilets under India's Swachh Bharat Mission (SBM) framework.
📅 Target Deployment: July 2025
🎯 Theme: Smart Cities | IoT | AI | Public Health | Digital India
India has successfully built toilets, but people still don't trust them.
- ✅ 95%+ villages are ODF Plus certified
- ❌ Only 10% of users trust public toilet maintenance
- 🚫 68% of people avoid public toilets entirely
- 🧠 Root cause: Psychological Scarring due to bad odor, dirty floors, no water, and unsafe environments
Result: Infrastructure exists, but usage does not.
We convert a public toilet into a "Living Smart Unit" that:
- Detects hygiene issues before users arrive
- Automatically responds using IoT-driven actions
- Displays a real-time Hygiene Trust Score outside the toilet
- Rebuilds confidence through pre-entry validation
- Ammonia & odor detection
- Water and soap level tracking
- Touchless usage detection
- Live hygiene score display
- Last cleaned / disinfected time
- QR-based hygiene verification for users & tourists
- Auto exhaust & odor neutralization
- UV-C sterilization after usage
- Touchless flush and taps
- Panic/help button
- Slip detection (future scope)
- Women & elderly-friendly design
We conducted a 10-point questionnaire to identify real user pain points:
- Fear of bad smell & dirty floors
- Avoidance of water intake
- Surface-touch anxiety
- Willingness to pay for guaranteed hygiene
- Trust in digital hygiene scores
📌 Insight: Smell and first impression decide usage within 3 seconds
| Sensor | Purpose |
|---|---|
| MQ-135 / MQ-137 | Ammonia & odor detection |
| PIR Sensor | User presence detection |
| Ultrasonic Sensor | Water tank level |
| Flow Sensor | Water & soap usage |
| UV-C Module | Post-use sterilization |
- High-speed exhaust activation
- Ozone / odor neutralization
- UV sterilization after exit
- Alert generation for maintenance staff
- Solar-powered IoT
- LoRaWAN communication
- Low-internet dependency
- Premium "Loo-Café" hygiene model
- Pay-per-use with guaranteed cleanliness
- Soap-usage tracking
- Handwashing compliance monitoring
- Child-safe hygiene assurance
- Pre-Entry Hygiene Validation
- Psychological Barrier Reduction
- Global Hygiene QR for Tourists
- Behavior-first sanitation design
- Increased public toilet usage
- Reduced health risks & infections
- Higher citizen satisfaction scores
- Data-driven sanitation governance
- Alignment with Super Swachh League (2025) metrics
- AI-based hygiene prediction
- Computer vision for cleanliness detection
- Mobile app for hygiene navigation
- Government dashboard integration
- Predictive maintenance alerts
Public sanitation in 2025 requires more than infrastructure — it requires Digital Trust.
The IoT Hygiene Ecosystem bridges the gap between:
"There is a toilet" and
"I feel safe using this toilet."
ai_model/
├── data/ # Data storage and processing
│ ├── raw/ # Raw sensor data from IoT devices
│ ├── processed/ # Cleaned and preprocessed data
│ └── synthetic/ # Augmented and synthetic data
├── models/ # Trained ML models and artifacts
├── training/ # Model training infrastructure
│ ├── scripts/ # Training scripts and notebooks
│ └── logs/ # Training logs and metrics
├── testing/ # Testing and validation
│ ├── unit_tests/ # Unit tests for model components
│ └── integration_tests/ # End-to-end pipeline tests
├── evaluation/ # Model evaluation and performance metrics
├── utils/ # Utility functions and helpers
└── config/ # Configuration files and parameters
## Quick Start
### 1. Training the Model
```bash
cd training/scripts
python train_model.py
# Unit tests
cd testing/unit_tests
python test_model.py
# Integration tests
cd testing/integration_tests
python test_pipeline.py- Raw Data Collection: IoT sensors collect environmental data
- Data Processing: Clean and preprocess sensor readings
- Model Training: Train hygiene prediction models
- Model Testing: Validate model performance
- Deployment: Deploy trained models to production
humidity: Relative humidity percentage (0-100)temperature: Temperature in Celsius (15-35°C)ammonia_level: Ammonia concentration (ppm)co2_level: CO2 concentration (ppm)occupancy_duration: Average occupancy time (seconds)usage_count: Number of toilet usescleaning_frequency: Cleaning frequency per dayhygiene_score: Target variable (0-100)
Same as training features but without the target variable (hygiene_score).
The current implementation uses:
- Algorithm: Random Forest Regressor
- Features: 7 environmental and usage metrics
- Target: Hygiene score (0-100)
- Evaluation: MSE, R² Score
- MSE: Mean Squared Error
- R² Score: Coefficient of determination
- Feature Importance: Ranking of input features
sensor_readings.csv: Raw sensor data from IoT devicestraining_features.csv: Preprocessed training datatesting_features.csv: Preprocessed testing dataaugmented_data.csv: Synthetic and augmented training data
train_model.py: Main training script with model pipeline
test_model.py: Unit tests for model functionalitytest_pipeline.py: Integration tests for data pipeline
import joblib
import pandas as pd
# Load trained model
model = joblib.load('models/hygiene_predictor.pkl')
# Prepare input data
input_data = pd.DataFrame({
'humidity': [65.0],
'temperature': [22.0],
'ammonia_level': [0.8],
'co2_level': [450],
'occupancy_duration': [180],
'usage_count': [12],
'cleaning_frequency': [8]
})
# Make prediction
hygiene_score = model.predict(input_data)
print(f"Predicted hygiene score: {hygiene_score[0]:.1f}")import pandas as pd
def preprocess_sensor_data(raw_data):
"""Preprocess raw sensor data for model input"""
# Handle missing values
processed_data = raw_data.fillna(method='forward_fill')
# Normalize features if needed
# Add feature engineering logic here
return processed_dataModel configuration files are stored in the config/ directory:
- Model hyperparameters
- Feature engineering settings
- Evaluation metrics configuration
- Unit Tests: Test individual model components
- Integration Tests: Test complete data pipeline
- Performance Tests: Monitor model performance metrics
- Data Quality Tests: Validate input data integrity
- Deep learning models (LSTM, CNN)
- Real-time model updates
- Advanced feature engineering
- Model explainability tools
- Automated hyperparameter tuning
- Model versioning and A/B testing
- pandas
- numpy
- scikit-learn
- joblib
- pytest (for testing)
- Add new training data to
data/raw/ - Update preprocessing scripts in
training/scripts/ - Run tests to ensure model quality
- Update documentation and metrics
This AI model is part of the Smart Toilet Hygiene Monitoring System.