Teradata Package for Python Function Reference - LARPredict - 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.LARPredict = class LARPredict(builtins.object)
     Methods defined here:
__init__(self, object=None, newdata=None, mode='STEP', s=None, target_col=None, newdata_sequence_column=None, object_sequence_column=None, newdata_order_column=None, object_order_column=None)
DESCRIPTION:
    The LARPredict function takes new data and the model output by the
    function LAR and uses the predictors in the model to output
    predictions for the new data.
 
 
PARAMETERS:
    object:
        Required Argument.
        Specifies the output model teradataml DataFrame from LAR or
        instance of LAR, which contains the model for predict.
 
    object_order_column:
        Optional Argument.
        Specifies Order By columns for object.
        Values to this argument can be provided as a list, if multiple
        columns are used for ordering.
        Types: str OR list of Strings (str)
 
    newdata:
        Required Argument.
        Specifies the test data teradataml DataFrame for predict.
 
    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)
 
    mode:
        Optional Argument.
        Specifies the mode for the s argument:
            "STEP": The s argument indicates the steps corresponding
                    to the steps in the model generated by the LAR function.
                    The s argument can include any real values in [1, k],
                    where k is the maximum step in the model.
            "FRACTION": The s argument indicates the fractions of the L1 norm of
                        the coefficients against the maximum L1 norm. The maximum L1 norm is
                        that of the full OLS solution, which is the coefficients at the last
                        step. The s argument can include any real values in [0, 1].
            "NORM": The s argument indicates the L1 norm of the coefficients. The s
                    argument can include any real values in [0, max L1 norm]. For maximum
                    L1 norm, see above.
            "LAMBDA": The s argument indicates the maximum absolute correlations.
                      For definition, the s argument can include any real values.
        Default Value: "STEP"
        Permitted Values: STEP, FRACTION, NORM, LAMBDA
        Types: str
 
    s:
        Optional Argument.
        Specifies the positions of the coefficients at which to generate
        predictions. Each coefficient is a different float value in the range
        specified by the mode argument.
        Types: float OR list of floats
 
    target_col:
        Optional Argument.
        Specifies the name of the response column in the input teradataml
        DataFrame (for prediction comparison). The sum-of-square error (SSE)
        for each prediction appears in the last row of the output teradataml DataFrame.
        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 LARPredict.
    Output teradataml DataFrames can be accessed using attribute
    references, such as LARPredictObj.<attribute_name>.
    Output teradataml DataFrame attribute name is:
        result
 
 
RAISES:
    TeradataMlException
 
 
EXAMPLES:
    # Load example data
    load_example_data("larpredict", ["diabetes", "diabetes_test"])
 
    # Create teradataml DataFrame objects.
    diabetes = DataFrame.from_table("diabetes")
    diabetes_test = DataFrame.from_table("diabetes_test")
 
    # Example 1 - Build a model using LAR and use it's output as direct input to LARPredict
    # Build a LAR model with response variable 'y' and ten baseline predictors.
    td_lar_out = LAR(formula = "y ~ hdl + glu + ldl + map1 + sex + tch + age + ltg + bmi + tc",
                 data = diabetes,
                 type = "LAR",
                 max_steps  = 20,
                 intercept = True
                 )
 
    # Example: Use the model object directly as input to the LARPredict function.
    lar_predict_out1 = LARPredict(object = td_lar_out,
                                 newdata = diabetes_test,
                                 mode = "step",
                                 s = 1.6,
                                 target_col = ["y"]
                                 )
 
    # Print the results
    print(lar_predict_out1)
 
    # Example 2 - Use the table from an already persisted LAR model.
    # Persist the model table generated by the LAR function.
    copy_to_sql(td_lar_out.output_table, "model_td_lar_out")
 
    # Create teradataml DataFrame objects.
    model_td_lar_out = DataFrame.from_table("model_td_lar_out")
 
    lar_predict_out2 = LARPredict(object = model_td_lar_out,
                                 newdata = diabetes_test,
                                 mode = "step",
                                 s = 1.6,
                                 target_col = ["y"]
                                 )
 
    # Print the results
    print(lar_predict_out2)
 
    # The prediction result can be persisted in a table - "result_td_lar_predict_out2".
    copy_to_sql(lar_predict_out2.result, table_name = "result_td_lar_predict_out2")
__repr__(self)
Returns the string representation for a LARPredict 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.