preprocess_scale: Scale Data

Description Usage Arguments Details Value Author(s) Examples

View source: R/preprocess_scale.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
preprocess_scale(
  input,
  epsilon = NA,
  input_model = NA,
  inverse_scaling = FALSE,
  max_value = NA,
  min_value = NA,
  scaler_method = NA,
  seed = NA,
  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 "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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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 Dec. 19, 2020, 1:06 a.m.