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

Teradata® Python Package Function Reference

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-07-17
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.sqle.GLMPredict = class GLMPredict(builtins.object)
     Methods defined here:
__init__(self, modeldata=None, newdata=None, terms=None, family=None, linkfunction='CANONICAL', newdata_order_column=None)
DESCRIPTION:
    The GLMPredict function uses the model generated by the function GLM
    to perform generalized linear model prediction on new input data.
 
 
PARAMETERS:
    modeldata:
        Required Argument.
        Specifies the teradataml DataFrame containing the model data
        or an instance of GLM.
 
    newdata:
        Required Argument.
        Specifies the teradataml DataFrame containing the input data.
 
    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)
 
    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
 
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:
    # Load the data to run the example.
    load_example_data("GLMPredict", ["admissions_test","admissions_train","housing_test","housing_train"])
 
    # Create teradataml DataFrame objects.
    admissions_test = DataFrame.from_table("admissions_test")
    admissions_train = DataFrame.from_table("admissions_train")
    housing_test = DataFrame.from_table("housing_test")
    housing_train = DataFrame.from_table("housing_train")
 
    # Example 1 -
    # First train the data, i.e., create a GLM Model
    glm_out = GLM(formula = "admitted ~ stats + masters + gpa + programming",
                 family = "LOGISTIC",
                 linkfunction = "LOGIT",
                 data = admissions_train,
                 weights = "1",
                 threshold = 0.01,
                 maxit = 25,
                 step = False,
                 intercept = True
                 )
 
    # Run predict on the output of GLM
    glm_predict_out1 = GLMPredict(modeldata = glm_out,
                                  newdata = admissions_test,
                                  terms = ["id","masters","gpa","stats","programming","admitted"],
                                  family = "LOGISTIC",
                                  linkfunction = "LOGIT"
                                  )
 
    # Print the results.
    print(glm_predict_out1.result)
 
    # Example 2 -
    # First train the data, i.e., create a GLM Model
    glm_out_hs = GLM(formula = "price ~ recroom + lotsize + stories + garagepl + gashw + bedrooms + driveway + airco + homestyle + bathrms + fullbase + prefarea",
                      family = "GAUSSIAN",
                      linkfunction = "IDENTITY",
                      data = housing_train,
                      weights = "1",
                      threshold = 0.01,
                      maxit = 25,
                      step = False,
                      intercept = True
                      )
 
    # Run predict on the output of GLM by passing coefficients
    glm_predict_out2 = GLMPredict(modeldata = glm_out_hs.coefficients,
                                  newdata = housing_test,
                                  terms = ["sn", "price"],
                                  family = "GAUSSIAN",
                                  linkfunction = "CANONICAL"
                                  )
 
    # Print the results.
    print(glm_predict_out2)
__repr__(self)
Returns the string representation for a GLMPredict class instance.