BincodeTransform
Description
The td_bincode_transform_sqle()
function is used to convert the continuous numeric data to
categorical data. The td_bincode_transform_sqle()
function takes the output of td_bincode_fit_sqle()
function to apply the transform on input tbl_teradata.
td_bincode_transform_sqle()
function takes two tbl_teradata objects as input:
Input tbl_teradata which contains numeric data to be converted to categorical data.
Output of
td_bincode_fit_sqle()
function which contains the binning data.
Usage
td_bincode_transform_sqle(
data = NULL,
object = NULL,
accumulate = NULL,
...
)
Arguments
data |
Required Argument. |
object |
Required Argument. |
accumulate |
Optional Argument. |
... |
Specifies the generic keyword arguments SQLE functions accept.
Below are the generic keyword arguments: persist: volatile: Function allows the user to partition, hash, order or local order the input data. These generic arguments are available for each argument that accepts tbl_teradata as input and can be accessed as:
Note: |
Value
Function returns an object of class "td_bincode_transform_sqle"
which is a named list containing object of class "tbl_teradata".
Named list member(s) can be referenced directly with the "$" operator
using the name(s):result
Examples
# Get the current context/connection.
con <- td_get_context()$connection
# Load the example data.
loadExampleData("tdplyr_example", "titanic", "bin_fit_ip")
# Create tbl_teradata object.
titanic_data <- tbl(con, "titanic")
bin_fit_ip <- tbl(con, "bin_fit_ip")
# Check the list of available analytic functions.
display_analytic_functions()
# Example 1: Convert the continuous numeric data in the column 'age' to
# categorical data.
# First generate a model using td_bincode_fit_sqle() function to bin-code the values
# in column 'age' using the 'Variable-Width' method type.
bin_code_1 <- td_bincode_fit_sqle(data=titanic_data,
fit.data=bin_fit_ip,
fit.data.order.column = c('minVal', 'maxVal'),
target.columns='age',
minvalue.column='minVal',
maxvalue.column='maxVal',
label.column='label',
method.type='Variable-Width',
label.prefix='label_prefix'
)
# Apply the transformation on the input data using the model generated above.
# Note the model is passed as a tbl_teradata.
obj <- td_bincode_transform_sqle(data=titanic_data,
object=bin_code_1$result,
object.order.column="TD_MinValue_BINFIT",
accumulate=c('passenger', 'ticket')
)
# Print the result.
print(obj$result)
# Example 2: Convert the continuous numeric data in the column 'age' to
# categorical data.
# First generate a model using td_bincode_fit_sqle() function to bin-code the values
# in column 'age' using the 'Equal-Width' method type.
bin_code_2 <- td_bincode_fit_sqle(data=titanic_data,
target.columns='age',
method.type='Equal-Width',
nbins=2,
label.prefix='label_prefix'
)
# Apply the transformation on the input data using the model generated above.
# Note that model is passed as an instance of td_bincode_fit_sqle to "object".
obj <- td_bincode_transform_sqle(data=titanic_data,
object=bin_code_2$result,
accumulate=c('passenger', 'ticket')
)
# Print the result.
print(obj$result)
# Alternatively use S3 transform function to run transform on the output of
# td_bincode_fit_sqle() function.
obj <- transform(bin_code_2,
data=titanic_data,
accumulate=c('passenger', 'ticket')
)
# Print the result.
print(obj$result)