OneHotEncodingTransform
Description
Function encodes specified attributes and categorical values as one-hot numeric vectors,
using td_one_hot_encoding_fit_sqle()
function output.
Usage
td_one_hot_encoding_transform_sqle (
data = NULL,
object = NULL,
is.input.dense = NULL,
...
)
Arguments
data |
Required Argument. |
object |
Required Argument. |
is.input.dense |
Required Argument. |
... |
Specifies the generic keyword arguments SQLE functions accept. 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_one_hot_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_data <- tbl(con, "titanic")
# Check the list of available analytic functions.
display_analytic_functions()
# Example 1: Transform categorical column "sex" to numerical columns "sex_male", "sex_female",
# and "sex_other" using td_one_hot_encoding_fit_sqle()
# and td_one_hot_encoding_transform_sqle().
# Generate fit object for column "sex".
fit_obj <- td_one_hot_encoding_fit_sqle(
data=titanic_data,
is.input.dense=TRUE,
target.column="sex",
categorical.values=c("male", "female"),
other.column="other")
# Print the result.
print(fit_obj$result)
# Encode "male" and "female" values of column "sex".
# Note that tbl_teradata representing the model is passed as
# input to "object".
obj <- td_one_hot_encoding_transform_sqle(
data=titanic_data,
object=fit_obj$result,
is.input.dense=TRUE)
# Print the result.
print(obj$result)
# Example 2: Encode "male" and "female" values of column "sex".
# Note that model is passed as instance of td_one_hot_encoding_fit_sqle
# to "object".
obj1 <- td_one_hot_encoding_transform_sqle(
data=titanic_data,
object=fit_obj,
is.input.dense=TRUE)
# Print the result.
print(obj1$result)
# Alternatively use S3 transform function to run transform on the output of
# td_fit_sqle() function.
obj1 <- transform(fit_obj,
data=titanic_data,
is.input.dense=TRUE)
# Print the result.
print(obj1$result)