You're a data scientist at a popular video streaming site and you need to generate a report on which users are likely to cancel their subscription so the marketing team can target their upcoming ad campaign.
You built a machine learning model to predict how likely users are to cancel their subscription based on their watch history, content preferences, and other user data. Your company stores this user data in a cloud data lake. To generate the report, you'll create a mapping to read from the data lake, pass the data through the machine learning model, and filter out results that aren't important to the marketing campaign.
Before you create the mapping, you set up a REST endpoint for the machine learning model. You also create an API collection with a POST request in
Data Integration
.
Then, you create a mapping that includes a Machine Learning transformation and a Filter transformation. The following image shows an overview of the mapping:
You configure the transformations in the following ways:
Machine Learning transformation
On the
Model
tab, select a POST request from your API collection as the operation and select the connection to the machine learning model. The following image shows the configured
Model
tab:
On the
Request Mapping
tab, verify that the mapping of the incoming field from the Source transformation to the request schema field is correct. If needed, manually map the fields. The following image shows the configured
Request Mapping
tab:
Filter transformation
Since the marketing team is only interested in users who are unlikely to renew their subscription, set the filter condition to filter for users who have a probability of renewing less than 50%. The following image shows the configured filter condition:
When you run the mapping, it reads user data from the cloud data lake. The Machine Learning transformation makes a REST API call to pass the data through the request schema fields to the machine learning model. The model generates predictions about each user's likelihood of renewing, and the Machine Learning transformation captures the predictions in the response schema fields. The Machine Learning transformation passes the results to the Filter transformation, which filters out users who are likely to renew and passes users who are unlikely to renew to the Target transformation. The Target transformation writes the results to the target file, which you can send over to the marketing team.