Teradata Package for Python Function Reference | 17.10 - DecisionTreePredict - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference

Product
Teradata Package for Python
Release Number
17.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.mle.DecisionTreePredict = class DecisionTreePredict(builtins.object)
     Methods defined here:
__init__(self, object=None, newdata=None, attr_table_groupby_columns=None, attr_table_pid_columns=None, attr_table_val_column=None, output_response_probdist=False, accumulate=None, output_responses=None, newdata_sequence_column=None, object_sequence_column=None, newdata_partition_column=None, newdata_order_column=None, object_order_column=None)
DESCRIPTION:
    The DecisionTreePredict function applies a tree model to a data input,
    outputting predicted labels for each data point.
 
    Note: This function is available only when teradataml is connected to
          Vantage 1.1 or later versions.
 
PARAMETERS:
    object:
        Required Argument.
        Specifies the name of the teradataml DataFrame containing the output
        model from DecisionTree or instance of DecisionTree.
 
    object_order_column:
        Optional Argument.
        Specifies Order By columns for object.
        Values to this argument can be provided as a list, if multiple columns
        are used for ordering.
        Types: str OR list of Strings (str)
 
    newdata:
        Required Argument.
        Specifies the name of the teradataml DataFrame containing the
        attribute names and the values.
 
    newdata_partition_column:
        Required Argument.
        Specifies Partition By columns for newdata.
        Values to this argument can be provided as a list, if multiple columns
        are used for partition.
        Types: str OR list of Strings (str)
 
    newdata_order_column:
        Optional Argument.
        Specifies Order By columns for newdata.
        Values to this argument can be provided as a list, if multiple columns
        are used for ordering.
        Types: str OR list of Strings (str)
 
    attr_table_groupby_columns:
        Required Argument.
        Specifies the names of the columns on which attribute "newdata" is
        partitioned. Each partition contains one attribute of the input data.
        Types: str OR list of Strings (str)
 
    attr_table_pid_columns:
        Required Argument.
        Specifies the names of the columns that define the data point
        identifiers.
        Types: str OR list of Strings (str)
 
    attr_table_val_column:
        Required Argument.
        Specifies the name of the column that contains the input values.
        Types: str
 
    output_response_probdist:
        Optional Argument.
        Specifies whether to output probabilities.
        Note:
            1. 'output_response_probdist' argument can accept input value True
               only when teradataml is connected to Vantage 1.0 Maintenance
               Update 2 version or later.
            2. 'output_response_probdist' can be set to True only when the
               DecisionTree function call used to generate the model had
               output_response_probdist = True.
        Default Value: False
        Types: bool
 
    accumulate:
        Optional Argument.
        Specifies the names of input teradataml DataFrame columns to copy to the output
        teradataML DataFrame.
        Types: str OR list of Strings (str)
 
    output_responses:
        Optional Argument.
        Specifies all responses in input teradataml DataFrame.
        This argument requires the output_response_probdist argument to be set to True.
        Types: str OR list of Strings (str)
 
    newdata_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "newdata". The argument is used to ensure
        deterministic results for functions which produce results that vary
        from run to run.
        Types: str OR list of Strings (str)
 
    object_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "object". The argument is used to ensure
        deterministic results for functions which produce results that vary
        from run to run.
        Types: str OR list of Strings (str)
 
RETURNS:
    Instance of DecisionTreePredict.
    Output teradataml DataFrames can be accessed using attribute
    references, such as DecisionTreePredictObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load the data to run the example.
    load_example_data("DecisionTreePredict", ["iris_attribute_train", "iris_response_train", "iris_attribute_test"])
 
    # Create teradataml DataFrame.
    iris_attribute_test = DataFrame.from_table("iris_attribute_test")
    iris_attribute_train = DataFrame.from_table("iris_attribute_train")
    iris_response_train = DataFrame.from_table("iris_response_train")
 
    # Example 1 -
    # We will try to predict the labels for each data point
    # by the tree model in the train data (iris_attribute_train).
    decision_tree_out  = DecisionTree(attribute_name_columns = 'attribute',
                                     attribute_value_column = 'attrvalue',
                                     id_columns = 'pid',
                                     attribute_table = iris_attribute_train,
                                     response_table = iris_response_train,
                                     response_column = 'response',
                                     approx_splits = True,
                                     nodesize = 100,
                                     max_depth = 5,
                                     weighted = False,
                                     split_measure = "gini")
 
    # Use the generated tree model to predict labels on the test data
    # iris_attribute_test by using decision_tree_out which is already
    # in the sparse format.
    decision_tree_predict_out = DecisionTreePredict(newdata=iris_attribute_test,
                                    newdata_partition_column='pid',
                                    object=decision_tree_out,
                                    attr_table_groupby_columns='attribute',
                                    attr_table_pid_columns='pid',
                                    attr_table_val_column='attrvalue',
                                    accumulate='attrvalue',
                                    newdata_sequence_column='pid',
                                    newdata_order_column=['pid','attribute']
                                    )
 
    # Print the result DataFrame
    print(decision_tree_predict_out.result)
__repr__(self)
Returns the string representation for a DecisionTreePredict class instance.
get_build_time(self)
Function to return the build time of the algorithm in seconds.
When model object is created using retrieve_model(), then the value returned is 
as saved in the Model Catalog.
get_prediction_type(self)
Function to return the Prediction type of the algorithm.
When model object is created using retrieve_model(), then the value returned is 
as saved in the Model Catalog.
get_target_column(self)
Function to return the Target Column of the algorithm.
When model object is created using retrieve_model(), then the value returned is 
as saved in the Model Catalog.
show_query(self)
Function to return the underlying SQL query.
When model object is created using retrieve_model(), then None is returned.