Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - retrieve_model - 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 on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
17.20
Publication Date
November 2022
Content Type
Programming Reference
Publication ID
B700-4500-112K
ft:locale
en-US
ft:lastEdition
2024-02-21
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_1720
Product Category
Teradata Vantage
teradataml.catalog.model_cataloging.retrieve_model = retrieve_model(name)
DESCRIPTION:
    Function to retrieve a saved model accessible to the current user.
 
PARAMETERS:
    name:
        Required Argument.
        Specifies the name of the model to retrieve.
        Types: str
 
RETURNS:
    The Analytic function object corresponding to the model retrieved.
 
RAISES:
    TeradataMlException, TypeError, ValueError
 
EXAMPLES:
    # Load the data to run the example
    load_example_data("decisionforestpredict", ["housing_train","housing_test"])
 
    # Create teradataml DataFrame objects.
    housing_train = DataFrame.from_table("housing_train")
    housing_test = DataFrame.from_table("housing_test")
 
    # This example uses home sales data to create a
    # classification tree that predicts home style, which can be input
    # to the DecisionForestPredict.
    formula = "homestyle ~ driveway + recroom + fullbase + gashw + airco + prefarea + price + lotsize + bedrooms + bathrms + stories + garagepl"
    rft_model = DecisionForest(data=housing_train,
                               formula = formula,
                               tree_type="classification",
                               ntree=50,
                               tree_size=100,
                               nodesize=1,
                               variance=0.0,
                               max_depth=12,
                               maxnum_categorical=20,
                               mtry=3,
                               mtry_seed=100,
                               seed=100
                               )
 
    # Let's save this generated model.
    save_model(model=rft_model, name="decision_forest_model", description="Decision Forest test")
 
    # Retrieve the saved model.
    retrieved_rft_model = retrieve_model("decision_forest_model")
 
    # Use the retrieved model in predict.
    decision_forest_predict_out = DecisionForestPredict(object = retrieved_rft_model,
                                                        newdata = housing_test,
                                                        id_column = "sn",
                                                        detailed = False,
                                                        terms = ["homestyle"],
                                                        newdata_order_column=['sn', 'price'],
                                                        object_order_column=['worker_ip', 'task_index']
                                                       )
 
    # Print the results.
    decision_forest_predict_out.result