gaitmap.data_transform.GroupedTransformer#

class gaitmap.data_transform.GroupedTransformer(transformer_mapping: list[tuple[Union[collections.abc.Hashable, str, tuple[Union[collections.abc.Hashable, str], ...]], gaitmap.data_transform._base.BaseTransformer]], keep_all_cols: bool = True)[source]#

Apply specific transformations to specific groups of columns.

Parameters:
transformer_mapping

List of tuples to define which transformers should be applied to which columns. The list should have the shape [(key, transformer), …] where key is either the name of the column or a tuple of column names. If the transformer is trainable, its self_optimize method will be called, when self_optimize of the Grouped Transformer is called.

keep_all_cols

If True, columns that are not mentioned as keys in the transformer_mapping, will be added to the output unchanged. Otherwise, only columns that are actually transformed remain in the output.

Other Parameters:
data

The data passed to the transform method.

Attributes:
transformed_data_

The transformed data.

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.

self_optimize(data, **kwargs)

Train all trainable transformers based on the provided data.

set_params(**params)

Set the parameters of this Algorithm.

to_json()

Export the current object parameters as json.

transform(data, **kwargs)

Transform all data columns based on the selected transformers.

__init__(transformer_mapping: list[tuple[Union[collections.abc.Hashable, str, tuple[Union[collections.abc.Hashable, str], ...]], gaitmap.data_transform._base.BaseTransformer]], keep_all_cols: bool = True) None[source]#
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.

self_optimize(data: Sequence[DataFrame], **kwargs) Self[source]#

Train all trainable transformers based on the provided data.

… note :: All transformers will be trained on all columns they are applied to as group.

This means you will get different results when using (("col_a", "col_b"), transformer()) compared to ("col_a", transformer()), ("col_b", transformer()). In the first case the transformer will be trained over both columns as one.

Parameters:
data

A sequence of dataframes, each representing single-sensor data.

Returns:
self

The trained instance of the transformer

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!

transform(data: DataFrame, **kwargs) Self[source]#

Transform all data columns based on the selected transformers.

Parameters:
data

A dataframe representing single sensor data.

Returns:
self

The instance of the transformer with the results attached