Teradata Package for Python Function Reference on VantageCloud Lake - GLMPredict - 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 on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
20.00.00.03
Published
December 2024
ft:locale
en-US
ft:lastEdition
2024-12-19
dita:id
TeradataPython_FxRef_Lake_2000
Product Category
Teradata Vantage
 
 
GLMPredict

 
Functions
       
GLMPredict(modeldata=None, newdata=None, terms=None, family=None, linkfunction='CANONICAL', output_prob=False, output_responses=None, **generic_arguments)
DESCRIPTION:
The GLMPredict() function uses the model generated by the function GLM()
to perform generalized linear model prediction on new input data.
 
Note:
    * The GLMPredict() function accepts models from the GLM() function in MLE,
      whereas the TDGLMPredict() function accepts models from GLM() function in SQLE.
 
 
PARAMETERS:
    modeldata:
        Required Argument.
        Specifies the teradataml DataFrame containing the model data
        generated by GLM() function or an instance of GLM.
        Types: teradataml DataFrame or GLM
 
    newdata:
        Required Argument.
        Specifies the teradataml DataFrame containing the input data.
        Types: teradataml DataFrame
 
    terms:
        Optional Argument.
        Specifies the names of newdata columns to copy to the output
        teradataml DataFrame.
        Types: str OR list of Strings (str)
 
    family:
        Optional Argument.
        Specifies the distribution exponential family. The default value is
        read from modeldata. If you specify this argument, you must give it
        the same value that you used for the Family argument of the function
        when you generated the model.
        Permitted Values: LOGISTIC, BINOMIAL, POISSON, GAUSSIAN, GAMMA,
        INVERSE_GAUSSIAN, NEGATIVE_BINOMIAL
        Types: str
 
    linkfunction:
        Optional Argument.
        The canonical link functions (default link functions) and the link
        functions that are allowed for each exponential family.
        Note:
            Use the same value that you used for the Link argument of the
            function  when you generated the model.
        Default Value: "CANONICAL"
        Permitted Values: CANONICAL, IDENTITY, INVERSE, LOG,
        COMPLEMENTARY_LOG_LOG, SQUARE_ROOT, INVERSE_MU_SQUARED, LOGIT,
        PROBIT, CAUCHIT
        Types: str
 
    output_prob:
        Optional Argument.
        Specifies whether to output probabilities.
        Default Value: False
        Types: bool
 
    output_responses:
        Optional Argument.
        Specifies responses for which to output probabilities.
        Types: str OR list of strs
 
    **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 GLMPredict.
    Output teradataml DataFrames can be accessed using attribute
    references, such as GLMPredictObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
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 data to run the example.
    load_example_data("GLMPredict", "admissions_test")
    load_example_data("teradataml", "glm_admissions_model")
 
    # Create teradataml DataFrame objects.
    admissions_test = DataFrame.from_table("admissions_test")
 
    # Create teradataml DataFrame object for model data.
    glm_admissions_model = DataFrame.from_table("glm_admissions_model")
 
    # Check the list of available analytic functions.
    display_analytic_functions()
 
    # Example 1: Predicting if student is admitted or not with probabilities of
    #            the both the responses. Response '1' means admitted and '0' means
    #            not admitted.
    obj = teradataml.GLMPredict(modeldata = glm_admissions_model,
                                newdata = admissions_test,
                                newdata_order_column="id",
                                modeldata_order_column=["attribute", "predictor"],
                                family="LOGISTIC",
                                terms=["id", "masters", "gpa", "stats", "programming", "admitted"],
                                linkfunction="CANONICAL",
                                output_prob=True,
                                output_responses=["1", "0"])
 
    # Print the result DataFrame.
    print(obj.result)