|
|
--- |
|
|
license: mit |
|
|
tags: |
|
|
- sentiment-analysis |
|
|
- aspect-based-sentiment-analysis |
|
|
- absa |
|
|
- product-reviews |
|
|
- scikit-learn |
|
|
language: |
|
|
- en |
|
|
metrics: |
|
|
- accuracy |
|
|
- f1 |
|
|
library_name: sklearn |
|
|
pipeline_tag: text-classification |
|
|
--- |
|
|
|
|
|
# AspectLens - Aspect-Based Sentiment Analysis |
|
|
|
|
|
A production-ready **Aspect-Based Sentiment Analysis (ABSA)** model that extracts granular sentiment for specific product features from customer reviews. |
|
|
|
|
|
## Model Description |
|
|
|
|
|
This model identifies sentiment for 6 product aspects: |
|
|
- **Battery**, **Camera**, **Display**, **Performance**, **Build**, **Price** |
|
|
|
|
|
## Model Details |
|
|
|
|
|
- **Architecture**: TF-IDF Vectorization + Logistic Regression |
|
|
- **Training Data**: 200K Amazon mobile phone reviews |
|
|
- **Accuracy**: 90% on test set |
|
|
- **Inference Time**: <100ms per review |
|
|
- **Language**: English |
|
|
|
|
|
## Performance |
|
|
|
|
|
| Metric | Score | |
|
|
|--------|-------| |
|
|
| Overall Accuracy | 90.0% | |
|
|
| Positive Class | 100% | |
|
|
| Negative Class | 80% | |
|
|
| Neutral Class | 90% | |
|
|
| Weighted F1 | 0.90 | |
|
|
|
|
|
## Usage |
|
|
|
|
|
```python |
|
|
from inference import predict |
|
|
|
|
|
# Analyze a review |
|
|
review = "Great camera but terrible battery life. The display is amazing though!" |
|
|
result = predict(review) |
|
|
|
|
|
print(result) |
|
|
# Output: |
|
|
# { |
|
|
# 'aspects': [ |
|
|
# {'aspect': 'camera', 'sentiment': 'positive', 'confidence': 0.982}, |
|
|
# {'aspect': 'battery', 'sentiment': 'negative', 'confidence': 0.947}, |
|
|
# {'aspect': 'display', 'sentiment': 'positive', 'confidence': 0.991} |
|
|
# ], |
|
|
# 'overall_sentiment': 'positive' |
|
|
# } |
|
|
``` |
|
|
|
|
|
## API Endpoint |
|
|
|
|
|
Once deployed on Hugging Face Inference API: |
|
|
|
|
|
```python |
|
|
import requests |
|
|
|
|
|
API_URL = "https://api-inference.huggingface.co/models/YOUR_USERNAME/AspectLens-Aspectwise-sentiment-breakdown" |
|
|
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"} |
|
|
|
|
|
def query(payload): |
|
|
response = requests.post(API_URL, headers=headers, json=payload) |
|
|
return response.json() |
|
|
|
|
|
output = query({ |
|
|
"inputs": "Great phone but battery dies quickly" |
|
|
}) |
|
|
``` |
|
|
|
|
|
## Training Details |
|
|
|
|
|
- **Dataset**: Amazon Product Reviews (Mobile Phones) |
|
|
- **Preprocessing**: Text cleaning, sentence segmentation, aspect detection |
|
|
- **Features**: TF-IDF with max 5000 features |
|
|
- **Classifier**: Logistic Regression with balanced class weights |
|
|
- **Validation**: 80/20 train-test split |
|
|
|
|
|
## Limitations |
|
|
|
|
|
- English language only |
|
|
- Focused on mobile phone reviews (generalizes to other electronics) |
|
|
- Rule-based aspect detection (keyword matching) |
|
|
- May struggle with sarcasm or complex negations |
|
|
|
|
|
## Intended Use |
|
|
|
|
|
- Product development teams identifying pain points |
|
|
- Customer support prioritizing issues |
|
|
- E-commerce platforms analyzing feedback |
|
|
- Marketing teams understanding preferences |
|
|
|
|
|
## Citation |
|
|
|
|
|
```bibtex |
|
|
@misc{aspectlens2026, |
|
|
author = {Aryan Patel}, |
|
|
title = {AspectLens: Aspect-Based Sentiment Analysis for Product Reviews}, |
|
|
year = {2026}, |
|
|
publisher = {Hugging Face}, |
|
|
howpublished = {\url{https://huggingface.co/YOUR_USERNAME/AspectLens}} |
|
|
} |
|
|
``` |
|
|
|
|
|
## License |
|
|
|
|
|
MIT License - Free for commercial and research use |
|
|
|
|
|
## Contact |
|
|
|
|
|
- GitHub: [@Aryan1patel](https://github.com/Aryan1patel) |
|
|
- Repository: [AspectLens](https://github.com/Aryan1patel/Aspectwise-sentiment-breakdown-and-Real-data-Insights) |
|
|
|
|
|
--- |
|
|
|
|
|
Built with ❤️ using scikit-learn |
|
|
|