Using DataRobot Prime Models with AWS Lambda

Showing results for 
Search instead for 
Did you mean: 

Using DataRobot Prime Models with AWS Lambda

This article shows how you can use the DataRobot Prime Model functionality to download a DataRobot model and deploy it using AWS Lambda. This example is based on a hospital readmissions dataset, but it can be customized to fit your specific requirements and use cases.


DataRobot Prime can be initiated on most DataRobot models and allows you to download an approximation of a DataRobot model either as a Python or Java module. The code is then easily deployable in any environment and is not dependent on the DataRobot application.

Take a look at this other community article to learn more about DataRobot prime models and how to create and download one, as well as caveats and restrictions. For the purposes of this tutorial, we assume that you already have a DataRobot Prime model downloaded as a Java module.

Why deploy on AWS Lambda

While DataRobot provides its own scalable prediction servers that are fully integrated with the platform, there are multiple reasons why you may want to deploy on AWS Lambda:

  • Company policy or governance decision.
  • Serverless architecture
  • Cost reduction.
  • Custom functionality on top of the DataRobot model.
  • The ability to integrate models into systems that can’t necessarily communicate with the DataRobot API.

In addition, there are also some drawbacks:

  • No data drift and accuracy tracking out-of-the-box unless MLOps Agents are configured.
  • Additional time overhead resulting from deploying to AWS Sagemaker.

All in all, it is up to you and your use case to decide where you would want your model to be deployed;  DataRobot supports multiple integration options.

Set up

The first step to deploying a DataRobot Prime model is to rename the Java file. Your filename should be the same as the public class that in this file so rename *.java →

Then create/Import example project “lambda_prime_example” into the IDE of your choice and:

  1. Copy to Project in the file specified in Figure 1.

    Figure 1. Project file structureFigure 1. Project file structure
  2. Compile the package using the mvn package command.

  3. Click Create function to create a new AWS function.

    Figure 2. Create new functionFigure 2. Create new function

  4. Choose Java 11 to create Lambda.

    Figure 3. Programming Language menuFigure 3. Programming Language menu

  5. Give the function a name and choose permissions as shown in Figure 4.

    Figure 4. Basic Information pageFigure 4. Basic Information page

  6. Upload the compiled JAR file to Lambda.

    Figure 5. Function code menuFigure 5. Function code menu

  7. Change the Lambda handler to your Java package . method name to:

The setup is now complete. All that remains is to do some testing to see that the deployment is working as intended.

Testing the Lambda function

To test the Lambda function:

  1. Go to the TEST event configuration page.

    Figure 6. TEST event configurationFigure 6. TEST event configuration
  2. Put JSON with features as test event:
    Figure 7. JSON with FeaturesFigure 7. JSON with Features
  3. Click the Test button.

    Figure 8. Testing Lambda functionFigure 8. Testing Lambda function

You are all set. Now you can configure the integration with AWS API Gateway or other services so that data is sent to the Lambda function and you receive results back.

More information

Check out another community article, Exporting models with DataRobot Prime.

Labels (2)
Version history
Last update:
‎06-01-2020 07:26 AM
Updated by: