DataRobot provides sample Python code containing the commands and identifiers required to submit a CSV or JSON file for scoring. You can use this code with the DataRobot Prediction API.
To use the Prediction API Scripting Code, open the deployment you want to make predictions through and click Predictions > Prediction API. On the Prediction API Scripting Code page, you can choose from several scripts for Batch and Real-time predictions. Follow the sample provided and make the necessary changes when you want to integrate the model, via API, into your production application.
To find and access the script required for your use case, configure the following settings:
Determines the prediction method used. Select Batch.
2
Interface
Determines the interface type of the batch prediction script you generate. Select one of the following interfaces:
CLI: A standalone batch prediction script using the DataRobot API Client. Before using the CLI script, if you haven't already downloaded predict.py, click download CLI tools.
API Client: An example batch prediction script using the DataRobot's Python package.
HTTP: An example batch prediction script using the raw Python-based HTTP requests.
3
Platform (only for CLI)
When you select the CLI interface option, the platform setting determines the OS on which you intend to run the generated CLI prediction script. Select one of the following platform types:
Mac/Linux
Windows
4
Copy script to clipboard
Copies the entire code snippet to your clipboard.
5
Show secrets
Displays any secrets hidden by ***** in the code snippet. Revealing the secrets in a code snippet can provide a convenient way to retrieve your API key or datarobot-key; however, these secrets are hidden by default for security reasons, so ensure that you handle them carefully.
6
Code overview screen
Displays the example code you can download and run on your local machine. Edit this code snippet to fit your needs.
Determines the prediction method used. Select Real time.
2
Language
Determines the language of the real-time prediction script generated. Select a format:
Python: An example real-time prediction script using the DataRobot's Python package.
cURL: A script using cURL, a command-line tool for transferring data using various network protocols, available by default in most Linux distributions and macOS.
3
Copy script to clipboard
Copies the entire code snippet to your clipboard.
4
Show secrets
Displays any secrets hidden by ***** in the code snippet. Revealing the secrets in a code snippet can provide a convenient way to retrieve your API key or datarobot-key; however, these secrets are hidden by default for security reasons, so ensure that you handle them carefully.
5
Code overview screen
Displays the example code you can download and run on your local machine. Edit this code snippet to fit your needs.
You can disable data drift tracking for individual prediction requests by applying a unique header to the request. This may be useful, for example, in the case where you are using synthetic data that does not have real-world consequences.
Insert the header, X-DataRobot-Skip-Drift-Tracking=1, into the request snippet. For example:
After you apply this header, drift tracking is not calculated for the request. However, service stats are still provided (data errors, system errors, execution time, and more).
When you create an external model deployment, you are notified that the deployment requires the use of monitoring snippets to report deployment statistics with the monitoring agent.
You can follow the link at the bottom of the page or navigate to Predictions > Monitoring for your deployment to view the snippet:
The monitoring snippet is designed to configure your MLOps library to send a model's statistics to DataRobot MLOps and represent those statistics in the deployment. Use this functionality to report back Scoring Code metrics to your deployment.
To instrument your Scoring Code with a deployment, select the Java language and copy the snippet to your clipboard when you are ready to use it. For further instructions, reference the Quick Start guide available in the monitoring agent's internal documentation.
If you have not yet configured the monitoring agent to monitor your deployment, a download of the MLOps agent tarball is available from a link in the Monitoring tab. Additional documentation for setting up the monitoring agent is included in the tarball.
Prediction servers become dormant after a prolonged period of inactivity. If you see the Prediction server is dormant alert, please contact our support team at support@datarobot.com for prompt reactivation: