Skip to content

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WHAR Models

This library offers reusable model implementations for WHAR (Wearable Human Activity Recognition), including:

  • standalone neural architectures for wearable activity recognition
  • standalone classical machine-learning baselines
  • a unified registry for discovering and constructing models
  • consistent model folders under src/whar_models/<model_id>/
  • a shared input convention for WHAR windows shaped as (batch, channels, timesteps)

The library currently includes out-of-the-box support for 24 models. Model-specific defaults are defined in each model package, and overrides can be passed through build_model.

How to Use

Installation

pip install "git+https://github.com/teco-kit//whar-models.git"

List Models

from whar_models import WHARModelID, list_models

for spec in list_models():
    print(spec.id, spec.name, spec.family, spec.framework)

print(WHARModelID.DEEPCONV_LSTM.value)

PyTorch Model Training and Inference

import torch

from whar_models import WHARModelID, build_model

model = build_model(
    WHARModelID.DEEPCONV_LSTM,
    input_channels=6,
    window_length=128,
    num_classes=5,
)

x_train = torch.randn(32, 6, 128)
y_train = torch.randint(0, 5, size=(32,))

optimizer = torch.optim.AdamW(model.parameters(), lr=1e-3)
criterion = torch.nn.CrossEntropyLoss()

model.train()
for _ in range(10):
    optimizer.zero_grad(set_to_none=True)
    loss = criterion(model(x_train), y_train)
    loss.backward()
    optimizer.step()

model.eval()
x_test = torch.randn(8, 6, 128)
with torch.no_grad():
    logits = model(x_test)
predictions = logits.argmax(dim=1)

Classical Model Inference After Fitting

import torch

from whar_models import WHARModelID, build_model

model = build_model(
    WHARModelID.RANDOM_FOREST,
    input_channels=6,
    window_length=128,
    num_classes=5,
)

x_train = torch.randn(32, 6, 128)
y_train = torch.randint(0, 5, size=(32,))
model.fit(x_train, y_train)

x_test = torch.randn(8, 6, 128)
scores = model(x_test)
predictions = scores.argmax(dim=1)

Classical models accept torch.Tensor and numpy.ndarray inputs with the same (batch, channels, timesteps) shape as neural models. Tensor inputs are converted internally for feature extraction and scikit-learn inference. Their fit(...) method fits the underlying estimator; it is not a benchmark training loop and does not support gradient-based training.

Supported Models

Neural Models

Supported Name Model Paper Framework
✅ AROMA_JOINT_MODEL AROMA Joint AROMA: A Deep Multi-Task Learning Based Simple and Complex Human Activity Recognition Method Using Wearable Sensors PyTorch
✅ ATTEND_DISCRIMINATE Attend+Discriminate Attend and Discriminate: Beyond the State-of-the-Art for Human Activity Recognition Using Wearable Sensors PyTorch
✅ ATTENSENSE AttenSense AttnSense: Multi-level Attention Mechanism For Multimodal Human Activity Recognition PyTorch
✅ CNN_HAR CNN-HAR Deep Convolutional Neural Networks on Multichannel Time Series for Human Activity Recognition PyTorch
✅ DANA DANA DANA: Dimension-Adaptive Neural Architecture for Multivariate Sensor Data PyTorch
✅ DEEPCONV_LSTM DeepConvLSTM Deep Convolutional and LSTM Recurrent Neural Networks for Multimodal Wearable Activity Recognition PyTorch
✅ DEEPCONV_LSTM_ATTENTION DeepConvLSTM-Attn On Attention Models for Human Activity Recognition PyTorch
✅ DEEPCONV_LSTM_ISWC DeepConvShallowLSTM Improving Deep Learning for HAR with Shallow LSTMs PyTorch
✅ DEEPSENSE DeepSense DeepSense: A Unified Deep Learning Framework for Time-Series Mobile Sensing Data Processing PyTorch
✅ DYNAMIC_WHAR DynamicWHAR Towards a Dynamic Inter-Sensor Correlations Learning Framework for Multi-Sensor-Based Wearable Human Activity Recognition PyTorch
✅ GLOBAL_FUSION GlobalFusion GlobalFusion: A Global Attentional Deep Learning Framework for Multisensor Information Fusion PyTorch
✅ IF_CONV_TRANSFORMER IF-ConvTransformer IF-ConvTransformer: A Framework for Human Activity Recognition Using IMU Fusion and ConvTransformer PyTorch
✅ LITEWAY LITEWAY LITEWAY: An extra-lightweight, convolution-only network with a single linear layer for human activity recognition (code) PyTorch
✅ LITEWAY_LIGHT LITEWAY Light LITEWAY: An extra-lightweight, convolution-only network with a single linear layer for human activity recognition (code) PyTorch
✅ LSTMS_ENSEMBLE Guan-LSTM Ensembles of Deep LSTM Learners for Activity Recognition Using Wearables PyTorch
✅ MLP_HAR MLP-HAR MLP-HAR: Boosting Performance and Efficiency of HAR Models on Edge Devices with Purely Fully Connected Layers PyTorch
✅ MLP_MIXER MLP-Mixer MLPs Are All You Need for Human Activity Recognition PyTorch
✅ SA_HAR SA-HAR Human Activity Recognition from Wearable Sensor Data Using Self-Attention PyTorch
✅ TINIERHAR TinierHAR TinierHAR: Towards Ultra-Lightweight Deep Learning Models for Efficient Human Activity Recognition on Edge Devices PyTorch
✅ TINYHAR TinyHAR TinyHAR: A Lightweight Deep Learning Model Designed for Human Activity Recognition PyTorch
✅ TRIPLE_CROSS_DOMAIN_ATTENTION Triple-Cross-Attn Triple Cross-Domain Attention on Human Activity Recognition Using Wearable Sensors PyTorch

Classical Models

Supported Name Model Paper Framework Default Configuration
✅ KNN k-NN Scikit-learn: Machine Learning in Python scikit-learn + tsfresh n_neighbors=5, weights="distance"
✅ RANDOM_FOREST Random Forest Scikit-learn: Machine Learning in Python scikit-learn + tsfresh n_estimators=100, random_state=42, n_jobs=-1, max_depth=8, min_samples_leaf=10
✅ SVM SVM Scikit-learn: Machine Learning in Python scikit-learn + tsfresh kernel="rbf", C=1.0, gamma="scale", probability=False

Adding a Model

  1. Add an implementation under src/whar_models/<model_id>/.
  2. Register it in src/whar_models/registry.py.
  3. Add a focused test that builds the model for a generic WHAR input.

Models should accept variable channel counts, sequence lengths, and class counts. Dataset-specific assumptions belong in the dataset package, not here.

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages