QuestionQ11

Train and use machine learning models

A Data Scientist has trained a model that is stored as a file on a Snowflake stage. They now want to score data in Snowflake using the model through a Python User-Defined Function (UDF).

One requirement is that they must be able to replace the model file with a newer one without needing to recreate the UDF.

What is required to accomplish this?

  • A Load the model file using the path to the model file including stage and file name in the UDF.
  • B Deploy the UDF using Snowpark for Python and use the trained model object in the UDF.
  • C Provide the path to the model file including stage and file name as a parameter to the function and load the file in the UDF.
  • D Add the path to the model file including stage and file name to the IMPORT parameter for the UDF and load the file in the UDF.
Explanation

A Python UDF can dynamically load a model directly from its staged path at execution time by using SnowflakeFile. Replacing the file at that same stage path lets subsequent executions use the new model without recreating the UDF. In contrast, a file listed in IMPORTS is copied into the UDF’s import directory during UDF creation, so it does not automatically reflect a later replacement of the staged file.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!