The purchase decision analysis service for E-commerce helps you analyze information related to purchase decisions, such as user motivations, usage scenarios, feature requests, and questions. This information can help you improve products, enhance user experience, segment user profiles, and conduct targeted marketing. If the currently supported domains and industries do not meet your needs, you can join the DingTalk group (ID: 23142693) for assistance.
This service is provided by the Natural Language Processing (NLP) Self-Learning Platform. You can use this service by calling the API directly.
Service activation and resource plan purchase
Before you start, ensure that the service is activated. After activation, you can purchase a resource plan.
Activate service: Activation link
Purchase resource plan: Purchase link
Service invocation and testing
For information about model invocation, see Model invocation.
For SDK examples, see SDK examples.
Debug
Configure access credentials using environment variables
Notes:
An AccessKey pair of an Alibaba Cloud account has all API access permissions. This poses a high security risk. We recommend that you create and use a Resource Access Management (RAM) user to make API calls or perform routine O&M. To create a RAM user, log on to the RAM console.
To avoid security risks, do not hard-code your AccessKey ID and AccessKey secret in your code. Instead, configure them as environment variables.
Configuration for Linux and macOS
export NLP_AK_ENV=<access_key_id> export NLP_SK_ENV=<access_key_secret>Replace <access_key_id> with your AccessKey ID and <access_key_secret> with your AccessKey secret. For more information about how to obtain an AccessKey ID and an AccessKey secret, see Step 2: Obtain an AccessKey pair.
Method for configuring Windows systems
Create the
NLP_AK_ENVandNLP_SK_ENVenvironment variables, and set them to your AccessKey ID and AccessKey secret.Restart Windows.
Java code example
/**
* An AccessKey pair of an Alibaba Cloud account has all API access permissions. This poses a high security risk. Create and use a RAM user to make API calls or perform routine O&M. To create a RAM user, log on to the RAM console.
* This example shows how to store the AccessKey ID and AccessKey secret in environment variables. You can also store them in a configuration file as needed.
* To avoid security risks, do not hard-code your AccessKey ID and AccessKey secret in your code.
*/
String accessKeyId = System.getenv("NLP_AK_ENV");
String accessKeySecret = System.getenv("NLP_SK_ENV");
DefaultProfile defaultProfile = DefaultProfile.getProfile("cn-hangzhou",accessKeyId,accessKeySecret);
IAcsClient client = new DefaultAcsClient(defaultProfile);
RunPreTrainServiceRequest request = new RunPreTrainServiceRequest();
request.setServiceName("NLP_ner_pretrained_review_multidim_ecom");
request.setPredictContent("Received the children's masks. Fast logistics, good service. A must-have for school during the pandemic. The price is better than in physical stores. I have purchased them many times!");
RunPreTrainServiceResponse response = client.getAcsResponse(request);
System.out.println(response.getPredictResult());Python code example
# Install dependencies
pip install aliyun-python-sdk-core
pip install aliyun-python-sdk-nlp-automl# -*- coding: utf8 -*-
import json
import os
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdknlp_automl.request.v20191111 import RunPreTrainServiceRequest
# An AccessKey pair of an Alibaba Cloud account has all API access permissions. This poses a high security risk. Create and use a RAM user to make API calls or perform routine O&M. To create a RAM user, log on to the RAM console.
# This example shows how to store the AccessKey ID and AccessKey secret in environment variables. You can also store them in a configuration file as needed.
# To avoid security risks, do not hard-code your AccessKey ID and AccessKey secret in your code.
access_key_id = os.environ['NLP_AK_ENV']
access_key_secret = os.environ['NLP_SK_ENV']
# Initialize AcsClient instance
client = AcsClient(
access_key_id,
access_key_secret,
"cn-hangzhou"
);
content = 'Received the children\'s masks. Fast logistics, good service. A must-have for school during the pandemic. The price is better than in physical stores. I have purchased them many times!'
# Initialize a request and set parameters
request = RunPreTrainServiceRequest.RunPreTrainServiceRequest()
request.set_ServiceName('NLP_ner_pretrained_review_multidim_ecom')
request.set_PredictContent(content)
# Print response
response = client.do_action_with_exception(request)
resp_obj = json.loads(response)
predict_result = json.loads(resp_obj['PredictResult'])
print(json.dumps(predict_result['data'],ensure_ascii=False))Request parameters
Parameter | Description | Example |
ServiceName | The service name. This parameter is required. | NLP_ner_pretrained_review_multidim_ecom |
PredictContent | The content of the product review. This parameter is required. | Received the children's masks. Fast logistics, good service. A must-have for school during the pandemic. The price is better than in physical stores. I have purchased them many times! |
Example of PredictResult content
{
"records": {
"comparison": [
{
"prob": 0.9929813610182868,
"offset": [26, 35],
"span": "The price is better than in physical stores"
}
],
"purchase_motivation^scenario": [
{
"prob": 0.97239750623703,
"offset": [21, 25],
"span": "A must-have for school"
}
],
"user_object": [
{
"prob": 0.9865950644016266,
"offset": [0, 2],
"span": "children"
}
],
"usage_scenario": [
{
"prob": 0.975536584854126,
"offset": [21, 25],
"span": "A must-have for school"
}
],
"will_repurchase": [
{
"prob": 0.9607752660910288,
"offset": [36, 42],
"span": "I have purchased them many times"
}
]
},
"content": "Received the children's masks. Fast logistics, good service. A must-have for school during the pandemic. The price is better than in physical stores. I have purchased them many times!"
}Response parameters
Field | Description | Example |
content | The user's input. | |
records | The set of labels extracted by the algorithm. This is a dictionary where the key is the label name and the value is the extracted information. | |
span | The segment extracted from the user's input. | children |
offset | The start (inclusive) and end (exclusive) positions of the extracted segment in the user's input. | [0, 2] |
prob | The confidence level. This is a probability value between 0 and 1. | 0.9865950644016266 |
List of supported purchase decision labels
Label | Description | Example |
Feature request | The user wants the product to meet more needs or provide more features. | It's a shame this pressure cooker doesn't have a reheating function. |
purchase_motivation^group | Received the barley grass juice that a friend recommended. | |
purchase_motivation^holiday | Birthday gift | |
purchase_motivation^scenario | I originally planned to give it as a gift. | |
purchase_motivation^other | Curiosity | |
Comparison | A comparison between products, purchase channels, and so on. | Cheaper than in the supermarket. |
First-time purchase | The user's first time purchasing the product. | First time drinking it. |
Will repurchase | Will repurchase indefinitely. | |
Will not repurchase | Won't buy it again. | |
Usage scenario | Bought it to improve my health. Very suitable for use at work. | |
Will recommend | Recommend buying it. | |
Will not recommend | Not recommended. | |
Will post a follow-up review | Will post a follow-up review after drinking it. | |
usage_status^used | Already started using it. | |
usage_status^not_used | Haven't drunk it yet. | |
Question about usage | Something the user has a question about. | I wonder if it gets dirty easily. I wonder how long it will last. |
Target audience | Extracts only the object entity. | Bought it for my [little nephew]. The [baby] is very comfortable wearing it. |
Brand impression | I trust Gree appliances. | |
Purchase channel | For example, a live channel or a Taoke promoter. | I bought it from Viya's live channel. |
User approval | The user's approval of the merchant. | I only buy products from this merchant. Thumbs up to the seller. |
service_promise-unfulfilled | A promise made by the merchant that was not fulfilled. | They promised to write a greeting card, but they didn't. They promised a gift, but I didn't receive one. |