Customer Review Sentiment Model (Free)
Introduction
The Customer Review Sentiment Model analyzes text data from customer reviews and predicts the sentiment behind them. It outputs a sentiment score where “1” indicates a positive sentiment and “0” indicates a negative sentiment, along with a confidence score for each prediction.
Here are some examples of customer reviews and the sentiment analysis predictions:
Customer Review | Sentiment Prediction | Confidence Score |
---|---|---|
“I love this brand. This camera doorbell is fantastic. Great picture quality, wide view, super easy to install. Can’t recommend highly enough. Very smart little device, able to detect easily between object and person.” | 1 | 0.923 |
“I am not happy with this.” | 0 | 0.88 |
“Terrible experience.” | 0 | 0.995 |
“Highly recommend it!” | 1 | 0.977 |
Check out our hugging face space to play with it: https://huggingface.co/spaces/dfpipe/eazyai
How to use the model
Step 1 - Prepare the input in json format
Code - Example of input
{
"apikey": "dfpipe-eazymodel-jikhoh-jybmac-pYxsi9",
"data": [
{"text": "This is a good product"},
{"text": "This is a bad product"}
],
"action": "infer",
"model_id": "customer_review_sentiment_v1"
}
There are 4 fields in the input json:
- apikey: the provided one is for free users. And it is completely free! But, you may get a 500 error when there are too many people is using it. Just simply try again later.
- model_id: this one indicate that you are calling the customer review sentiment model v1
- action: [“infer”], which is the only action supported by v1 model
- data: which is a list of dictionary objects, each one should have one field -> “text”, which can be any customer review text.
- data list should be less than 20, for more than 20, you should split them to call the model
- each “text” value should be less than 300 words, if one has more than 300 words, it will be truncated.
Step 2 - Call the model with the input
Option 1 - Call using HTTP request command Curl
curl -X POST https://api.dfpipe.com/eazyai \
-H "Content-Type: application/json" \
-d '{"apikey": "dfpipe-eazymodel-jikhoh-jybmac-pYxsi9", "data": [{"text": "This is a good product"}, {"text": "This is a bad product"}], "action": "infer", "model_id": "customer_review_sentiment_v1"}'
Option 2 - Call the model using python
import requests
url = "https://api.dfpipe.com/eazyai"
headers = {
"Content-Type": "application/json"
}
payload = {
"apikey": "dfpipe-eazymodel-jikhoh-jybmac-pYxsi9",
"data": [
{"text": "This is a good product"},
{"text": "This is a bad product"}
],
"action": "infer",
"model_id": "customer_review_sentiment_v1"
}
response = requests.post(url, json=payload, headers=headers)
# Print the response
print(response.status_code)
print(response.json())
Step 3 - Get the result
{
"status_code": 200,
"body": {
"results": [
{"y": 1, "confidence": 0.932},
{"y": 0, "confidence": 0.998}
],
"model_id": "customer_review_sentiment_v1",
"model_version": "1.0"
}
}
Status code:
- 200: success
- 400: input argument error
- 500: internal server error
Results:
- y: sentiment prediction. 1 is positive, 0 is negative.
- confidence: confidence score, between 0 and 1. 0 means the model is not confident about the prediction and 1 means the model is most confident about the prediction.