Obtaining a Recommendation Result
When an intelligent scenario is created, it is normal if its status is Running. You can use the prediction function to further adjust job parameters based on the recommendation result. You can also call an API to obtain the recommendation result.
Prediction
- Log in to the RES management console. Choose Recommendation Scenarios > Intelligent Scenarios from the left navigation bar. The intelligent scenario list is displayed by default.
- Click the name of a scenario in 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 1. Figure 2 Form prediction
Obtaining a Prediction API
- Log in to the RES management console. Choose Recommendation Scenarios > Intelligent Scenarios from the left navigation bar. The intelligent scenario list is displayed by default.
- Click the name of the target service in the Completed state. On the intelligent 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 an Intelligent Scenario
Next Article: Effect Evaluation



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