Scikit-learn
human-activity-recognition
wearable
wrist
time-series
cpu
scikit-learn
File size: 1,803 Bytes
4731b11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""The three WISP-CIS representation blocks under their paper names.

Each function returns an unfitted kernel transformer configured exactly as inside
WISP-CIS (``wisp.cis_algorithms.StateRocketIntervalHMM``) for the given seed. They take
windows ``(n, T, C)`` and return ``(n, d)`` features; each standardises every window
and channel itself.
"""
from __future__ import annotations

from wisp.cpu.features import IntervalDistributionSketch, RandomConvSketch, WearableFeatureExtractor

__all__ = ["RandomConvolution", "IntervalSummary", "StateSpectral"]


def RandomConvolution(random_state: int = 42, n_kernels: int = 384) -> RandomConvSketch:
    """Paper block R: random dilated multichannel convolutions with PPV/max/mean/std pooling."""
    return RandomConvSketch(n_kernels=int(n_kernels), random_state=int(random_state))


def IntervalSummary(random_state: int = 42, n_intervals: int = 24) -> IntervalDistributionSketch:
    """Paper block I: dyadic plus random intervals summarised by moments, slope and quantiles.

    ``random_state`` is the recipe seed; the CIS seed offset (+29) is applied here, so
    ``IntervalSummary(s)`` equals the I block of ``WISPRepresentation("cis", random_state=s)``.
    """
    return IntervalDistributionSketch(n_random_intervals=int(n_intervals), random_state=int(random_state) + 29)


def StateSpectral() -> WearableFeatureExtractor:
    """Paper block S: magnitude/jerk, spectrum, autocorrelation, cross-axis and symbolic state features."""
    return WearableFeatureExtractor(include_raw_stats=False, include_magnitude=True, include_jerk=True,
                                    include_multiscale=False, include_spectral=True, include_autocorr=True,
                                    include_cross_channel=True, include_symbolic=True, symbolic_bins=6)