An LSTM-based sentiment classifier that improves through human feedback. When the model is uncertain about a prediction, it asks the user for a label and learns from it in real time.
The model starts with 100 labeled movie reviews (50 positive, 50 negative). On new input, it predicts sentiment with a confidence score. If confidence is low or too many words are unknown, it flags uncertainty and asks you to provide the correct label then updates its weights immediately.
pip install -r requirements.txt
python adaptiveSentimentClassifier.pyEnter text (or 'quit'): this movie was absolutely fantastic
Prediction: Positive (confidence: 0.92)
Enter text (or 'quit'): weird confusing nonsensical plot
I'm not sure about: 'weird confusing nonsensical plot'
(confidence: 0.18, unknown words: 75%)
Positive (1), Negative (0), or 'skip': 0
Learned! 'weird confusing nonsensical plot' -> Negative
classifier = AdaptiveSentimentClassifier(
confidenceThreshold=0.4, # Below this, ask for a label
unknownThreshold=0.5, # Unknown word ratio trigger
modelDir="model" # Where to save checkpoints
)├── adaptiveSentimentClassifier.py # AdaptiveSentimentClassifier + interactive loop
├── model/ # Auto-created on first run
│ ├── classifier.pt # Saved model weights & vocab
│ └── newLabels.json # User-provided labels
├── requirements.txt
├── .gitignore
└── LICENSE
MIT