This article shows how you can use DataRobot’s Scoring Code functionality to download the scoring code of a model and then deploy it using AWS Lambda. This example is based on a hospital readmissions dataset but can be customized to fit your specific requirements and use cases.
DataRobot automatically runs code generation for those models that support it, and indicates code availability with an icon on the Leaderboard.
This option allows you to download validated Java scoring code for a predictive model without approximation; the code is easily deployable in any environment and is not dependent on the DataRobot application.
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 someone would want to deploy on AWS Lambda:
Company policy or governance decision.
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 this case, AWS Lambda can be used either as a primary means of scoring for fully offline systems or as a backend for systems that are using the DataRobot API.
In addition, there are some drawbacks to this as managing and monitoring externally deployed models requires DataRobot MLOps monitoring agents.
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.
Scoring Code Download
The first step to deploying a DataRobot model to AWS Lambda is to download the scoring code JAR file. Select the model from the Leaderboard, then select Predict > Downloads (Figure 1). Depending on your DataRobot license, the code might only be available through the Deployments page.
Figure 1. Downloads
Then, you need to either create your own or import the example project provided here into your IDE.
Figure 2. Lambda Scoring Project
In the pom.xml you need to change the path to the downloaded JAR file:
Figure 3. JAR path placeholder
Compiling the project
After you have successfully completed the above steps, it's time to finalize the setup and compile the project.
To start with, find this line in CodeGenLambdaExample.java file and impute with your model ID: