Obtaining a Recommendation Result
After the online service is created and deployed, if the service status is Running, the service status is normal. You can use the online prediction function to further adjust job parameters based on the recommendation result. You can also call an API to obtain the recommendation result.
Online Prediction
- Log in to the RES management console. Choose Recommendation Scenarios > Custom Scenarios from the left navigation bar. The custom scenario list is displayed by default.
- Click the name of a scenario with the Completed status to go to the scenario details page. Then, click the Predict tab. There are two prediction modes available.
- Code: Enter a prediction code and click Predict. The prediction result is displayed. See Figure 1. Enter a user ID and the recommended number, and return the prediction result based on your settings.
- Form: Enter an ID and set the maximum number of recommendations. The ID can be a user ID or item ID. After you click Predict, the prediction result is displayed. See Figure 2.
Obtaining a Prediction API
- Log in to the RES management console. Choose Recommendation Scenarios > Custom Scenarios from the left navigation bar. The custom scenario list is displayed by default.
- Click the name of the target service with the Completed status. On the scenario details page that is displayed, click the Predict tab to obtain the API address of the service. Click
to copy the API address and invoke the service. Figure 3 Obtaining a prediction API
Calling an API
Both Mozilla Firefox and Google Chrome provide a graphical browser plugin, that is, REST client, to send and process requests.
- For Mozilla Firefox, see Firefox RESTClient.
- For Google Chrome, see Postman.
Postman is used as an example to describe how to call the prediction API to obtain the recommendation result. For details on APIs, see the RES API Reference.
- Download PostmanPostman and install it, or add the Postman extension directly to Google Chrome. (Alternatively, use other software that can send POST requests).
- Open Postman. Figure 4 shows the Postman interface.
- Set parameters on the Postman page.
- Select the POST task and copy the call address obtained in Obtaining a Prediction API to the POST box. On the Headers tab page, set KEY to X-Auth-Token and VALUE to the token obtained in Obtaining User Token. See Figure 5.
You can also use AK/SK to encrypt the service call request. For details, see AK/SK Authentication in the section "Getting Authenticated"Getting Authenticated in RES API Reference.
- Select the POST task and copy the call address obtained in Obtaining a Prediction API to the POST box. On the Headers tab page, set KEY to X-Auth-Token and VALUE to the token obtained in Obtaining User Token. See Figure 5.
- On the Postman page, choose Body > raw and enter the JSON body in the text box below. The following is a request example:
{ "id":"user894", "rec_num": 10 } - After setting the parameters, click Send to send the request. The result is displayed in the response. In the preceding information, id indicates the ID of the recommended item, and score indicates the score of the recommended item. The following is an example:
{ "flow_id": "flow1", "rec_num": 10, "candidates": [ { "id": "item235", "score": 0.58418584, "source": "WeightBehavior-DIREC" }, { "id": "item338", "score": 0.5653803, "source": "WeightBehavior-DIREC" }, { "id": "item709", "score": 0.55219465, "source": "WeightBehavior-DIREC" }, { "id": "item960", "score": 0.55219465, "source": "WeightBehavior-DIREC" }, { "id": "item469", "score": 0.55219465, "source": "WeightBehavior-DIREC" }, { "id": "item236", "score": 0.55219465, "source": "WeightBehavior-DIREC" } ] }
Last Article: Publishing or Stopping a Custom Scenario
Next Article: Deleting a Custom Scenario




Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.