gaitmap.data_transform.TrainableMinMaxScaler#

class gaitmap.data_transform.TrainableMinMaxScaler(out_range: tuple[float, float] = (0, 1.0), data_range: tuple[float, float] | None = None)[source]#

Scale the data by Min-Max values learned from trainings data.

Warning

By default, this scaler will not modify the data! Use self_optimize to adapt the data_range parameter based on a set of training data.

During training the scaling and offset is calculated based on the min and max of the trainings sequence. If multiple sequences are provided for training, the global min and max values of all sequences are used.

data_range =  (x_train.min(), x_train.max())
scale = (out_range[1] - out_range[0]) / (data_range[1] - data_range[0])
offset = out_range[0] - x_train.min() * transform_scale

Note that the minimum and maximum over all columns is calculated. I.e. Only a single global scaling factor is applied to all the columns.

During transform these trained transformation are applied as follows.

y = x * scale + offset
Parameters:
out_range

The range the data is scaled to.

data_range

The range of the data used for training. The values can either be set manually or automatically calculated from the training data using self_optimize.

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, **_)

Calculate scaling parameters based on a trainings sequence.

set_params(**params)

Set the parameters of this Algorithm.

to_json()

Export the current object parameters as json.

transform(data, **_)

Scale the data.

__init__(out_range: tuple[float, float] = (0, 1.0), data_range: tuple[float, float] | None = None) 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], **_)[source]#

Calculate scaling parameters based on a trainings sequence.

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, **_) Self[source]#

Scale the data.

Parameters:
data

A dataframe representing single sensor data.

Returns:
self

The instance of the transformer with the results attached