Update README.md
Browse files
README.md
CHANGED
|
@@ -11,4 +11,70 @@ license: mit
|
|
| 11 |
short_description: Real-Time Tweet Sentiment Analyzer
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
short_description: Real-Time Tweet Sentiment Analyzer
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# π§ Sentiment Analysis from Scratch (BiLSTM + Attention)
|
| 15 |
+
|
| 16 |
+
Welcome to this live interactive demo of a sentiment analysis model trained completely from scratch using a **Deep Bidirectional LSTM** architecture enhanced with a **custom attention mechanism**. This project is designed to classify short texts or tweets into **Positive** or **Negative** sentiments with a confidence score.
|
| 17 |
+
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
## π Project Highlights
|
| 21 |
+
|
| 22 |
+
- β
**Trained from scratch**: The embedding layer is trained on the dataset itself (not using pretrained embeddings).
|
| 23 |
+
- π§ **Model Architecture**:
|
| 24 |
+
- Bidirectional LSTM layers
|
| 25 |
+
- Custom attention layer (`BetterAttention`)
|
| 26 |
+
- Final dense ANN for binary classification
|
| 27 |
+
- π **Output**: Label (Positive/Negative) and confidence score (0β1)
|
| 28 |
+
- π **Tokenizer**: Also trained from scratch and saved as `tokenizer.joblib`
|
| 29 |
+
- π **Model Format**: Saved as `.keras` and loaded efficiently during inference
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## π Try it Out
|
| 34 |
+
|
| 35 |
+
Enter a tweet or short sentence below and see real-time prediction:
|
| 36 |
+
|
| 37 |
+
π *Example*:
|
| 38 |
+
`"I absolutely loved the performance!"`
|
| 39 |
+
**Output**: Positive (0.91)
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## π Model Files
|
| 44 |
+
|
| 45 |
+
You can also explore/download the trained artifacts here:
|
| 46 |
+
- [`sentiment_model.keras`](https://huggingface.co/MasterShomya/Sentiment_Analysis-Tweets/blob/main/sentiment_model.keras)
|
| 47 |
+
- [`tokenizer.joblib`](https://huggingface.co/MasterShomya/Sentiment_Analysis-Tweets/blob/main/tokenizer.joblib)
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
## π§ͺ How It Works
|
| 52 |
+
|
| 53 |
+
1. The input text is tokenized using the trained tokenizer (`joblib`).
|
| 54 |
+
2. The padded sequence is passed through:
|
| 55 |
+
- `Embedding β BiLSTM β BiLSTM β Attention β Dense Layers`
|
| 56 |
+
3. The final sigmoid-activated output represents the **probability of positivity**.
|
| 57 |
+
4. A confidence-aware label is returned using Gradioβs `Label` component.
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## π Model Performance
|
| 62 |
+
|
| 63 |
+
Despite training from scratch without pretrained embeddings (like GloVe or FastText), the model performs comparably well. Experiments with `glove.27B.200d` embeddings yielded **similar accuracy**, and hence were excluded for clarity.
|
| 64 |
+
|
| 65 |
+
Training plots and confusion matrix are available in the original [Kaggle Notebook](https://www.kaggle.com/code/mastershomya/sentiment-analysis-deep-bilstm).
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## π§βπ» Author
|
| 70 |
+
|
| 71 |
+
**Shomya Soneji**
|
| 72 |
+
Machine Learning & Deep Learning Enthusiast
|
| 73 |
+
Connect on [Kaggle](https://www.kaggle.com/mastershomya)
|
| 74 |
+
|
| 75 |
+
---
|
| 76 |
+
|
| 77 |
+
## π€ Support
|
| 78 |
+
|
| 79 |
+
If you find this project helpful, please consider giving it a π and sharing it!
|
| 80 |
+
Your feedback and suggestions are always welcome π¬
|