Teradata Package for R Function Reference | 17.00 - 17.00 - tdSigmoid - Teradata Package for R

Teradata® Package for R Function Reference

Teradata Package for R
Release Number
July 2021
Last Update
August 2022
Content Type
Programming Reference
Publication ID
English (United States)
Last Update


tdSigmoid() allows rescaling of continuous numeric data in a more sophisticated way than the Rescaling transformation function. In a Sigmoid transformation, a numeric column is transformed using a type of sigmoid or s-shaped function.
These non-linear transformations are more useful in data mining than a linear Rescaling transformation. The Sigmoid transformation is supported for numeric columns only.
For absolute values of x greater than or equal to 36, the value of the sigmoid function is effectively 1 for positive arguments or 0 for negative arguments, within about 15 digits of significance.

  • Object of this class is passed to "sigmoid" argument of td_transform_valib().


tdSigmoid(columns=NULL, style="logit", datatype=NULL, fillna=NULL)



Optional Argument.
Specifies name(s) of column(s) containing the input and output column names, where key is the name of the column to perform transformation on and value contains the name of the transformed output column. When only key is specified then output column name is the name of input column.
Types: character OR list of Strings (character)


Optional Argument.
Specifies the style of sigmoid function to use.
Permitted Values:

  • 'logit': The logit function produces a continuously increasing value between 0 and 1.

  • 'modifiedlogit': The modified logit function is twice the logit minus 1 and produces a value between -1 and 1.

  • 'tanh': The hyperbolic tangent function also produces a value between -1 and 1.

Default Value: 'logit'
Types: character


Optional Argument.
Specifies the name of the intended datatype of the output column.
Intended data types for the output column can be specified using the permitted strings below:

------------------------------------ ---------------------------------------
If intended SQL Data Type is Permitted Value to be passed is
------------------------------------ ---------------------------------------
bigint bigint
byteint byteint
char(n) char,n
date date
decimal(m,n) decimal,m,n
float float
integer integer
number(*) number
number(n) number,n
number(*,n) number,*,n
number(n,n) number,n,n
smallint smallint
time(p) time,p
timestamp(p) timestamp,p
varchar(n) varchar,n


  1. Argument is ignored if "columns" argument is not used.

  2. char without a size is not supported.

  3. number(*) does not include the * in its datatype format.


  1. If intended datatype for the output column is "bigint", then pass string "bigint" to the argument as shown below:

  2. If intended datatype for the output column is "decimal(3,5)", then pass string "decimal,3,5" to the argument as shown below:

Types: character


Optional Argument.
Specifies whether the null replacement/missing value treatment should be performed with sigmoid transformation or not. Output of tdFillNa() can be passed to this argument.

  • If the tdFillNa object is created with its arguments "columns" and "datatype", then values passed in tdFillNa() arguments are ignored. Only nullstyle information is captured from the same.

Types: tdFillNa


An object of tdSigmoid class.


# Notes:
# 1. To run any transformation, user needs to use td_transform_valib()
#    function.
# 2. To do so set option 'val.install.location' to the database name
#    where Vantage analytic library functions are installed.

# Get the current context/connection.
con <- td_get_context()$connection

# Set the option 'val.install.location'.
options(val.install.location = "SYSLIB")

# Load example data.
loadExampleData("val_example", "sales", "iris_test")

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

iris_test <- tbl(con,"iris_test")

# Example 1: Scale values in columns 'Jan' and 'Mar' using sigmoid function
#            'tanh'.
#            Combine the scaling with null replacement.
fn <- tdFillNa(style="literal", value=0)
sig <- tdSigmoid(style="tanh", columns=list("Jan", "Mar"), fillna=fn)

# Perform the sigmoid transformation using td_transform_valib() function.
obj <- td_transform_valib(data=sales, sigmoid=sig, key.columns="accounts")

# Example 2: Rescaling with Sigmoid is carried out with multiple styles.
# Rescale values in columns 'sepal_length', 'sepal_width', 'petal_length'
# and 'petal_width' with 'logit' (default) sigmoid function.
sig_1 <- tdSigmoid(columns=list("sepal_length"="sl",
# Rescale values in columns 'sepal_length', 'sepal_width', 'petal_length'
# and 'petal_width' with 'tanh' sigmoid function.
sig_2 <- tdSigmoid(style="tanh", columns=list("sepal_length"="sl_t",

# Rescale values in columns 'sepal_length' and 'sepal_width' with
# 'modifiedlogit' sigmoid function. Combine it with null replacement using
# 'median' style.
fn <- tdFillNa(style="median")
sig_3 <- tdSigmoid(style="modifiedlogit",
                   columns=list("sepal_length"="sl_ml", "sepal_width"="sw_ml"),

# Perform the sigmoid transformation using td_transform_valib() function.
obj <- td_transform_valib(data=iris_test,
                          sigmoid=c(sig_1, sig_2, sig_3),