Overview
The emotion prediction API provides sentiment classification to determine whether text expresses positive or negative emotions. This is powered by a trained emotion classifier that analyzes cleaned and processed text.How Sentiment Detection Works
The API uses a two-stage approach:- Text Processing: Text is cleaned, lemmatized, and vectorized (microservice.py:202-221)
- Emotion Classification: The vectorized text is analyzed to predict emotional sentiment
- Smart Adjustment: If content is flagged as inappropriate across all toxicity categories, it’s automatically classified as “Negative”
Classification Logic
API Usage
Making a Request
Response Format
The API returns sentiment along with toxicity classifications:Use Case Scenarios
Customer Feedback Analysis
Automatically classify customer reviews and support tickets as positive or negative. Route negative feedback to priority queues for faster resolution.
Social Media Monitoring
Track brand sentiment across social platforms. Identify trends in positive or negative mentions over time.
Product Reviews
Analyze product review sentiment at scale. Correlate sentiment with star ratings to identify discrepancies.
Employee Feedback
Gauge employee satisfaction from survey responses and feedback forms. Identify areas of concern requiring attention.
Chat Analytics
Monitor customer service chat conversations to measure customer satisfaction in real-time.
Email Campaign Analysis
Analyze responses to marketing emails to understand audience reception and improve future campaigns.
Implementation Examples
Basic Sentiment Analysis
Customer Feedback Dashboard
Real-time Sentiment Monitoring
Integration with Reviews Platform
Advanced Analytics
Sentiment Trends Over Time
Best Practices
Sentiment Analysis Guidelines
- Context matters: Sentiment analysis works best with complete sentences and paragraphs
- Combine with toxicity: Use both sentiment and toxicity classifications for comprehensive insights
- Batch processing: For large datasets, implement rate limiting and batch processing
- Handle edge cases: Short texts like “OK” or “Fine” may be ambiguous - consider context
- Track over time: Monitor sentiment trends rather than individual data points for better insights
- Cross-reference data: Compare sentiment with other metrics (star ratings, NPS scores) for validation
Next Steps
- Learn about Content Moderation using the 6 toxicity categories
- Understand the text processing pipeline in microservice.py:94-120
- Explore entity extraction features (countries, dates, people names) for richer analysis