Teradata Package for Python Function Reference | 17.10 - LinRegPredict - 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.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
lifecycle
previous
Product Category
Teradata Vantage

 
teradataml.analytics.mle.LinRegPredict = class LinRegPredict(builtins.object)
     Methods defined here:
__init__(self, object=None, newdata=None, accumulate=None, input_columns=None, newdata_sequence_column=None, object_sequence_column=None, newdata_order_column=None, object_order_column=None)
DESCRIPTION:
    The LinRegPredict function takes a model built by the LinReg
    function and a test data set whose input attributes are
    the same as those in the model, and predicts the response variable
    for each observation in the test data set.
 
 
PARAMETERS:
    object:
        Required Argument.
        Specifies the teradataml DataFrame containing the model
        data generated by LinReg or instance of LinReg,
        which contains the model.
 
    object_order_column:
        Optional Argument.
        Specifies Order By columns for object.
        Values to this argument can be provided as list, if multiple columns
        are used for ordering.
        Types: str OR list of Strings (str)
 
    newdata:
        Required Argument.
        Specifies the teradataml DataFrame containing the input test data.
 
    newdata_order_column:
        Optional Argument.
        Specifies Order By columns for newdata.
        Values to this argument can be provided as list, if multiple columns
        are used for ordering.
        Types: str OR list of Strings (str)
 
    accumulate:
        Optional Argument.
        Specifies the names of input teradataml DataFrame columns to copy to
        the output TeradataMl DataFrame.
        Types: str OR list of Strings (str)
 
    input_columns:
        Optional Argument.
        Specifies the names of the input teradataml DataFrame columns that
        contain the input variables.
        Types: str OR list of Strings (str)
 
    newdata_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "newdata". 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)
 
    object_sequence_column:
        Optional Argument.
        Specifies the list of column(s) that uniquely identifies each row of
        the input argument "object". 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 LinRegPredict.
    Output teradataml DataFrames can be accessed using attribute
    references, such as LinRegPredictObj.<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")
 
    # Build a linear regression model on the input data
    lin_reg_out = LinReg(data = housing_data,
                          formula = 'sellingprice ~ housesize + lotsize + bedrooms + granite + upgradedbathroom')
 
    # Example 1 - This example uses the above linear regression model to
    # make the predictions.
    linreg_predict_out = LinRegPredict(object = lin_reg_out,
                                      newdata = housing_data,
                                      accumulate = ["housesize","lotsize","bedrooms","granite","upgradedbathroom"]
                                     )
    # Print the result DataFrame
    print(linreg_predict_out)
 
 
    # Example 2 - Use the table by persisting LinReg model generated.
    # Persist the model table generated by the LinReg function.
    copy_to_sql(lin_reg_out.result, "lin_reg_model")
 
    # Create teradataml DataFrame objects.
    lin_reg_model = DataFrame.from_table("lin_reg_model")
 
    linreg_predict_out2 = LinRegPredict(object = lin_reg_model,
                                      newdata = housing_data,
                                      accumulate = ["housesize","lotsize","bedrooms","granite","upgradedbathroom"]
                                     )
 
    # Print the result DataFrame
    print(linreg_predict_out2.result)
__repr__(self)
Returns the string representation for a LinRegPredict 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.