Back

AquaSense AI

Forecasts pollutant levels 30 minutes ahead and flags breach risk before it happens.

Wastewater compliance forecasting · Hackathon team project · Finalist, Unihack × BCU Innovation Fest 2026

Open live site ↗ Source ↗
AquaSense AI interface

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.

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

  1. Sensor stream 8,640 simulated 5-minute readings replayed live 01
  2. Feature pipeline Lag and rolling features over a 120-minute buffer 02
  3. Forecasts RandomForest, XGBoost and ExtraTrees, 30 minutes ahead 03
  4. Breach risk HistGradientBoosting classifier 04
  5. Compliance rules Consent limits decide the current breach status 05
  6. Dashboard Next.js, Recharts and Leaflet, alerts in SQLite 06

Measured

Breach classifier ROC-AUC, validation 0.986
Ammonia forecast MAE against a persistence baseline, test 2.30 vs 3.18
Soft-sensor R² against lab values, COD / BOD / TSS 0.91 / 0.88 / 0.97

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

A chronological train, validation and test split, with imputation fitted on training data only, so nothing from the future leaks into the model.
Walk-forward validation across four folds, alongside an incident holdout.
Rules decide whether a reading is a breach; the model's job is to predict the risk ahead of time.

Built with

Next.jsExpressFastAPIscikit-learnXGBoostSQLiteRecharts

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.