Teradata Package for Python Function Reference - 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.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.sqle.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_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.
 
 
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 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: 'output_response_probdist' argument can accept input value True
              only when teradataml is connected to Vantage 1.0 Maintenance
              Update 2 version or later.
        Default Value: False
        Types: bool
 
    accumulate:
        Optional Argument.
        Specifies the names of newdata columns to copy to the output
        teradataml DataFrame.
        Types: str OR list of Strings (str)
 
    output_responses:
        Optional Argument.
        Required if output_response_probdist is True.
        Specifies all responses in newdata.
        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 -
    # First train the data, i.e., create a decision tree Model
    td_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",
                                         output_response_probdist = False)
 
    # Run predict on the output of decision tree
    decision_tree_predict_out = DecisionTreePredict(newdata=iris_attribute_test,
                                                    newdata_partition_column='pid',
                                                    object=td_decision_tree_out,
                                                    attr_table_groupby_columns='attribute',
                                                    attr_table_pid_columns='pid',
                                                    attr_table_val_column='attrvalue',
                                                    accumulate='pid',
                                                    output_response_probdist=False,
                                                    output_responses=['pid','attribute'])
 
    # Print output dataframes
    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.