Activities
actimotus.Activities
dataclass
Processes extracted features to perform Human Activity Recognition (HAR).
This class ingests features from multiple sensors (required: thigh; optional: trunk, calf, arm) and produces a time-series of recognized activities at 1-second resolution.
Key capabilities include automatic sensor orientation detection (correcting for upside-down or inside-out flipped devices), vendor-specific signal corrections, and configurable activity recognition thresholds.
Attributes:
| Name | Type | Description |
|---|---|---|
system_frequency |
int
|
The target frequency (in Hz) used for internal calculations. Defaults to 30 Hz. |
vendor |
Literal['Sens', 'Other']
|
The hardware vendor of the sensor. If set to |
orientation |
bool
|
If |
chunks |
bool
|
If |
size |
str | timedelta
|
The duration of each processing chunk. Accepts a |
overlap |
str | timedelta
|
The duration of overlap between consecutive chunks. Accepts a
|
config |
dict[str, Any] | Literal['DEFAULT', 'LEGACY']
|
The configuration for activity recognition thresholds. Can be a dictionary of custom parameters, or a preset string:
|
Examples:
Standard usage with default configuration:
>>> model = Activities()
>>> # activities, references = model.process(features)
Usage for 'Sens' devices with legacy thresholds and automatic flip detection:
>>> model = Activities(
... vendor='Sens',
... config='LEGACY',
... orientation=True
... )
compute
compute(
thigh: DataFrame,
*,
trunk: DataFrame | None = None,
calf: DataFrame | None = None,
arm: DataFrame | None = None,
references: dict[str, Any] | None = None
) -> tuple[pd.DataFrame, dict[str, Any]]
Executes the activity recognition pipeline on the provided sensor data.
This method synchronizes inputs from the thigh (primary) and optional secondary sensors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thigh
|
DataFrame
|
The primary accelerometer feature data. Must contain a
|
required |
trunk
|
DataFrame | None
|
Optional feature data from a trunk sensor. |
None
|
calf
|
DataFrame | None
|
Optional feature data from a calf sensor. |
None
|
arm
|
DataFrame | None
|
Optional feature data from an arm sensor. |
None
|
references
|
dict[str, Any] | None
|
A dictionary containing reference data (individual reference angles, calibration intervals). |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A tuple |
dict[str, Any]
|
|
tuple[DataFrame, dict[str, Any]]
|
|
Examples:
Basic usage with only the mandatory thigh sensor:
>>> model = Activities()
>>> activities, references = model.compute(features)
Usage with multiple sensors and existing references. Note that secondary sensors must be passed as keyword arguments:
>>> previous_references = {
... 'thigh': {
... 'value': -0.201,
... 'expires': '2024-09-03 12:05:51+00:00',
... },
... 'calibrations': [
... {
... 'start': '2024-09-03 08:08:51+00:00',
... 'end': '2024-09-03 08:09:11+00:00',
... 'ttl': '24h',
... },
... ],
... }
>>> activities, new_references = model.compute(
... thigh_df,
... trunk=trunk_df,
... references=previous_references,
... )