Downloads · 30 days
0
kokemn/Wearable_TimeSeries_Health_Monitor
Wearable_TimeSeries_Health_Monitor is a time series forecasting model from kokemn. Use it for the time series forecasting task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as apache-2.0.
Downloads · 30 days
0
Access
Public
Updated Mar 18, 2026
Repo size
27.3 MB
Likes
0
Public
Click a slice to open those files.
.pt27.3 MB · 100%
From the Hugging Face model README
<a id="中文版本"></a>
面向可穿戴设备的多用户健康监控方案:一份模型、一个配置,就能为不同用户构建个性化异常检测。模型基于 Phased LSTM + Temporal Fusion Transformer (TFT),并整合自适应基线、因子特征以及单位秒级的数据滑窗能力,适合当作 HuggingFace 模型或企业内部服务快速接入。
| 能力 | 说明 |
|---|---|
| 即插即用 | 内置 WearableAnomalyDetector 封装,加载模型即可预测,一次初始化后可持续监控多个用户 |
| 配置驱动特征 | configs/features_config.json 描述所有特征、缺省值、类别映射,新增/删减血氧、呼吸率等只需改配置 |
| 多用户实时服务 | FeatureCalculator + 轻量级 data_storage 缓存,实现用户历史管理、基线演化、批量推理 |
| 多场景 Demo | test_wearable_service.py 内置 3 个真实"客户"案例:完整传感器、缺少字段、匿名设备,即使没有原始数据也能立即体验 |
| 自适应基线支持 | 可扩展 UserDataManager 将个人/分组基线接入推理流程,持续改善个体敏感度 |
模型采用自适应基线策略,根据用户历史数据量动态选择最优基线:
final_mean = α × personal_mean + (1-α) × group_mean)实现从群体到个人的渐进式适应优势:相比固定阈值或纯群体基线,自适应基线能同时兼顾个性化敏感度(减少误报)和冷启动鲁棒性(新用户可用),特别适合多用户、长周期监控场景。
优势:适应不同设备采样频率、用户佩戴习惯,无需强制对齐时间戳,降低数据预处理复杂度。
模型整合4 大类特征通道,通过因子特征与注意力机制实现跨通道信息融合:
生理通道(HR、HRV 系列、呼吸率、血氧)
physiological_mean, physiological_std, physiological_max, physiological_min活动通道(步数、距离、能量消耗、加速度、陀螺仪)
activity_mean, activity_std 等环境通道(光线、时间周期、数据质量)
time_period_primary(morning/day/evening/night)基线通道(自适应基线均值/标准差、偏差特征)
hrv_deviation_abs, hrv_z_score 等相对异常指标协同机制:
优势:多通道协同能显著降低单一指标误报(如运动导致心率升高),提升异常检测的上下文感知能力,特别适合可穿戴设备的多传感器融合场景。
模型偏向召回,适合“异常先提醒、人机协同复核”的场景。可通过阈值/采样策略调节精度与召回。
git clone https://huggingface.co/oscarzhang/Wearable_TimeSeries_Health_Monitor
cd Wearable_TimeSeries_Health_Monitor
pip install -r requirements.txt
# 默认跑 ab60 案例
python test_wearable_service.py
# 批量跑全部预置客户
python test_wearable_service.py --case all
# 想从原始 stage1 CSV 抽样测试
python test_wearable_service.py --from-raw
test_wearable_service.py 将自动:
WearableAnomalyDetectorfrom wearable_anomaly_detector import WearableAnomalyDetector
detector = WearableAnomalyDetector(
model_dir="checkpoints/phase2/exp_factor_balanced",
threshold=0.53,
)
result = detector.predict(data_points, return_score=True, return_details=True)
print(result)
data_points为 12 条最新的 5 分钟记录;若缺静态特征/设备信息,系统会自动从配置/缓存补齐。
{
"timestamp": "2024-01-01T08:00:00",
"deviceId": "ab60", # 可选,缺失时会自动创建匿名 ID
"features": {
"hr": 72.0,
"hrv_rmssd": 30.0,
"time_period_primary": "morning",
"data_quality": "high",
...
}
}
configs/features_config.json 控制{
"is_anomaly": True,
"anomaly_score": 0.5760,
"threshold": 0.5300,
"details": {
"window_size": 12,
"model_output": 0.5760,
"prediction_confidence": 0.0460
}
}
├─ configs/
│ └─ features_config.json # 特征定义 & 归一化策略
├─ wearable_anomaly_detector.py # 核心封装:加载、预测、批处理
├─ feature_calculator.py # 配置驱动的特征构建 + 用户历史缓存
├─ test_wearable_service.py # HuggingFace Demo脚本(内含预置案例)
└─ checkpoints/phase2/... # 模型权重 & summary
欢迎:
features_config.json + 提交 PRFeatureCalculator 或贡献 UserDataManager@software{Wearable_TimeSeries_Health_Monitor,
title = {Wearable\_TimeSeries\_Health\_Monitor},
author = {oscarzhang},
year = {2025},
url = {https://huggingface.co/oscarzhang/Wearable_TimeSeries_Health_Monitor}
}
<a id="english-version"></a>
A multi-user health monitoring solution for wearable devices: one model, one configuration, enabling personalized anomaly detection for different users. The model is based on Phased LSTM + Temporal Fusion Transformer (TFT), integrating adaptive baselines, factor features, and second-level data sliding window capabilities, suitable for deployment as a HuggingFace model or rapid integration into enterprise services.
| Capability | Description |
|---|---|
| Plug-and-Play | Built-in WearableAnomalyDetector wrapper, load the model and start predicting, supports continuous monitoring of multiple users after a single initialization |
| Configuration-Driven Features | configs/features_config.json defines all features, default values, and category mappings; adding/removing features like blood oxygen or respiratory rate only requires configuration changes |
| Multi-User Real-Time Service | FeatureCalculator + lightweight data_storage cache enables user history management, baseline evolution, and batch inference |
| Multi-Scenario Demo | test_wearable_service.py includes 3 real "client" cases: complete sensors, missing fields, anonymous devices, allowing immediate experience even without raw data |
| Adaptive Baseline Support | Extensible UserDataManager integrates personal/group baselines into the inference pipeline, continuously improving individual sensitivity |
The model employs an adaptive baseline strategy that dynamically selects the optimal baseline based on user historical data volume:
final_mean = α × personal_mean + (1-α) × group_mean)Advantage: Compared to fixed thresholds or pure group baselines, adaptive baselines balance personalized sensitivity (reducing false positives) and cold-start robustness (usable for new users), especially suitable for multi-user, long-term monitoring scenarios.
Advantage: Adapts to different device sampling frequencies and user wearing habits, no need to force timestamp alignment, reducing data preprocessing complexity.
The model integrates 4 major feature channels, achieving cross-channel information fusion through factor features and attention mechanisms:
Physiological Channel (HR, HRV series, respiratory rate, blood oxygen)
physiological_mean, physiological_std, physiological_max, physiological_minActivity Channel (steps, distance, energy consumption, acceleration, gyroscope)
activity_mean, activity_std, etc.Environmental Channel (light, time period, data quality)
time_period_primary (morning/day/evening/night)Baseline Channel (adaptive baseline mean/std, deviation features)
hrv_deviation_abs, hrv_z_scoreSynergy Mechanism:
Advantage: Multi-channel synergy significantly reduces single-indicator false positives (e.g., exercise-induced heart rate elevation) and improves context-aware anomaly detection, especially suitable for multi-sensor fusion scenarios in wearable devices.
The model favors recall, suitable for "anomaly-first alert, human-machine collaborative review" scenarios. Precision and recall can be adjusted through threshold/sampling strategies.
git clone https://huggingface.co/oscarzhang/Wearable_TimeSeries_Health_Monitor
cd Wearable_TimeSeries_Health_Monitor
pip install -r requirements.txt
# Run ab60 case by default
python test_wearable_service.py
# Run all predefined clients
python test_wearable_service.py --case all
# Sample from raw stage1 CSV for testing
python test_wearable_service.py --from-raw
test_wearable_service.py will automatically:
WearableAnomalyDetectorfrom wearable_anomaly_detector import WearableAnomalyDetector
detector = WearableAnomalyDetector(
model_dir="checkpoints/phase2/exp_factor_balanced",
threshold=0.53,
)
result = detector.predict(data_points, return_score=True, return_details=True)
print(result)
data_pointsshould be 12 latest 5-minute records; if static features/device information are missing, the system will automatically fill from configuration/cache.
{
"timestamp": "2024-01-01T08:00:00",
"deviceId": "ab60", # Optional, anonymous ID will be created if missing
"features": {
"hr": 72.0,
"hrv_rmssd": 30.0,
"time_period_primary": "morning",
"data_quality": "high",
...
}
}
configs/features_config.json{
"is_anomaly": True,
"anomaly_score": 0.5760,
"threshold": 0.5300,
"details": {
"window_size": 12,
"model_output": 0.5760,
"prediction_confidence": 0.0460
}
}
├─ configs/
│ └─ features_config.json # Feature definitions & normalization strategies
├─ wearable_anomaly_detector.py # Core wrapper: loading, prediction, batch processing
├─ feature_calculator.py # Configuration-driven feature construction + user history cache
├─ test_wearable_service.py # HuggingFace Demo script (includes predefined cases)
└─ checkpoints/phase2/... # Model weights & summary
Welcome to:
features_config.json + submit PRFeatureCalculator or contribute UserDataManager@software{Wearable_TimeSeries_Health_Monitor,
title = {Wearable\_TimeSeries\_Health\_Monitor},
author = {oscarzhang},
year = {2025},
url = {https://huggingface.co/oscarzhang/Wearable_TimeSeries_Health_Monitor}
}