Teradata Package for Python Function Reference - LinReg - 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.LinReg = class LinReg(builtins.object)
     Methods defined here:
__init__(self, formula=None, data=None, target_column=None, data_sequence_column=None, data_order_column=None)
DESCRIPTION:
    The Linear Regression function is composed of the functions LinReg
    and LinRegInternal. LinRegInternal takes a data set and outputs a linear
    regression model. LinReg takes the linear regression model and
    outputs its coefficients. One of the output model coefficient corresponds to
    the slope intercept. The function ignores input rows with NULL values.
 
 
PARAMETERS:
    formula:
        Optional Argument.
        A string consisting of "formula". Specifies the model to be fitted.
        Only basic formula of the "col1 ~ col2 + col3 +..." form is
        supported and all dependent and independent variables must be from the same
        teradataml DataFrame object. Specifying the independent variables is optional, in
        which case the formula should be specified in the following format
        (col1 ~ .). When the independent variables are specified using a dot
        (.) symbol, then all columns in the input teradataml DataFrame other than the
        column specifying the dependent variable is used for prediction.
 
    data:
        Required Argument.
        Specifes the input teradataml DataFrame that contains one row for each data point and one
        column for each data point component.
 
    data_order_column:
        Optional Argument.
        Specifies Order By columns for data.
        Values to this argument can be provided as a list, if multiple
        columns are used for ordering.
        Types: str OR list of Strings (str)
 
    target_column:
        Optional Argument.
        Specifies the column containing the target variable.
        Types: str
 
    data_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "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 LinReg.
    Output teradataml DataFrames can be accessed using attribute
    references, such as LinRegObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load example data.
    load_example_data("linreg", "housing_data")
 
    # Create teradataml DataFrame objects.
    housing_data = DataFrame.from_table("housing_data")
 
    # Example 1 - This example uses the Linear Regression function
    # to find the coefficients of the independent variables that
    # determine the selling price of a home in a given neighborhood.
    lin_reg_out = LinReg(data = housing_data,
                          formula = 'sellingprice ~ housesize + lotsize + bedrooms + granite + upgradedbathroom')
 
    # Print the result DataFrame
    print(lin_reg_out)
__repr__(self)
Returns the string representation for a LinReg 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.