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

 
Functions
       
LinRegEvaluator(data, model)
DESCRIPTION:
    Linear regression model evaluation begins with scoring a DataFrame that includes the
    actual values of the dependent variable. The standard error of estimate for the model is
    calculated and reported and is compared to the standard error of estimate reported when
    the model was built. The standard error of estimate is calculated as the square root of
    the average squared residual value over all the observations (as shown below):
 
    standard error of estimate = sqrt( sum((y-y1)**2)/(n-p-1) ),
    where
        * y1 - the actual value of the dependent variable
        * y  - the predicted value
        * n  - the number of observations
        * p  - the number of independent variables (substituting n-p in the denominator if
               there is no constant term)
 
PARAMETERS:
    data:
        Required Argument.
        Specifies the input data to evaluate.
        Types: teradataml DataFrame
 
    model:
        Required Argument.
        Specifies the input containing the linear model to use in evaluation. This must be
        the "model" teradataml DataFrame generated by LinReg() function from VALIB or a
        teradataml DataFrame created on a table generated by 'linear' function from
        Vantage Analytic Library.
        Types: teradataml DataFrame
 
RETURNS:
    An instance of LinRegEvaluator.
    Output teradataml DataFrames can be accessed using attribute references, such as
    LinRegEvaluatorObj.<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 linear regression model evaluation is performed.
    # First generate the model using LinReg() function from 'valib'.
    lin_reg_obj = valib.LinReg(data=df,
                               columns=["age", "years_with_bank", "nbr_children"],
                               response_column="income")
 
    # Print the linear regression model.
    print(lin_reg_obj.model)
 
    # Evaluate the data using the linear regression model generated above.
    obj = valib.LinRegEvaluator(data=df,
                                model=lin_reg_obj.model)
 
    # Print the results.
    print(obj.result)