A deployable NLP project built from NLP_NEW.ipynb, with a trained text-classification pipeline, a Streamlit front-end, and free-hosting deployment support through Streamlit Community Cloud.
This project turns a notebook-based emotion classification workflow into a small application that can be trained locally and served on the web.
It includes:
- A reproducible training script
- A saved model artifact for inference
- A Streamlit UI for single-text prediction
- Tests for training, inference, and UI helpers
- Train an emotion classifier from
train.txt - Preprocess text using the notebook’s cleaning flow
- Save and reload the trained model with
joblib - Predict from a single sentence in Streamlit
- Show both predicted label and confidence score
train.txt -> train_model.py -> TF-IDF + Logistic Regression pipeline -> artifacts/emotion_model.joblib
User input -> app.py -> predict.py -> saved model artifact -> predicted label + confidence
- User enters text in the Streamlit app
- Input is validated
- The saved model is loaded
- The model predicts the most likely emotion
- The app displays the label and confidence
python/
├── app.py
├── predict.py
├── train_model.py
├── train.txt
├── NLP_NEW.ipynb
├── requirements.txt
├── README.md
├── artifacts/
│ ├── .gitkeep
│ └── emotion_model.joblib
├── tests/
│ ├── conftest.py
│ ├── test_app.py
│ ├── test_predict.py
│ ├── test_project_scaffold.py
│ └── test_train_model.py
└── docs/
└── superpowers/
├── plans/
│ └── 2026-04-16-nlp-streamlit-app.md
└── specs/
└── 2026-04-16-nlp-streamlit-design.md
Install dependencies:
python3 -m pip install --user -r requirements.txtRun the full test suite:
python3 -m pytest -vTrain the model artifact:
python3 train_model.pyStart the Streamlit app:
python3 -m streamlit run app.pyTrain:
python3 train_model.pyExpected output:
Saved model to artifacts/emotion_model.joblib
Accuracy: 0.8638
Run app:
python3 -m streamlit run app.pyPush main to GitHub:
git push -u origin main- Open
https://share.streamlit.io - Sign in with GitHub
- Click
Create app - Select repository
sumitjadhav1703/Sentiment_analysis - Select branch
main - Set main file path to
app.py - Choose a Python version supported by Streamlit Cloud
- Click
Deploy
- The notebook
NLP_NEW.ipynbis included as the original exploration and experimentation source. - The training and deployment plan is included in
docs/superpowers/plans/2026-04-16-nlp-streamlit-app.md. - The design spec is included in
docs/superpowers/specs/2026-04-16-nlp-streamlit-design.md.