Text Classification
Scikit-learn
Joblib
English
sentiment-analysis
aspect-based-sentiment-analysis
absa
product-reviews
scikit-learn
Instructions to use DukeShadow/AspectLens-Aspectwise-sentiment-breakdown with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use DukeShadow/AspectLens-Aspectwise-sentiment-breakdown with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("DukeShadow/AspectLens-Aspectwise-sentiment-breakdown", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
|
Download README.md from DukeShadow/AspectLens-Aspectwise-sentiment-breakdown: direct link, hf CLI and curl.
- Browser
- Download file 3.32 kB
-
https://huggingface.co/DukeShadow/AspectLens-Aspectwise-sentiment-breakdown/resolve/main/README.md
- Command line
-
hf download hf://DukeShadow/AspectLens-Aspectwise-sentiment-breakdown/README.md
-
curl -L -H "Authorization: Bearer $HF_TOKEN" -o README.md https://huggingface.co/DukeShadow/AspectLens-Aspectwise-sentiment-breakdown/resolve/main/README.md
3.32 kB
| 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. | |
| # Use the Model in Space | |
| - Demo: [Space](https://huggingface.co/spaces/DukeShadow/aspectlens-demo) | |
| ## 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 | |