Tutorial | Create an API endpoint and test queries (MLOps part 4)

The batch deployment framework demonstrated in the batch deployment tutorial works well for many use cases, such as creating periodic reports. For many other use cases though, we need to score records in real-time!

For this tutorial, you’ll start by working with a prediction model already deployed in the Flow of a project in the Design node. You’ll use the model to create an endpoint that will be included in an API service for deployment to an API node.

Objectives

In this tutorial, you will:

  • Package an API service that includes a prediction model as an endpoint.

  • Create test queries for the prediction endpoint.

Starting here?

If you skipped the previous sections and just want to create an API endpoint, you need to:

  • Satisfy the technical prerequisites.

  • Create the project (+New Project > DSS Tutorials > MLOps > MLOps (Tutorial)).

  • Remap filesystem to SQL connections (optional).

  • Build the Flow.

Create an API service with a prediction endpoint

Note

For greater context on the concepts at work here, see our resources on real-time API deployment and API endpoints.

To get started, we need a prediction model deployed to the Flow.

  • From the project Flow, select the prediction model Predict authorized_flag (binary).

  • Open the right-side Actions tab, and click Create API.

Create an API service with a prediction endpoint.

  • In the New scoring API from model dialog, name the API service ID fraud_detection.

Note

The API service ID must be unique. If an API service with the same name already exists in your project, consider adding a unique identifier (such as your name) to the API service ID.

  • Name the Endpoint ID predict_fraud. This ID should be unique within the API service.

  • Click Append to open the API designer.

Dataiku screenshot of the new scoring API from model dialog.

Test the prediction endpoint

The fraud_detection API service now includes the model as a prediction endpoint. Next, we’ll run some test queries on records found in the test_scored dataset to confirm that the endpoint properly generates a prediction for whether a credit card transaction is fraudulent or not.

  • If not already there, navigate to the API Designer from the More Options menu in the top navigation bar. Click fraud_detection to open the API service.

  • Go to the Test queries panel on the left.

  • Click +Add Queries, and choose to create 5 test queries.

  • Create the test queries from the test_scored dataset, and click Add.

Dataiku screenshot of the page for adding test queries to verify that the endpoint works.

  • Click Run Test Queries at the top right.

  • Click the Details of the first query to see more details, such as the probabilities of the two outcomes according to the model.

Dataiku screenshot of output from test queries.

Note

The Logs tab (next to Details) provides information that can be useful for debugging and troubleshooting, in the event that something fails.

Next steps

Congratulations! You’ve successfully designed and tested an API service with a prediction endpoint.

The next step is to actually deploy this API service from the Design node into a production environment!

Note

For more information, see the product documentation on API Node & API Deployer: Real-time APIs.