nnmnkwii.preprocessing.minmax_scale

nnmnkwii.preprocessing.minmax_scale(x, data_min=None, data_max=None, feature_range=(0, 1), scale_=None, min_=None)[source]

Min/max scaling for given a single data.

Given data min, max and feature range, apply min/max normalization to data. Optionally, you can get a little performance improvement to give scaling factor (scale_) and minimum value (min_) used in scaling explicitly. Those values can be computed by nnmnkwii.preprocessing.minmax_scale_params().

Note

If scale_ and min_ are given, feature_range will be ignored.

Parameters
  • x (array) – Input data

  • data_min (array) – Data min for each feature dimention.

  • data_max (array) – Data max for each feature dimention.

  • feature_range (array like) – Feature range.

  • scale_ ([optional]array) – Scaling factor.

  • min_ ([optional]array) – Minimum value for scaling.

Returns

Scaled data.

Return type

array

Raises

ValueError – If (data_min, data_max) or (scale_ and min_) are not specified.

Examples

>>> from nnmnkwii.preprocessing import minmax, minmax_scale
>>> from nnmnkwii.util import example_file_data_sources_for_acoustic_model
>>> from nnmnkwii.datasets import FileSourceDataset
>>> X, Y = example_file_data_sources_for_acoustic_model()
>>> X, Y = FileSourceDataset(X), FileSourceDataset(Y)
>>> data_min, data_max = minmax(X)
>>> scaled_x = minmax_scale(X[0], data_min, data_max)