Teradata Package for Python Function Reference - AdaBoost - 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.AdaBoost = class AdaBoost(builtins.object)
     Methods defined here:
__init__(self, attribute_data=None, attribute_name_columns=None, attribute_value_column=None, categorical_attribute_data=None, response_data=None, id_columns=None, response_column=None, iter_num=20, num_splits=10, approx_splits=True, split_measure='gini', max_depth=3, min_node_size=100, output_response_probdist=False, categorical_encoding='graycode', attribute_data_sequence_column=None, response_data_sequence_column=None, categorical_attribute_data_sequence_column=None)
DESCRIPTION:
    The AdaBoost function takes a training data set and a single
    decision tree and uses adaptive boosting to produce a strong classifying model
    that can be input to the function AdaBoostPredict.
 
 
PARAMETERS:
    attribute_data:
        Required Argument.
        Specifies the name of the teradataml DataFrame that contains the
        attributes and values of the data.
 
    attribute_name_columns:
        Required Argument.
        Specifies the names of attribute teradataml DataFrame columns that
        contain the data attributes.
        Types: str OR list of Strings (str)
 
    attribute_value_column:
        Required Argument.
        Specifies the names of attribute teradataml DataFrame columns that
        contain the data values.
        Types: str
 
    categorical_attribute_data:
        Optional Argument.
        Specifies the name of the teradataml DataFrame that contains the
        names of the categorical attributes.
 
    response_data:
        Required Argument.
        Specifies the name of the teradataml DataFrame that contains the
        responses (labels) of the data.
 
    id_columns:
        Required Argument.
        Specifies the names of the columns in the response and attribute
        teradataml DataFrames that specify the identifier of the instance.
        Types: str OR list of Strings (str)
 
    response_column:
        Required Argument.
        Specifies the name of the response teradataml DataFrame column that
        contains the responses (labels) of the data.
        Types: str
 
    iter_num:
        Optional Argument.
        Specifies the number of iterations to boost the weak classifiers,
        which is also the number of weak classifiers in the ensemble (T). The
        iterations must be an int in the range [2, 200].
        Default Value: 20
        Types: int
 
    num_splits:
        Optional Argument.
        Specifies the number of splits to try for each attribute in the node
        splitting.
        Default Value: 10
        Types: int
 
    approx_splits:
        Optional Argument.
        Specifies whether to use approximate percentiles.
        Default Value: True
        Types: bool
 
    split_measure:
        Optional Argument.
        Specifies the type of measure to use in node splitting.
        Default Value: "gini"
        Permitted Values: GINI, ENTROPY
        Types: str
 
    max_depth:
        Optional Argument.
        Specifies the maximum depth of the tree. The max_depth must be an int in
        the range [1, 10].
        Default Value: 3
        Types: int
 
    min_node_size:
        Optional Argument.
        Specifies the minimum size of any particular node within each
        decision tree.
        Default Value: 100
        Types: int
 
    output_response_probdist:
        Optional Argument.
        Specifies the value for the switch to enable/disable output of
        probability distribution for output labels.
        Default Value: False
        Types: bool
 
    categorical_encoding:
        Optional Argument.
        Specifies which encoding method is used for categorical variables.
        Note: categorical_encoding argument support is only available
              when teradataml is connected to Vantage 1.1 or later.
        Default Value: "graycode"
        Permitted Values: graycode, hashing
        Types: str
 
    attribute_data_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "attribute_data". 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)
 
    response_data_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "response_data". 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)
 
    categorical_attribute_data_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "categorical_attribute_data". 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 AdaBoost.
    Output teradataml DataFrames can be accessed using attribute
    references, such as AdaBoostObj.<attribute_name>.
    Output teradataml DataFrame attribute names are:
        1. model_table
        2. output
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load example data.
    load_example_data("adaboost", ["housing_train", "housing_cat", "housing_train_response", "iris_attribute_train", "iris_response_train"])
 
    # 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")
 
    # Example 1 -
    # This example uses home sales data to create a model that predicts home style when input to AdaBoostPredict.
 
    # Input description:
    # housing_train                (attribute_data) : teradataml DataFrame containing real estate sales data.
    #                                                 There are six numerical predictors and six categorical predictors.
    #                                                 The response variable is 'homestyle'.
    # housing_cat      (categorical_attribute_data) : teradataml DataFrame that lists all the categorical predictors.
    # housing_response              (response_data) : teradataml DataFrame that lists the responses for each instance
    #                                                 in 'attribute_data' as specified by 'id_columms'.
 
    # The attribute data (housing_train) needs to have the data in the sparse form where each attribute
    # and its corresponding value are specified in an individual row.
    unpivot_out = 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.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
                            )
 
    # Print the results
    print(AdaBoost_out_1.output)
    print(AdaBoost_out_1.model_table)
 
 
    # Example 2 -
    # This example uses the iris flower dataset to create a model that predicts the species when input to AdaBoostPredict.
 
    # Input description:
    # iris_attribute_train  (attribute_data) : teradataml DataFrame containing the iris flower dataset in the sparse format.
    # iris_response_train    (response_data) : teradataml DataFrame specifying the response variable for each instance
    #                                          in 'attribute_data' as specified by 'id_columms'.
 
    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
                            )
 
    # Print the results
    print(AdaBoost_out_2.output)
    print(AdaBoost_out_2.model_table)
__repr__(self)
Returns the string representation for a AdaBoost 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.