Teradata R Package Function Reference | 17.00 - 17.00 - ScaleByPartition - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
17.00
created_date
September 2020
category
Programming Reference
featnum
B700-4007-090K

Description

This ScaleByPartition function scales the sequences in each partition independently, using the same formula as the function Scale (td_scale_mle).

Usage

  td_scale_by_partition_mle (
    data = NULL,
    method = NULL,
    miss.value = "KEEP",
    input.columns = NULL,
    global = FALSE,
    accumulate = NULL,
    multiplier = 1,
    intercept = "0",
    data.sequence.column = NULL,
    data.partition.column = NULL,
    data.order.column = NULL
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata for scaling.

data.partition.column

Required Argument.
Specifies Partition By columns for "data".
Values to this argument can be provided as a vector, if multiple columns are used for partition.
Types: character OR vector of Strings (character)

data.order.column

Optional Argument.
Specifies Order By columns for "data". Values to this argument can be provided as a vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character)

method

Required Argument.
Specifies one or more statistical methods to use to scale the data set. For method values and descriptions. If you specify multiple methods, the output tbl_teradata includes the column scalemethod (which contains the method name) and a row for each input-row/method combination.
Permitted Values: MEAN, SUM, USTD, STD, RANGE, MIDRANGE, MAXABS.
Types: character OR vector of characters

miss.value

Optional Argument.
Specifies how the function processes NULL values in input.
To process NULL values in input, pass any permitted values which are as follows:

  1. KEEP : Keep NULL values.

  2. OMIT : Ignore any row that has a NULL value.

  3. ZERO : Replace each NULL value with zero.

  4. LOCATION : Replace each NULL value with its location value.

Default Value: "KEEP".
Permitted Values: KEEP, OMIT, ZERO, LOCATION.
Types: character

input.columns

Required Argument.
Specifies the input tbl_teradata columns that contain the attribute values of the samples. The attribute values must be numeric values between -1e308 and 1e308. If a value is outside this range, the function treats it as infinity.
Types: character OR vector of Strings (character)

global

Optional Argument. Specifies whether all input columns are scaled to the same location and scale.
Note: Each input column is scaled separately.
Default Value: FALSE
Types: logical

accumulate

Optional Argument. Specifies the input tbl_teradata columns to copy to the output tbl_teradata. By default, the function copies no input tbl_teradata columns to the output tbl_teradata.
Tip: To identify the sequences in the output, specify the partition columns in this argument.
Types: character OR vector of Strings (character)

multiplier

Optional Argument. Specifies one or more multiplying factors to apply to the input variables (multiplier in the following formula):
X' = intercept + multiplier * (X - location)/scale
If you specify only one multiplier, it applies to all columns specified in the "input.columns" argument. If you specify multiple multiplying factor, each multiplier applies to the corresponding input column. For example, the first multiplier applies to the first column specified in the "input.columns" argument, the second multiplier applies to the second input column, and so on.
Default Value: 1
Types: numeric OR vector of numerics

intercept

Optional Argument.
Specifies one or more addition factors incrementing the scaled results-intercept in the following formula:
X' = intercept + multiplier * (X - location)/scale
If you specify only one intercept, it applies to all columns specified in the "input.columns" argument. If you specify multiple addition factors, each intercept applies to the corresponding input column.
The syntax of intercept is: [-]number | min | mean | max
where min, mean, and max are the global minimum, mean values in the corresponding columns.
The function scales the values of min, mean, and max.
For example, if intercept is "- min" and multiplier is 1, the scaled result is transformed to a nonnegative sequence according to this formula, where scaledmin is the scaled value:
X' = -scaledmin + 1 * (X - location)/scale
Default Value: "0"
Types: character OR vector of characters

data.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "data". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

Value

Function returns an object of class "td_scale_by_partition_mle" which is a named list containing object of class "tbl_teradata".
Named list member can be referenced directly with the "$" operator using name: result.

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("scalemap_example", "scale_housing")

    # Create object(s) of class "tbl_teradata".
    scale_housing_input <- tbl(con, "scale_housing")

    # Create object(s) of class "tbl_teradata".
    # Example 1 - This function scales the sequences on partition cloumn 'lotsize' using
    # the same formula as the function td_scale_mle().
    td_scale_by_partition_out <- td_scale_by_partition_mle(data=scale_housing_input,
                                                       data.partition.column ="lotsize",
                                                       input.columns = c("id","price", "lotsize", 
                                                                         "bedrooms", "bathrms"),
                                                       method = c("maxabs"),
                                                       accumulate = c("types")
                                                      )