Skip to main content
Practice

Classifying Data Based on Criteria

Accurate data classification is essential for performance analysis and business success. For instance, identifying public sentiment about content based on social media comments or analyzing review data from a shopping site can help select high customer satisfaction products.

While zero-shot prompting where no examples are given can be used for classification, when it comes to subjective judgment criteria like sentiments, it's beneficial to provide some examples.

Giving AI 2-5 examples to serve as a judgment criterion through few-shot prompting is very useful when optimizing data classification tasks.

Imagine you need to select the product with the highest customer satisfaction among several products. If you need to classify reviews for a popular product like oranges as positive or negative, you can use the following few-shot prompt:

Orange Product Classification Prompt Example
### Instruction: Based on the below orange product reviews, determine whether each review is positive or negative.

### Orange Product Reviews
Review: "These oranges are really fresh and sweet. My kids loved them too!"
Result: Positive

Review: "The oranges were too tart and hard to eat. I don't think I'll buy them again."
Result: Negative

Review: "The delivery was fast, and the oranges were fresh. I'm satisfied with the purchase."
Result: Positive

Review: "The oranges were a bit dried out. They weren't as good as I had hoped."
Result: Negative

### Reviews to Determine Positive/Negative

Review 1: "There were a few rotten oranges. I don't think I'll buy them again."
Result: [Write your answer here]

Review 2: "Taste much better than the ones I got from the store."
Result: [Write your answer here]

Review 3: "They were just okay. I'll probably buy a different fruit next time."
Result: [Write your answer here]

This prompt uses ### delimiters to structure the prompt and provides four examples for few-shot prompting. It asks AI to write the results in the [Write your answer here] section.

If there are too many reviews to classify, you can organize them in Google Sheets and use the GPT for Sheets™ and Docs™ extension to ask AI to classify multiple reviews at once.

Additionally, you can use the Open AI Chat Completion API to automate review analysis through a program.


Practice

Send the prompt example and compare the AI's response.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.