Feature Scalers

class derrom.scalers.data_scaler[source]

Bases: object

Base clase to define the methods to be implemented.

inverse_transform()[source]
train()[source]
transform()[source]
class derrom.scalers.normalize_scaler(rel_scale=1.0)[source]

Bases: data_scaler

Feature scaler which linearly maps each feature to a specified symmetric range around the origin.

Parameters:

rel_scale (float) – Range to which the features are mapped. The default rel_scale = 1.0 maps to \([-0.5,0.5]\)

inverse_transform(data_matrix)[source]

Reverses normalization of each feature

Parameters:

data_matrix (2D numpy.ndarray) – scaled data matrix with the datavectors as rows.

Returns:

scaled_data_matrix – unscaled data matrix

Return type:

2D numpy.ndarray

train(data_matrix)[source]

Determines the range if each feature, i.e., the maximum and minimum value.

Detects quasi-constant features, i.e. features with a standard deviation < 1e-8 and does not scale them.

Parameters:

data_matrix (2D numpy.ndarray) – Training data matrix, where the data vectors are stored in the rows (first index). Hence, the features are defined by their column index (second index).

transform(data_matrix)[source]

Applies normalization to each feature.

Parameters:

data_matrix (2D numpy.ndarray) – unscaled data matrix with the datavectors as rows.

Returns:

scaled_data_matrix – scaled data matrix

Return type:

2D numpy.ndarray

class derrom.scalers.standardize_scaler(rel_scale=1.0)[source]

Bases: data_scaler

Feature scaler which subtracts the mean and devices by the standard deviation for each feature.

Parameters:

rel_scale (float) – Standard deviation of the resulting scaled features. Default is 1.

inverse_transform(data_matrix)[source]

Reverses standardization of each feature by multiplying by the standard deviation and adding the mean (of the training data)

Parameters:

data_matrix (2D numpy.ndarray) – scaled data matrix with the datavectors as rows.

Returns:

scaled_data_matrix – unscaled data matrix

Return type:

2D numpy.ndarray

train(data_matrix)[source]

Computes the mean and standard deviation of each feature.

Detects quasi-constant features, i.e. features with a standard deviation < 1e-8 and does not scale them.

Parameters:

data_matrix (2D numpy.ndarray) – Training data matrix, where the data vectors are stored in the rows (first index). Hence, the features are defined by their column index (second index).

transform(data_matrix)[source]

Applies standardization to each feature.

Parameters:

data_matrix (2D numpy.ndarray) – unscaled data matrix with the datavectors as rows.

Returns:

scaled_data_matrix – scaled data matrix

Return type:

2D numpy.ndarray

class derrom.scalers.tanh_scaler(arg_scale=1.0, out_scale=1.0)[source]

Bases: data_scaler

inverse_transform(data_matrix)[source]
train(data_matrix)[source]
transform(data_matrix)[source]