Description
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.
Note:
Object of this class is passed to "sigmoid" argument of
td_transform_valib()
.
Usage
tdSigmoid(columns=NULL, style="logit", datatype=NULL, fillna=NULL)
Arguments
columns |
Optional Argument. | ||||||||||||||||||||||||||||||||||||
style |
Optional Argument.
Default Value: 'logit' | ||||||||||||||||||||||||||||||||||||
datatype |
Optional Argument.
Notes:
Examples:
Types: character | ||||||||||||||||||||||||||||||||||||
fillna |
Optional Argument.
Types: tdFillNa |
Value
An object of tdSigmoid class.
Examples
# 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")
sales
iris_test <- tbl(con,"iris_test")
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")
obj$result
# 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",
"sepal_width"="sw",
"petal_length"="pl",
"petal_width"="pw"))
# 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",
"sepal_width"="sw_t",
"petal_length"="pl_t",
"petal_width"="pw_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"),
fillna=fn)
# Perform the sigmoid transformation using td_transform_valib() function.
obj <- td_transform_valib(data=iris_test,
sigmoid=c(sig_1, sig_2, sig_3),
key.columns="id")
obj$result