Skip to content

Click in-app to access the full platform documentation for your version of DataRobot.

Generate Snowflake UDF Scoring Code

Scoring Code makes it easy for you to perform predictions on DataRobot models anywhere you want, by exporting a model to a Java .jar file. Snowflake user defined functions (UDFs) allow you to execute arbitrary Java code on Snowflake. DataRobot provides an API to Scoring Code for you to use Scoring Code as a UDF on Snowflake without having to write any additional code.

To download and execute scoring code with Snowflake UDFs, you must meet the following prerequisites:

  • Prepare a DataRobot model that supports Scoring Code for deployment and create a model package with it.

  • Register your Snowflake prediction environment to use with the model.

Access Scoring Code

When you have your model package and prediction environment prepared in DataRobot, you can deploy the model in order to access the Scoring Code for use with Snowflake.

  1. Navigate to the Model Registry and select your model package. On the Deployments tab, select Create new deployment.

  2. Complete the fields and configure the deployment as desired. To generate Snowflake UDF Scoring Code, specify your Snowflake prediction environment under the Inference header.

  3. Once fully configured, select Create deployment at the top of the screen.

  4. After deploying the model, access the deployment from the inventory and navigate to the Predictions > Portable Predictions tab. This is where Datarobot hosts the Scoring Code for the model.

  5. Optionally, select the toggle if you want to include prediction explanations with the prediction results.

  6. Click Download. The Scoring Code JAR file should appear in your browser bar.

  7. When the download completes, you can configure and execute the installation script. The script uploads the .jar file to a Snowflake stage and creates a UDF for making predictions with Scoring Code. Modify the script template with the desired parameters for the Snowflake warehouse, database, schema, and JAR file location:

  8. Execute the script in SnowSQL by providing your credentials and the script location:

  9. With your UDF successfully created, you can now use Snowflake to score data. The snippet captured below is an example of how to load and score data. However, you can use this UDF in any manner supported by SQL, and can skip loading data if your data is already in Snowflake.

  10. After scoring data, you can upload actuals via the Settings tab in order to enable accuracy monitoring and more.


Updated September 2, 2021
Back to top