MinMax Scaler

Description

The MinMax scaler scales the given data set, so that all values will lie between a user specified range [min,max].In case the user does not provide a specific minimum and maximum value for the scaling range, the MinMax scaler transforms the features of the input data set to lie in the [0,1] interval.Given a set of input data $x_1, x_2,… x_n$, with minimum value:

and maximum value:

The scaled data set $z_1, z_2,…,z_n$ will be:

where $\textit{min}$ and $\textit{max}$ are the user specified minimum and maximum values of the range to scale.

Operations

MinMaxScaler is a Transformer.As such, it supports the fit and transform operation.

Fit

MinMaxScaler is trained on all subtypes of Vector or LabeledVector:

  • fit[T <: Vector]: DataSet[T] => Unit
  • fit: DataSet[LabeledVector] => Unit

Transform

MinMaxScaler transforms all subtypes of Vector or LabeledVector into the respective type:

  • transform[T <: Vector]: DataSet[T] => DataSet[T]
  • transform: DataSet[LabeledVector] => DataSet[LabeledVector]

Parameters

The MinMax scaler implementation can be controlled by the following two parameters:

ParametersDescription
MinThe minimum value of the range for the scaled data set. (Default value: 0.0)
MaxThe maximum value of the range for the scaled data set. (Default value: 1.0)

Examples

  1. // Create MinMax scaler transformer
  2. val minMaxscaler = MinMaxScaler()
  3. .setMin(-1.0)
  4. // Obtain data set to be scaled
  5. val dataSet: DataSet[Vector] = ...
  6. // Learn the minimum and maximum values of the training data
  7. minMaxscaler.fit(dataSet)
  8. // Scale the provided data set to have min=-1.0 and max=1.0
  9. val scaledDS = minMaxscaler.transform(dataSet)

Back to top