OrdinalEncodingTransform
Description
The td_ordinal_encoding_transform_sqle()
function maps the categorical value
to a specified ordinal value using the td_ordinal_encoding_fit_sqle()
function output.
Usage
td_ordinal_encoding_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_ordinal_encoding_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")
# Create tbl_teradata object.
titanic <- tbl(con, "titanic")
# Check the list of available analytic functions.
display_analytic_functions()
# Example 1: Transform the data by identifying distinct categorical
# values using input from td_ordinal_encoding_fit_sqle() function.
ordinal_encodingfit_res_1 <- td_ordinal_encoding_fit_sqle(
target.column='sex',
data=titanic)
ordinal_encoding_transform_out_1 <- td_ordinal_encoding_transform_sqle(
data=titanic,
object=
ordinal_encodingfit_res_1$result,
accumulate='age')
# Print the result.
print(ordinal_encoding_transform_out_1$result)
# Example 2: Transform the data by identifying distinct categorical values
# from the input and returns the distinct categorical values
# along with the ordinal value for each category.
ordinal_encodingfit_res_2 <- td_ordinal_encoding_fit_sqle(
target.column='sex',
approach='LIST',
categories=c('category0',
'category1'),
ordinal.values=c(1, 2),
start.value=0,
default.value=-1,
data=titanic)
ordinal_encoding_transform_out_2 <- td_ordinal_encoding_transform_sqle(
data=titanic,
object=
ordinal_encodingfit_res_2$result,
accumulate='age')
# Print the result.
print(ordinal_encoding_transform_out_2$result)
# Alternatively use S3 transform function to run transform on the output of
# td_ordinal_encoding_fit_sqle() function.
obj1 <- transform(ordinal_encodingfit_res_2,
data=titanic,
accumulate='age')
# Print the result.
print(obj1$result)