AquaSense AI
Forecasts pollutant levels 30 minutes ahead and flags breach risk before it happens.
What it's for
A food-processing plant discharges wastewater under a permit. The operator needs to know, before it happens, whether the next few hours will breach a limit.
- Forecasts pollutant levels 30 minutes ahead and flags breach risk before the reading arrives.
- Soft sensors estimate COD, BOD and TSS from cheap live probes instead of waiting for a lab result.
- Every number on the dashboard is traceable to a reading, and the data is simulated, which the page says.
What it is
A compliance monitor for a food-processing plant's wastewater. It replays 5-minute sensor readings as a live stream, forecasts COD, BOD, TSS, ammonia and pH 30 minutes ahead, predicts breach risk, and turns the result into alerts, reports, drought context and data-quality views.
How it works
- Sensor stream 8,640 simulated 5-minute readings replayed live
- Feature pipeline Lag and rolling features over a 120-minute buffer
- Forecasts RandomForest, XGBoost and ExtraTrees, 30 minutes ahead
- Breach risk HistGradientBoosting classifier
- Compliance rules Consent limits decide the current breach status
- Dashboard Next.js, Recharts and Leaflet, alerts in SQLite
Measured
Built on simulated plant data. The validation set holds 12 breach windows and the test split holds none, so the classifier scores are an early signal rather than a field result.
Engineering decisions
Built with
Case study
A plant discharging wastewater has consent limits it must stay under. The usual way it learns it went over one is a lab result, days later, when the water is long gone and the penalty is already earned.
Half an hour of warning changes what an operator can do about it. That’s the whole product.
On authorship. This was a team build: the repository has four contributors and the work started as a hackathon project. Everything described below is what the code does, not a claim about who wrote which part, and the project is listed on this site as a team project for that reason.
What the plant sends
Five-minute readings: pH, COD, BOD, TSS, ammonia, temperature, flow. The demo replays 8,640 of them as a live stream, so the dashboard behaves like a plant running now rather than a chart of last month.
From those, lag and rolling features over a two-hour window feed two different jobs:
- Forecasters, one per indicator, each chosen by what actually won on validation: Random Forest for COD and BOD, XGBoost for TSS, Extra Trees for ammonia and pH.
- A breach-risk classifier, gradient boosting, answering a different question: not “what will the number be” but “how likely is a breach in this window”.
Why the rules stay rules
The model is never allowed to declare a breach. Current compliance status is decided by comparing readings against the consent limits, full stop.
That split matters more than any accuracy figure. A breach is a regulatory fact: it has to be traceable to a reading and a limit, not to a model’s opinion. Prediction is confined to the part where being early is the entire value, and where being wrong costs an operator a wasted check rather than a false compliance record.
The part that’s easy to fake
Time series makes cheating effortless. Shuffle the rows, fill gaps using statistics from the whole dataset, and you get beautiful numbers that would evaporate in production.
So: train, validation and test split strictly in time order (6,022 / 1,291 / 1,291 readings), imputation fitted on training data only, audit fields kept out of the features, and four rolling walk-forward folds instead of one lucky split.
What the numbers say
On validation the breach classifier reaches 0.917 precision and 0.917 recall, PR-AUC 0.914, ROC-AUC 0.986, at about 0.22 false alarms a day. One breach was flagged 25 minutes before it happened.
The forecasters beat a persistence baseline, which is the only comparison worth making over a 30-minute horizon: ammonia at 2.30 MAE against persistence at 3.18, R² 0.706. The soft sensors track lab values at R² 0.91 (COD), 0.88 (BOD) and 0.97 (TSS).
What I’d need before trusting it
The data is simulated. The validation window holds 12 breaches, so those precision and recall figures rest on a handful of events, and the test split contains no breaches at all. Walk-forward also showed the model ranking shifting between folds, exactly what you’d expect at this sample size.
The pipeline, the leakage discipline and the alerting transfer to a real plant. The scores don’t, until they’ve met one.