An advanced sentiment analysis system for Reddit posts using fine-tuned transformers and multi-model ensemble approach.
Python 3.8+
pip or conda
Reddit API credentials (optional, for live data)
# Clone the repository
git clone https://github.com/yourusername/Reddit-Sentiment-Tracker.git
cd Reddit-Sentiment-Tracker
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Create a .env file:
REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_client_secret
REDDIT_USER_AGENT=your_user_agent
cd app
uvicorn main:app --reload
Visit http://localhost:8000/docs for interactive API documentation.
import requests
response = requests.post("http://localhost:8000/analyze", json={
"text": "Tesla",
"subreddit": "technology",
"limit": 10
})
results = response.json()
print(f"Average Sentiment: {results['summary']['average_sentiment']}")
{
"posts": [
{
"title": "Tesla Model Y Review",
"sentiment": "positive",
"sentiment_score": 0.85,
"sarcasm_flag": false,
"method": "absa"
}
],
"summary": {
"average_sentiment": 0.72,
"most_positive_post": {...},
"most_negative_post": {...}
}
}
┌─────────────────┐
│ Reddit API │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Data Fetcher │
└────────┬────────┘
│
▼
┌─────────────────────────────────────┐
│ Multi-Model Ensemble │
│ ┌───────────┐ ┌────────────┐ │
│ │ DeBERTa │ │ RoBERTa │ │
│ │ ABSA │ │ Sentiment │ │
│ └─────┬─────┘ └──────┬─────┘ │
│ │ │ │
│ └────────┬──────┘ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Sarcasm Detector│ │
│ └─────────┬───────┘ │
└──────────────────┼──────────────────┘
│
▼
┌─────────────────┐
│ Sentiment │
│ Aggregation │
└─────────────────┘
Fine-tune the ABSA model on your own data:
from model_tuning import fine_tune_model
# Prepare your data in CSV format:
# text, aspect, label
# "Tesla is amazing", "Tesla", "positive"
model, tokenizer = fine_tune_model()
| Model | Accuracy | Use Case |
|---|
| DeBERTa ABSA (Base) | 79% | Aspect-specific sentiment |
| RoBERTa Irony | 87% | Sarcasm detection |
Reddit-Sentiment-Tracker/
├── app/
│ ├── main.py # FastAPI application
│ ├── services/
│ │ ├── fetch_data.py # Reddit data fetching
│ │ └── analyze.py # Sentiment analysis
│ ├── nlp_models.py # Model loading
│ ├── model_tuning.py # Fine-tuning pipeline
│ ├── evaluate.py # Model evaluation
│ └── insights.py # Analytics & visualization
├── Data/
│ ├── test_data.csv # Evaluation dataset
│ └── extended_training_data.csv
├── requirements.txt
└── README.md
Contributions are welcome! Please:
git checkout -b feature/NewFeature)git commit -m 'Add Feature')git push origin feature/NewFeature)This project is licensed under the MIT License - see the LICENSE file for details.
Abhinand H - [https://www.linkedin.com/in/abhinand-h-74616a1b8/]
Project Link: [https://github.com/abhi0420/Reddit-Sentiment-Tracker]
⭐ Star this repo if you find it helpful!
28 commits
Python
100.0%
An advanced sentiment analysis system for Reddit posts using fine-tuned transformers and multi-model ensemble approach.
Python 3.8+
pip or conda
Reddit API credentials (optional, for live data)
# Clone the repository
git clone https://github.com/yourusername/Reddit-Sentiment-Tracker.git
cd Reddit-Sentiment-Tracker
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Create a .env file:
REDDIT_CLIENT_ID=your_client_id
REDDIT_CLIENT_SECRET=your_client_secret
REDDIT_USER_AGENT=your_user_agent
cd app
uvicorn main:app --reload
Visit http://localhost:8000/docs for interactive API documentation.
import requests
response = requests.post("http://localhost:8000/analyze", json={
"text": "Tesla",
"subreddit": "technology",
"limit": 10
})
results = response.json()
print(f"Average Sentiment: {results['summary']['average_sentiment']}")
{
"posts": [
{
"title": "Tesla Model Y Review",
"sentiment": "positive",
"sentiment_score": 0.85,
"sarcasm_flag": false,
"method": "absa"
}
],
"summary": {
"average_sentiment": 0.72,
"most_positive_post": {...},
"most_negative_post": {...}
}
}
┌─────────────────┐
│ Reddit API │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Data Fetcher │
└────────┬────────┘
│
▼
┌─────────────────────────────────────┐
│ Multi-Model Ensemble │
│ ┌───────────┐ ┌────────────┐ │
│ │ DeBERTa │ │ RoBERTa │ │
│ │ ABSA │ │ Sentiment │ │
│ └─────┬─────┘ └──────┬─────┘ │
│ │ │ │
│ └────────┬──────┘ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Sarcasm Detector│ │
│ └─────────┬───────┘ │
└──────────────────┼──────────────────┘
│
▼
┌─────────────────┐
│ Sentiment │
│ Aggregation │
└─────────────────┘
Fine-tune the ABSA model on your own data:
from model_tuning import fine_tune_model
# Prepare your data in CSV format:
# text, aspect, label
# "Tesla is amazing", "Tesla", "positive"
model, tokenizer = fine_tune_model()
| Model | Accuracy | Use Case |
|---|
| DeBERTa ABSA (Base) | 79% | Aspect-specific sentiment |
| RoBERTa Irony | 87% | Sarcasm detection |
Reddit-Sentiment-Tracker/
├── app/
│ ├── main.py # FastAPI application
│ ├── services/
│ │ ├── fetch_data.py # Reddit data fetching
│ │ └── analyze.py # Sentiment analysis
│ ├── nlp_models.py # Model loading
│ ├── model_tuning.py # Fine-tuning pipeline
│ ├── evaluate.py # Model evaluation
│ └── insights.py # Analytics & visualization
├── Data/
│ ├── test_data.csv # Evaluation dataset
│ └── extended_training_data.csv
├── requirements.txt
└── README.md
Contributions are welcome! Please:
git checkout -b feature/NewFeature)git commit -m 'Add Feature')git push origin feature/NewFeature)This project is licensed under the MIT License - see the LICENSE file for details.
Abhinand H - [https://www.linkedin.com/in/abhinand-h-74616a1b8/]
Project Link: [https://github.com/abhi0420/Reddit-Sentiment-Tracker]
⭐ Star this repo if you find it helpful!
28 commits
Python
100.0%