Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prrao87/fine-grained-sentiment-app
A Flask LIME explainer app for fine-grained sentiment classification.
https://github.com/prrao87/fine-grained-sentiment-app
flask interpretability lime lime-explainer nlp visualization web-app
Last synced: 14 days ago
JSON representation
A Flask LIME explainer app for fine-grained sentiment classification.
- Host: GitHub
- URL: https://github.com/prrao87/fine-grained-sentiment-app
- Owner: prrao87
- License: mit
- Created: 2019-08-23T18:27:52.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T21:20:09.000Z (over 1 year ago)
- Last Synced: 2024-10-04T17:38:32.463Z (about 1 month ago)
- Topics: flask, interpretability, lime, lime-explainer, nlp, visualization, web-app
- Language: Python
- Homepage:
- Size: 14.8 MB
- Stars: 11
- Watchers: 3
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# An Explainer App for Fine Grained Sentiment Classification
This repo contains an initial prototype of an interactive application written in Flask, that explains the results of fine-grained sentiment classification, described in detail in [this Medium Series](https://medium.com/@tech_optimist/fine-grained-sentiment-analysis-in-python-part-2-2a92fdc0160d).
A number of classifiers are implemented and their results explained using the [LIME explainer](https://arxiv.org/pdf/1602.04938.pdf).
The classifers were trained on the [Stanford Sentiment Treebank](https://nlp.stanford.edu/sentiment/) (SST-5) dataset. The class labels are any of `[1, 2, 3, 4, 5]`, where `1` is very negative and `5` is very positive.## Installation
First, set up virtual environment and install from ```requirements.txt```:
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txtFor further development, simply activate the existing virtual environment.
source venv/bin/activate
## Usage
Run the file `app.py` and then enter a sentence, choose a type of classifier and click on the button `Explain results!`. We can then observe the features (i.e. words or tokens) that contributed to the classifier predicting a particular class label.
## Demo for the front-end
The front-end app takes in a text sample and outputs LIME explanations for the different methods. The app is is deployed using Heroku at this location: https://sst5-explainer.herokuapp.com/Play with your own text examples as shown below and see the fine-grained sentiment results explained!
**NOTE:** Because the PyTorch-based models (Flair and the causal transformer) are quite expensive to run inference with (they require a GPU), these methods are not deployed.
![](data/assets/explainer-app.gif)