Transformers
Safetensors
time-series
patchtst
livestock
dairy
synthetic-data
student-project
time-series-classification
Instructions to use YasenDzhenkov/herdsight-patchtst with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use YasenDzhenkov/herdsight-patchtst with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("YasenDzhenkov/herdsight-patchtst", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download test_simulate.py from YasenDzhenkov/herdsight-patchtst: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/YasenDzhenkov/herdsight-patchtst/resolve/main/test_simulate.py
- Command line
-
hf download hf://YasenDzhenkov/herdsight-patchtst/test_simulate.py
-
curl -L -o test_simulate.py https://huggingface.co/YasenDzhenkov/herdsight-patchtst/resolve/main/test_simulate.py
1.7 kB
| """Self-check for the simulator: shapes, seeding, label rates, realistic ranges. Run: python test_simulate.py""" | |
| import numpy as np | |
| from simulate import CLASSES, SIGNALS, simulate | |
| a = simulate(n_cows=600, n_days=400, n_farms=4, seed=7) | |
| b = simulate(n_cows=600, n_days=400, n_farms=4, seed=7) | |
| c = simulate(n_cows=600, n_days=400, n_farms=4, seed=8) | |
| X, y = a["X"], a["y"] | |
| assert X.shape == (600, 400, len(SIGNALS)) and y.shape == (600, 400) and a["thi"].shape == (4, 400) | |
| assert np.array_equal(X, b["X"], equal_nan=True) and np.array_equal(y, b["y"]), "same seed must reproduce" | |
| assert not np.array_equal(y, c["y"]), "different seed must differ" | |
| rates = np.bincount(y.ravel(), minlength=len(CLASSES)) / y.size | |
| assert 0.90 < rates[0] < 0.99, rates # most cow-days are normal | |
| assert all(r > 0 for r in rates[1:]), rates # every event class occurs | |
| assert 0.01 < np.isnan(X[:, :, 0]).mean() < 0.08 # missing data present but limited | |
| temp = X[:, :, SIGNALS.index("thermal_drone")] | |
| assert 20 <= np.nanmin(temp) and np.nanmax(temp) <= 38.5 # body SURFACE, not core (38.5-39.5) | |
| assert 0.005 < np.isnan(temp).mean() < 0.2 # drone misses some cow-days | |
| assert 25 < np.nanmedian(temp) < 36 | |
| for s in ["feeding_min", "rumination_min", "lying_min", "outside_fence_min"]: | |
| v = X[:, :, SIGNALS.index(s)] | |
| assert np.nanmin(v) >= 0 and np.nanmax(v) <= 1440, s | |
| rum = X[:, :, SIGNALS.index("rumination_min")] | |
| assert np.nanmean(rum[y == CLASSES.index("brd")]) < np.nanmean(rum[y == 0]) | |
| steps = X[:, :, SIGNALS.index("steps")] | |
| assert np.nanmean(steps[y == CLASSES.index("estrus")]) > 1.3 * np.nanmean(steps[y == 0]) | |
| print("ok", dict(zip(CLASSES, rates.round(4)))) | |