A controlled water hammer, 17 features and four machine-learning models turn 30 seconds of pressure into an explainable verdict: bypass or normal. Two programs make it possible — from the laboratory bench to the point on the street.
A clandestine bypass is an illegal branch installed downstream of the legal connection: the customer keeps registering consumption, the branch is buried or embedded, and its hydraulic signature is masked by regular demand. Andean utilities consistently report that conventional location technologies perform poorly against this kind of theft.
The principle fits in four steps — and in 8.86 milliseconds.
A PLC-commanded solenoid valve closes in ≈ 15 ms — well below 2L/a — generating a controlled water hammer.
ΔP = ρ · a · ΔVThe pressure front runs along the PVC SCH-40 pipe at the Korteweg–Joukowsky celerity.
a ≈ 677 m/sThe T-junction splits the hydraulic impedance into two parallel branches and reflects a negative rarefaction pulse.
r = (Zeq − Z)/(Zeq + Z) = −⅓The echo arrives at t = 2Lb/a. 17 features (time, frequency, db4 wavelet) are extracted and an ensemble returns the verdict.
RF + SVM + XGB + LGBMIllustrative model based on equations (1)–(6) of the study. Move the bypass: the echo shifts by exactly 2·Lb/a.
Bench with a 2 HP pump, Siemens S7-1200 PLC and solenoid valve. 1,200 labeled records at 5 distances.
→30 s window, 30,000 samples per record, 14-bit resolution.
→6-stage filtering, ×4–10 augmentation, 5-fold cross-validation, model ranking.
→Model + scaler + features + metrics in one file. NumPy-only converter for the edge.
→Arduino Q samples at 500 Hz, extracts the same 17 features and replies with a JSON verdict to the phone.
Over 10,000 lines of Python that carry the raw signal all the way to the exported model, without leaving a single window. Four tabs share one model object: what you train in one, you analyze in another.
Generates transients with the analytic p(t) model, visualizes Signal/PSD, 2D spectrogram and 3D surface, wavelet scalograms — and predicts instantly.
Neighbor anti-spike, Hampel, IQR envelope, duration filter, manual suppression and zero-phase Butterworth. All off by default: the operator decides.
Class-balanced datasets, grouped CSV ingestion, ×4–10 augmentation (noise, jitter, scaling) and a 75/25 split with Suggest hyperparameter buttons.
Random Forest, SVM-RBF, XGBoost and LightGBM under stratified 5-fold cross-validation. Multi-select: two loaded models become a voting ensemble.
Confusion matrix, feature importance, Leave-One-Out analysis, per-fold metrics, outlier detection and removal, automatic model ranking.
A single .joblib with model + scaler + feature list + metrics. The portable_v1 converter ships it as pure NumPy for the field device.
The lab, in a case. An Arduino Q of the Linux class runs the FastAPI backend, samples the line at 500 Hz and runs the same 17-feature extractor as the desktop: bit-exact compatibility between training and inference. The technician only needs a phone.
The Arduino Q runs a full Python stack on board: NumPy, SciPy, scikit-learn and PyWavelets. On-site inference, no cloud and no laptop.
The same pressure sensor as the lab, read through the on-board analog interface. The full window is stored and processed locally.
The extract_features routine is identical to the desktop's. Zero drift between what the model learned and what it sees in the field.
RF + SVM + XGB + LGBM with soft voting. If the models disagree, the result is “inconclusive” and a retest is suggested — fraud demands certainty.
On selecting a .joblib, /api/inspect_model instantly shows which models it contains. Big percentage, collapsible per-model detail, JSON verdict.
Relay, portable solenoid valve, buck converters and a battery with BMS in a sealed enclosure. It taps the line through a T and fires its own water hammer.
Results from the campaign reported in the study: 1,200 synthetic transients (75/25 split), reflection patterns measured on the Big Brother bench, and a 36-acquisition field pilot.
| Model | Accuracy | Precision | Recall | F1 |
|---|---|---|---|---|
| Random Forest | 0.971 | 0.965 | 0.978 | 0.971 |
| SVM (RBF) | 0.962 | 0.957 | 0.968 | 0.962 |
| Consensus | 0.967 | 0.973 | 0.971 | 0.965 |
The lab-trained model keeps 89 % accuracy when transferred to the Little Brother (36 acquisitions, 500 Hz, higher noise floor).
LAB → FIELD TRANSFERMeasured echo vs. Joukowsky-impedance theory for a bypass at 3 m. Relative amplitude 0.31 ± 0.04 against the predicted r = −1/3. The physics, confirmed.
n = 20 ACQUISITIONS · BIG BROTHERA 1-D CNN baseline reached 91.5 % — but demanded ~10× more data and non-interpretable decisions. In fraud cases, explainability wins: the RF + SVM consensus is the operational classifier.
VS DEEP LEARNINGTwo files, one methodology. Train with one, detect with the other.
Simulation, 6-stage filtering, synthetic and real training, 4 models with cross-validation, full analysis and .joblib export. Distributed as a Windows installer (.exe).
instalador.exeArduino App Lab project: assets, Python sketch, app.yaml and readme. Import it into the Arduino App Lab and flash it to the Arduino Q.
HydraDetectAI-LittleBrother-win64.zipTrouble downloading? Reach out — links are published with each release.