Teradata Package for Python Function Reference - AdaBoostPredict - 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.mle.AdaBoostPredict = class AdaBoostPredict(builtins.object)
     Methods defined here:
__init__(self, object=None, newdata=None, attr_groupby_columns=None, attr_pid_columns=None, attr_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)
DESCRIPTION:
    The AdaBoostPredict function applies the model output by the
    AdaBoost function to a new data set, outputting predicted labels for each data point.
 
 
PARAMETERS:
    object:
        Required Argument.
        Specifies the name of the teradataml DataFrame containing the output
        model from AdaBoost or instance of AdaBoost.
 
    newdata:
        Required Argument.
        Specifies the name of the teradataml DataFrame containing the
        attribute names and the values of test data.
 
    newdata_partition_column:
        Required Argument.
        Specifies Partition By columns for newdata.
        Values to this argument can be provided as list, if multiple columns
        are used for partition.
        Required when there are more than one data point identifiers in newdata.
        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 list, if multiple columns
        are used for ordering.
        Types: str OR list of Strings (str)
 
    attr_groupby_columns:
        Required Argument.
        Specifies the names of the columns on which the attribute teradataml
        DataFrame is partitioned.
        Types: str
 
    attr_pid_columns:
        Required Argument.
        Specifies the names of the attribute teradataml DataFrame columns
        that contain the data point identifiers.
        Types: str OR list of Strings (str)
 
    attr_val_column:
        Required Argument.
        Specifies the name of the attribute teradataml DataFrame column that
        contains the data point values.
        Types: str
 
    output_response_probdist:
        Optional Argument.
        Specifies whether to output probabilities.
        It can be set to True only when the Adaboost function call used 
        to generate the model had output_response_probdist = True.
        Note: With Vantage version prior to 1.1.1, when this argument is 
              set to True, need to specify output_responses also.
        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.
        Specifies all responses in input teradataml DataFrame.
        This can be used only when both the AdaBoostPredict function, 
        and the Adaboost function call used to generate the model, use(d) 
        output_response_probdist = True.
        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 AdaBoostPredict.
    Output teradataml DataFrames can be accessed using attribute
    references, such as AdaBoostPredictObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load example data.
    load_example_data("adaboost", ["housing_train", "housing_cat", "housing_train_response", "iris_attribute_train", "iris_response_train"])
    load_example_data("adaboostpredict", ["housing_test", "iris_attribute_test"])
 
    # Create teradataml DataFrame objects.
    housing_train = DataFrame.from_table("housing_train")
    housing_cat = DataFrame.from_table("housing_cat")
    housing_train_response = DataFrame.from_table("housing_train_response")
    iris_attribute_train =  DataFrame.from_table("iris_attribute_train")
    iris_response_train = DataFrame.from_table("iris_response_train")
 
    housing_test = DataFrame.from_table("housing_test")
    iris_attribute_test = DataFrame.from_table("iris_attribute_test")
 
    # Example 1 -
    # Here, we will try to predict the 'homestyle' for the data points in the test data (housing_test)
    # based on the model generated using AdaBoost functions Example #1.
    #
    # First, we will have to run AdaBoost on the input in sparse format.
    # We run Unpivot to be create the input in Sparse format.
    unpivot_out_1 = Unpivot(data=housing_train,
                            unpivot = ["price", "lotsize", "bedrooms", "bathrms", "stories","driveway", "recroom", "fullbase", "gashw", "airco", "garagepl", "prefarea"],
                            accumulate = ["sn"])
 
    AdaBoost_out_1 = AdaBoost(attribute_data = unpivot_out_1.result,
                              attribute_name_columns = ["attribute"],
                              attribute_value_column = "value_col",
                              categorical_attribute_data = housing_cat,
                              response_data = housing_train_response,
                              id_columns = ["sn"],
                              response_column = "response",
                              iter_num = 2,
                              num_splits = 10,
                              max_depth = 3,
                              min_node_size = 100
                              )
 
    # Use the generated model to predict the house style, on the test data.
    # But we need to transform that too into sparse format
    unpivot_out_2 = Unpivot(data=housing_test,
                            unpivot = ["price", "lotsize", "bedrooms", "bathrms", "stories","driveway", "recroom", "fullbase", "gashw", "airco", "garagepl", "prefarea"],
                            accumulate = ["sn"])
 
    AdaBoostPredict_out_1 = AdaBoostPredict(object = AdaBoost_out_1.model_table,
                                            newdata = unpivot_out_2.result,
                                            newdata_partition_column = ["sn"],
                                            attr_groupby_columns = "attribute",
                                            attr_pid_columns = ["sn"],
                                            attr_val_column = "value_col"
                                            )
 
    # Print the results
    print(AdaBoostPredict_out_1)
 
    # Example 2 -
    # In this example, we will try to predict the 'species' for the flowers represented by the data points in the test data (iris_attribute_test)
    # based on the model generated using AdaBoost functions Example #2.
    #
    # First, we will have to run AdaBoost on the input (which is already in sparse format).
    AdaBoost_out_2 = AdaBoost(attribute_data = iris_attribute_train,
                              attribute_name_columns = ["attribute"],
                              attribute_value_column = "attrvalue",
                              response_data = iris_response_train,
                              id_columns = ["pid"],
                              response_column = "response",
                              iter_num = 3,
                              num_splits = 10,
                              approx_splits = False,
                              max_depth = 3,
                              min_node_size = 5,
                              output_response_probdist = True
                              )
 
    # Use the generated model to predict the species, on the test data which is already in the sparse format.
    AdaBoostPredict_out_2 = AdaBoostPredict(object = AdaBoost_out_2.model_table,
                                            newdata = iris_attribute_test,
                                            newdata_partition_column = ["pid"],
                                            attr_groupby_columns = "attribute",
                                            attr_pid_columns = ["pid"],
                                            attr_val_column = "attrvalue",
                                            output_response_probdist = True,
                                            output_responses = ['          1','          2','          3']
                                            )
 
    # Print the results
    print(AdaBoostPredict_out_2)
__repr__(self)
Returns the string representation for a AdaBoostPredict 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.