preprocess_scale: Scale Data

View source: R/preprocess_scale.R

preprocess_scaleR Documentation

Scale Data

Description

A utility to perform feature scaling on datasets using one of sixtechniques. Both scaling and inverse scaling are supported, andscalers can be saved and then applied to other datasets.

Usage

preprocess_scale(
  input,
  epsilon = NA,
  input_model = NA,
  inverse_scaling = FALSE,
  max_value = NA,
  min_value = NA,
  scaler_method = NA,
  seed = NA,
  verbose = getOption("mlpack.verbose", FALSE)
)

Arguments

input

Matrix containing data (numeric matrix).

epsilon

regularization Parameter for pcawhitening, or zcawhitening, should be between -1 to 1. Default value "1e-06" (numeric).

input_model

Input Scaling model (ScalingModel).

inverse_scaling

Inverse Scaling to get original datase. Default value "FALSE" (logical).

max_value

Ending value of range for min_max_scaler. Default value "1" (integer).

min_value

Starting value of range for min_max_scaler. Default value "0" (integer).

scaler_method

method to use for scaling, the default is standard_scaler. Default value "standard_scaler" (character).

seed

Random seed (0 for std::time(NULL)). Default value "0" (integer).

verbose

Display informational messages and the full list of parameters and timers at the end of execution. Default value "getOption("mlpack.verbose", FALSE)" (logical).

Details

This utility takes a dataset and performs feature scaling using one of the six scaler methods namely: 'max_abs_scaler', 'mean_normalization', 'min_max_scaler' ,'standard_scaler', 'pca_whitening' and 'zca_whitening'. The function takes a matrix as "input" and a scaling method type which you can specify using "scaler_method" parameter; the default is standard scaler, and outputs a matrix with scaled feature.

The output scaled feature matrix may be saved with the "output" output parameters.

The model to scale features can be saved using "output_model" and later can be loaded back using"input_model".

Value

A list with several components:

output

Matrix to save scaled data to (numeric matrix).

output_model

Output scaling model (ScalingModel).

Author(s)

mlpack developers

Examples

# So, a simple example where we want to scale the dataset "X" into "X_scaled"
# with  standard_scaler as scaler_method, we could run 

## Not run: 
output <- preprocess_scale(input=X, scaler_method="standard_scaler")
X_scaled <- output$output

## End(Not run)

# A simple example where we want to whiten the dataset "X" into "X_whitened"
# with  PCA as whitening_method and use 0.01 as regularization parameter, we
# could run 

## Not run: 
output <- preprocess_scale(input=X, scaler_method="pca_whitening",
  epsilon=0.01)
X_scaled <- output$output

## End(Not run)

# You can also retransform the scaled dataset back using"inverse_scaling". An
# example to rescale : "X_scaled" into "X"using the saved model "input_model"
# is:

## Not run: 
output <- preprocess_scale(input=X_scaled, inverse_scaling=TRUE,
  input_model=saved)
X <- output$output

## End(Not run)

# Another simple example where we want to scale the dataset "X" into
# "X_scaled" with  min_max_scaler as scaler method, where scaling range is 1
# to 3 instead of default 0 to 1. We could run 

## Not run: 
output <- preprocess_scale(input=X, scaler_method="min_max_scaler",
  min_value=1, max_value=3)
X_scaled <- output$output

## End(Not run)

mlpack documentation built on June 22, 2024, 9:36 a.m.