Model function commands¶
Model function commands allow you to see the functions (also called methods) of machine learning models.
You can create and manage models and their methods in Python using the Snowpark Model Registry API.
Calling model methods¶
You can call or invoke methods of a model using the model_name!method_name(...)
syntax. The methods
available on a model are determined by the underlying Python model class. For example, many types of models use a method
named predict
for inference.
Methods are attached to specific model versions. To invoke a method on the default version of a model, use the syntax shown below, passing arguments to the method, if any, between the parentheses, and providing the name of the table containing the inference data in the FROM clause.
SELECT <model_name>!<method_name>(...) FROM <table_name>;
To invoke a method of a specific version of a model, first create an alias to the specific version of the model using WITH, then invoke the desired function through the alias.
WITH <model_version_alias> AS MODEL <model_name> VERSION <version_or_alias_name>
SELECT <model_version_alias>!<method_name>(...) FROM <table_name>;
For example, to call the latest version of a model through the LAST alias:
WITH latest AS MODEL my_model VERSION LAST
SELECT latest!predict(...) FROM my_table;