gaitmap.stride_segmentation.hmm.BaseSegmentationHmm#

class gaitmap.stride_segmentation.hmm.BaseSegmentationHmm[source]#

Base class for HMM segmentation models.

Note

This algorithm is only available via the gaitmap_mad package and distributed under a AGPL3 licence. To use it, you need to explicitly install the gaitmap_mad package. Learn more about that here.

In case you want to propose your own HMM architecture that is not covered by the options provided in RothSegmentationHmm, you can inherit from this class and implement all abstract methods.

Attributes:
stride_states

Get the indexes of the states in the hidden state sequence corresponding to strides.

Methods

clone()

Create a new instance of the class with all parameters copied over.

from_json(json_str)

Import an gaitmap object from its json representation.

get_params([deep])

Get parameters for this algorithm.

predict(data, sampling_rate_hz)

Perform prediction based on given data and given model.

self_optimize(data_sequence, ...)

Create and train the HMM model based on the given data and labels.

self_optimize_with_info(data_sequence, ...)

Create and train the HMM model based on the given data and labels.

set_params(**params)

Set the parameters of this Algorithm.

to_json()

Export the current object parameters as json.

__init__(*args, **kwargs)#
clone() Self[source]#

Create a new instance of the class with all parameters copied over.

This will create a new instance of the class itself and all nested objects

classmethod from_json(json_str: str) Self[source]#

Import an gaitmap object from its json representation.

For details have a look at the this example.

You can use the to_json method of a class to export it as a compatible json string.

Parameters:
json_str

json formatted string

get_params(deep: bool = True) dict[str, Any][source]#

Get parameters for this algorithm.

Parameters:
deep

Only relevant if object contains nested algorithm objects. If this is the case and deep is True, the params of these nested objects are included in the output using a prefix like nested_object_name__ (Note the two “_” at the end)

Returns:
params

Parameter names mapped to their values.

predict(data: DataFrame, sampling_rate_hz: float) Self[source]#

Perform prediction based on given data and given model.

Parameters:
data

The data to predict the hidden state sequence for.

sampling_rate_hz

The sampling rate of the data.

Returns:
self

The instance with the result objects attached.

self_optimize(data_sequence: Sequence[DataFrame], stride_list_sequence: Sequence[DataFrame], sampling_rate_hz: float) Self[source]#

Create and train the HMM model based on the given data and labels.

Parameters:
data_sequence

Sequence of gaitmap sensordata objects.

stride_list_sequence

Sequence of gaitmap stride lists. The number of stride lists must match the number of sensordata objects (i.e. they must belong together).

sampling_rate_hz

Sampling frequency of the data.

Returns:
self

The trained model instance.

self_optimize_with_info(data_sequence: Sequence[DataFrame], stride_list_sequence: Sequence[DataFrame], sampling_rate_hz: float) tuple[typing_extensions.Self, Any][source]#

Create and train the HMM model based on the given data and labels.

This is identical to self_optimize, but can return additional information about the training process.

Parameters:
data_sequence

Sequence of gaitmap sensordata objects.

stride_list_sequence

Sequence of gaitmap stride lists. The number of stride lists must match the number of sensordata objects (i.e. they must belong together).

sampling_rate_hz

Sampling frequency of the data.

Returns:
self

The trained model instance.

training_info

An arbitrary object containing training information.

set_params(**params: Any) Self[source]#

Set the parameters of this Algorithm.

To set parameters of nested objects use nested_object_name__para_name=.

to_json() str[source]#

Export the current object parameters as json.

For details have a look at the this example.

You can use the from_json method of any gaitmap algorithm to load the object again.

Warning

This will only export the Parameters of the instance, but not any results!