cancel
Showing results for 
Search instead for 
Did you mean: 

Snowflake UDF Jar Prediction with Explanation

Snowflake UDF Jar Prediction with Explanation

Hi,

 

I have a question about how to retrieve more than 3 explanations when I deploy the .jar model on Snowflake as a UDF.

 

What I have done is to call this handler in the udf

handler = 'com.datarobot.prediction.simple.ClassificationPredictor.scoreWithExplanations'

 

, however, by default, it only returned 3 explanations. I need 20 explanations.

 

Anybody can help? Thank you for your time and patience.

 

Best

Xu

Labels (3)
0 Kudos
1 Reply
jbaekdahl
DataRobot Employee
DataRobot Employee

Hi Xu,

 

scoreWithExplanations has a parameter that will let you customize the number of explanations which are returned.

 

You can create your UDF like this

CREATE OR REPLACE FUNCTION datarobot_deployment_628d25c5a05250cf6aed2f90(RowValue OBJECT, MaxCodes INTEGER, ThresholdLow FLOAT, ThresholdHigh FLOAT)
RETURNS OBJECT
LANGUAGE JAVA
IMPORTS=('@~/jars/628d25c5a05250cf6aed2f90-625e8e17eed2ffd50a04330d-pe.jar')
HANDLER='com.datarobot.prediction.simple.ClassificationPredictor.scoreWithExplanations';

 

and when scoring, specify 20 for the MaxCodes parameter:

SELECT datarobot_deployment_628d25c5a05250cf6aed2f90(OBJECT_CONSTRUCT_KEEP_NULL(*), 20, NULL, NULL)
FROM "input.csv"

 

You can find these code snippets in the Portable Predictions tab of a Snowflake deployment. Remember to enable "Include Prediction Explanations" to get the correct snippet.

See this page in the documentation for more info.

0 Kudos