WetNet helps Aigües de Barcelona (Barcelona Water Company) predict anomalous water consumption, using machine learning.
Project description
WetNet
WetNet helps Aigües de Barcelona (Barcelona Water Company) predict anomalous water consumption, using machine learning.
Setup
1. Install uv
Our project uses uv to manage dependencies in a reproducible way. See Installing uv documentation for installation instructions.
[!TIP] You can skip the rest of the setup if you just want to run the scripts and see the project in action! Run
uvx wet-net --helpto see the available commands in the CLI. This will install the latest release of the project from PyPI in an isolated virtual environment.
2. Clone the repository
git clone https://github.com/ZachParent/wet-net.git
cd wet-net
3. Install the project dependencies
uv sync --locked
Torch install hint (if not pulled via lockfile):
- CPU-only:
pip install torch torchvision torchaudio- CUDA 12.8 (recommended for GPUs):
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
HuggingFace token (only needed if you plan to push trained models)
- Copy
.env.exampleto.envand setHUGGINGFACE_TOKEN=<your_token>. If you already placed your token in.env, nothing else to do. - One-off export:
export HUGGINGFACE_TOKEN=hf_xxx. - CLI alternative:
huggingface-cli login(same token).
End-to-end train (full data) + push example:
# assuming data is preprocessed and CUDA available
uv run wet-net train --seq-len 96 --optimize-for recall
uv run python - <<'PY'
import os, torch
from huggingface_hub import HfApi, HfFolder
from wet_net.paths import RESULTS_DIR
run_dir = RESULTS_DIR / "wetnet" / "seq96_recall"
repo = os.environ.get("HF_REPO", "your-username/wetnet-seq96-recall")
api = HfApi()
api.create_repo(repo, exist_ok=True)
api.upload_file(path_or_fileobj=run_dir / "wetnet.pt", path_in_repo="wetnet.pt", repo_id=repo)
api.upload_file(path_or_fileobj=run_dir / "vib.pt", path_in_repo="vib.pt", repo_id=repo)
api.upload_file(path_or_fileobj=run_dir / "config.json", path_in_repo="config.json", repo_id=repo)
PY
Make sure HUGGINGFACE_TOKEN is set in your environment before running the upload step.
Usage
Run the scripts
The CLI entry points are unchanged, now targeting the WetNet tri-task pipeline (no grid search; cached best configs per sequence length):
# Generate data (real: pass your private URL; mock: bundled synthetic)
# Accepts a parquet URL or the official challenge zip URL
uv run wet-net pre-process --data-url https://<your-parquet-or-zip-url> # real
uv run wet-net pre-process --mock # synthetic
# Train (picks the best recall/false_alarm config for that seq_len)
uv run wet-net train --seq-len 192 --optimize-for recall
uv run wet-net train --seq-len 192 --optimize-for false_alarm --mock
# Optional: push trained artifacts to Hugging Face
uv run wet-net train --seq-len 96 --optimize-for recall --push-to-hub --hub-model-name WetNet/wet-net
# Optional: override hyperparameters by editing src/wet_net/config/best_configs.yaml
# (any fields you change there are picked up automatically at runtime)
# Evaluate saved checkpoints (no retraining)
uv run wet-net evaluate --seq-len 192 --optimize-for recall
The code for the scripts can be found in the src/wet_net/scripts directory.
Tri-Task WetNet
- Model: Cyclic-UniTS backbone + 4 heads (reconstruction, 24h forecast, short/long anomaly logits), class
wet_net.models.wetnet.WetNet. - Cached best configs: one per sequence length (96, 192, 360, 720, 1440) for two objectives (recall, false_alarm). Each stores schedule variant, PCGrad flag, transformer width/depth/heads/dropout, and the fusion threshold to report.
- VIB fusion: lightweight dual-VIB probe is trained after the main model to provide uncertainty mass for Dempster–Shafer fusion.
- Data: preprocessing lives in
wet_net.data.preprocess. For real runs supply the parquet URL via--data-urlorWETNET_DATA_URL. A mock parquet is shipped so the full pipeline can run without private data.
Notebooks
We use Jupyter notebooks to show the process of preparing the data, training the model, and evaluating the model, with descriptions and code. You can run the notebooks by opening them up in your favorite IDE. Be sure to choose the .venv kernel which is created and managed by uv. The notebooks can be found in the notebooks directory.
01_pre_process.ipynb
The 01_pre_process.ipynb notebook shows the process of preparing the data. It includes:
- Loading the data
- Pre-processing the data
- Saving the pre-processed data
02_train.ipynb
The 02_train.ipynb notebook shows the process of training the model. It includes:
- Loading the pre-processed data
- Training the model
- Saving the trained model
03_evaluate.ipynb
The 03_evaluate.ipynb notebook shows the process of evaluating the model. It includes:
- Loading the trained model
- Evaluating the model
- Saving the evaluation results
Contributing
We welcome contributions to the project. Please feel free to submit an issue or pull request.
For more information on contributing, including how to set up pre-commit hooks and how to cut a new release, see CONTRIBUTING.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wet_net-0.4.0b1.tar.gz.
File metadata
- Download URL: wet_net-0.4.0b1.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a4ed4bae146f11c15bd1b277ba817a30be02666f214872af584d74786de284f
|
|
| MD5 |
281a7b742d02799a319b8716f26d49b1
|
|
| BLAKE2b-256 |
8e903a0166a0b3f4b092f9d8472da75e78a9127ff1f06d52b45d312180f313bf
|
File details
Details for the file wet_net-0.4.0b1-py3-none-any.whl.
File metadata
- Download URL: wet_net-0.4.0b1-py3-none-any.whl
- Upload date:
- Size: 32.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c6e6419ea8b40d61778c1c8a36b168efb7d1ac61e178d32ac288babfe8023a5
|
|
| MD5 |
fd28dd59323f47b28161d5da5c3f4871
|
|
| BLAKE2b-256 |
d64c3fd4dc8deae4368b5820ab5352befaa7c8de7b1360d6f3c68f128ab2214b
|