| |
- Transform(data=None, object=None, id_columns=None, **generic_arguments)
- DESCRIPTION:
The Transform() function applies numeric transformations to input columns,
using Fit() output.
PARAMETERS:
data:
Required Argument.
Specifies the input teradataml DataFrame.
Types: teradataml DataFrame
object:
Required Argument.
Specifies the teradataml DataFrame which contains the model data generated by
the Fit() function or instance of Fit.
Types: teradataml DataFrame or Fit
id_columns:
Optional Argument.
Specifies the input teradataml DataFrame numeric columns to exactly
copy to the output. By default, all numeric columns will be converted
to float.
Types: str OR list of Strings (str)
**generic_arguments:
Specifies the generic keyword arguments SQLE functions accept.
Below are the generic keyword arguments:
persist:
Optional Argument.
Specifies whether to persist the results of the function in a table or
not. When set to True, results are persisted in a table; otherwise,
results are garbage collected at the end of the session.
Default Value: False
Types: boolean
volatile:
Optional Argument.
Specifies whether to put the results of the function in a volatile table
or not. When set to True, results are stored in a volatile table,
otherwise not.
Default Value: False
Types: boolean
Function allows the user to partition, hash, order or local order the input
data. These generic arguments are available for each argument that accepts
teradataml DataFrame as input and can be accessed as:
* "<input_data_arg_name>_partition_column" accepts str or list of str (Strings)
* "<input_data_arg_name>_hash_column" accepts str or list of str (Strings)
* "<input_data_arg_name>_order_column" accepts str or list of str (Strings)
* "local_order_<input_data_arg_name>" accepts boolean
Note:
These generic arguments are supported by teradataml if the underlying
SQL Engine function supports, else an exception is raised.
RETURNS:
Instance of Transform.
Output teradataml DataFrames can be accessed using attribute
references, such as TransformObj.<attribute_name>.
Output teradataml DataFrame attribute name is:
result
RAISES:
TeradataMlException, TypeError, ValueError
EXAMPLES:
# Notes:
# 1. Get the connection to Vantage to execute the function.
# 2. One must import the required functions mentioned in
# the example from teradataml.
# 3. Function will raise error if not supported on the Vantage
# user is connected to.
# Load the example data.
load_example_data("teradataml", ["iris_input", "transformation_table"])
# Create teradataml DataFrame objects.
iris_input = DataFrame.from_table("iris_input")
transformation_df = DataFrame.from_table("transformation_table")
transformation_df = transformation_df.drop(['id'], axis=0)
# Check the list of available analytic functions.
display_analytic_functions()
# Example 1: Run Fit() with all arguments which will validate numeric
# transformations can be applied or not present in transformation_df DataFrame.
# and pass the output to Transform().
fit_df = Fit(data=iris_input,
object=transformation_df,
object_order_column='TargetColumn'
)
# Run Transform() with persist as True in order to save the result.
# Note that teradataml DataFrame representing the model is passed as
# input to "object".
transform_result = Transform(data=iris_input,
data_partition_column='sepal_length',
data_order_column='sepal_length',
object=fit_df.result,
object_order_column='TargetColumn',
id_columns=['species', 'id'],
persist=True
)
# Print the result DataFrame.
print(transform_result.result)
# Example 2: Transform the 'petal_length', 'sepal_length', 'petal_width',
# 'sepal_width' according to transformation_df DataFrame.
# Note that model is passed as instance of FIT to "object".
transform_result1 = Transform(data=iris_input,
data_partition_column='sepal_length',
data_order_column='sepal_length',
object=fit_df,
object_order_column='TargetColumn',
id_columns=['species', 'id'],
persist=True
)
# Print the result DataFrame.
print(transform_result1.result)
|