SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2011.01776 · 2020

Leveraging Activity Recognition to Enable Protective Behavior Detection in Continuous Data

arXiv · PDF · Open in the Atlas

Code that ran

3 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 0 failures of our instrument; 4 no recorded run), measured 2026-11-21; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2011.01776.json · badge: /api/ran/2011.01776.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
Mvrjustid/IMWUT-Hierarchical-HAR-PBD canonical (classifier label)
classifier basis: census
3 ran · 4 no recorded run
FunctionStatusWhere it lives
class_balance_weights Ran
ran on a synthesized input
Mvrjustid/IMWUT-Hierarchical-HAR-PBD/code/utils.py
code served (permissive licence) · get_code("ae056e4ff565a8a4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 1, dtype family float, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Construct arguments for class_balance_weights
# The function takes:
# - beta: a float (probability, typically between 0 and 1)
# - sample_per_class: array-like of sample counts per class

beta = 0.9999
sample_per_class = np.array([100, 50, 200, 150])

ARGS = {
    "beta": beta,
    "sample_per_class": sample_per_class,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (4,) — shape (4,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
focal_loss Ran
ran on a synthesized input
Mvrjustid/IMWUT-Hierarchical-HAR-PBD/code/utils.py
code served (permissive licence) · get_code("6853f6c77c17fc20")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tensorflow as tf
import numpy as np

# Set seed for reproducibility
tf.random.set_seed(0)

# Create small test data
batch_size = 2
num_classes = 2

# y_true: one-hot encoded labels (batch_size x num_classes)
y_true = tf.constant([[1.0, 0.0], [0.0, 1.0]], dtype=tf.float32)

# y_pred: probability predictions (batch_size x num_classes)
y_pred = tf.constant([[0.9, 0.1], [0.2, 0.8]], dtype=tf.float32)

# Define the focal_loss function
def focal_loss(weights=None, gamma=None, num_class=None):
    if weights is None:
        weights = [1.0, 1.0]
    if gamma is None:
        gamma = 1.0
    if num_class is None:
        num_class = 2

    def focaloss(y_true, y_pred):
        weights1 = tf.cast(weights, dtype=tf.float32)
        weights1 = tf.expand_dims(weights1, 0)
        weights1 = tf.tile(weights1, [tf.shape(y_true)[0], 1]) * y_true
        weights1 = tf.reduce_sum(weights1, axis=1)
        weights1 = tf.expand_dims(weights1, 1)
        weights1 = tf.tile(weights1, [1, num_class])
        CE = -y_true * tf.math.log(y_pred)
        modulator = (1 - y_true * y_pred) ** gamma
        loss = modulator * CE
        weighted_loss = weights1 * loss
        FL = tf.reduce_sum(weighted_loss)
        FL /= tf.reduce_sum(y_true)
        return FL
    return focaloss

# Create loss function instance
loss_fn = focal_loss(weights=[1.0, 1.0], gamma=2.0, num_class=2)

# Test the loss function
result = loss_fn(y_true, y_pred)

ARGS = {
    "weights": [1.0, 1.0],
    "gamma": 2.0,
    "num_class": 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
output_of_adjmul Ran
ran on a synthesized input
Mvrjustid/IMWUT-Hierarchical-HAR-PBD/code/HierarchicalHAR-PBD.py
code served (permissive licence) · get_code("a0f88d29e3b32aa7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function takes input_shape and returns a tuple of 4 elements from it
# input_shape should be indexable with indices 0, 1, 2, 3
# A simple tuple or list with 4 integers works

input_shape = (2, 4, 8, 16)

ARGS = {
    "input_shape": input_shape
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
HARExtend Not yet run
unverified (harvested, no recorded run)
Mvrjustid/IMWUT-Hierarchical-HAR-PBD/code/HierarchicalHAR-PBD.py
code served (permissive licence) · get_code("24b4d234620d9739")
How it ran

no invocation recorded.

adjmul Not yet run
unverified (harvested, no recorded run)
Mvrjustid/IMWUT-Hierarchical-HAR-PBD/code/HierarchicalHAR-PBD.py
code served (permissive licence) · get_code("baf34e51345c75c8")
How it ran

no invocation recorded.

build_model Not yet run
unverified (harvested, no recorded run)
Mvrjustid/IMWUT-Hierarchical-HAR-PBD/code/gc-LSTM.py
code served (permissive licence) · get_code("4fc2e305cd8947e6")
How it ran

no invocation recorded.

crop Not yet run
unverified (harvested, no recorded run)
Mvrjustid/IMWUT-Hierarchical-HAR-PBD/code/utils.py
code served (permissive licence) · get_code("7ca5ca815c2f5c6f")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Protective behavior exhibited by people with chronic pain (CP) during physical activities is the key to understanding their physical and emotional states. Existing automatic protective behavior detection (PBD) methods rely on pre-segmentation of activities predefined by users. However, in real life, people perform activities casually. Therefore, where those activities present difficulties for people with chronic pain, technology-enabled support should be delivered continuously and automatically adapted to activity type and occurrence of protective behavior. Hence, to facilitate ubiquitous CP management, it becomes critical to enable accurate PBD over continuous data. In this paper, we propose to integrate human activity recognition (HAR) with PBD via a novel hierarchical HAR-PBD architecture comprising graph-convolution and long short-term memory (GC-LSTM) networks, and alleviate class imbalances using a class-balanced focal categorical-cross-entropy (CFCC) loss. Through in-depth evaluation of the approach using a CP patients' dataset, we show that the leveraging of HAR, GC-LSTM networks, and CFCC loss leads to clear increase in PBD performance against the baseline (macro F1 score of 0.81 vs. 0.66 and precision-recall area-under-the-curve (PR-AUC) of 0.60 vs. 0.44). We conclude by discussing possible use cases of the hierarchical architecture in CP management and beyond. We also discuss current limitations and ways forward.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2011.01776")
get_code_for_paper("2011.01776")
have("2011.01776")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2011.01776.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2011.01776.svg)](https://syntology.ai/paper/2011.01776)

Connect an agent — have() is free.