Teradata Package for Python Function Reference - LogRegPredict - 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
 
 
LogRegPredict

 
Functions
       
LogRegPredict(data, model, estimate_column=None, index_columns=None, prob_column=None, accumulate=None, prob_threshold=0.5)
DESCRIPTION:
    Logistic Regression function model can be passed to a Logistic Regression Scoring
    function to create a score output containing predicted values of the dependent variable.
    
PARAMETERS:
    data:
        Required Argument.
        Specifies the input data to score.
        Types: teradataml DataFrame
    
    model:
        Required Argument.
        Specifies the input containing the logistic model to use in scoring. This must
        be the "model" teradataml DataFrame generated by LogReg() function from VALIB or
        a teradataml DataFrame created on a table generated by 'logistic' function from
        Vantage Analytic Library.
        Types: teradataml DataFrame
    
    estimate_column:
        Required Argument.
        Specifies the name of a column in the score output containing the estimated value
        of the dependent variable (column).
        Notes:
            1. Either "estimate_column" or "prob_column" must be requested.
            2. If the estimate column is not unique in the score output, '_tm_' is
               automatically placed in front of the name.
        Types: str
    
    index_columns:
        Optional Argument.
        Specifies the name(s) of the column(s) representing the primary index of the
        score output. By default, the primary index columns of the score output are the
        primary index columns of the input. In addition, the index columns need to form
        a unique key for the score output. Otherwise, there are more than one score for
        a given observation.
        Types: str OR list of Strings (str)
    
    prob_column:
        Optional Argument.
        Specifies the name of a column in the score output containing the probability
        that the dependent value is equal to the response value.
        Notes:
            1. Either "estimate_column" or "prob_column" must be requested.
            2. If the probability column is not unique in the score output, '_tm_' is
               automatically placed in front of the name.
        Types: str
    
    accumulate:
        Optional Argument.
        Specifies the name(s) of the column(s) from the input to retain in the output.
        Types: str OR list of Strings (str)
    
    prob_threshold:
        Optional Argument.
        Specifies the probability threshold value. When the probability of the dependent
        variable being 1 is greater than or equal to this value, the estimated value of
        the dependent variable is 1. If less than this value, the estimated value is 0.
        Default Value: 0.5
        Types: float, int
    
RETURNS:
    An instance of LogRegPredict.
    Output teradataml DataFrames can be accessed using attribute references, such as 
    LogRegPredictObj.<attribute_name>.
    Output teradataml DataFrame attribute name is: result
    
RAISES:
    TeradataMlException, TypeError, ValueError
    
EXAMPLES:
    # Notes:
    #   1. To execute Vantage Analytic Library functions,
    #       a. import "valib" object from teradataml.
    #       b. set 'configure.val_install_location' to the database name where Vantage 
    #          analytic library functions are installed.
    #   2. Datasets used in these examples can be loaded using Vantage Analytic Library 
    #      installer.
    # Import valib object from teradataml to execute this function.
    from teradataml import valib
 
    # Set the 'configure.val_install_location' variable.
    from teradataml import configure
    configure.val_install_location = "SYSLIB"
 
    # Create required teradataml DataFrame.
    df = DataFrame("customer")
    print(df)
    
    # Example 1: Shows how logistic model scoring can be performed.
    # Generate a logistic model.
    log_reg_obj = valib.LogReg(data=df,
                               columns=["age", "years_with_bank", "income"],
                               response_column="nbr_children",
                               response_value=0)
 
    # Print the model.
    print(log_reg_obj.model)
 
    # Score using the model generated above.
    obj = valib.LogRegPredict(data=df,
                              model=log_reg_obj.model,
                              prob_column="Probability")
 
    # Print the results.
    print(obj.result)