An end-to-end machine-learning web app: it trains a sentiment classifier, persists it, and serves live predictions through a clean Streamlit interface.
Part of Hamza Naeem's AI portfolio.
- Full ML lifecycle — train → save (
joblib) → load → predict, not just a script. - Clean separation — model logic in
model.py(unit-tested), UI instreamlit_app.py. - Interactive UI — type text, get a positive/negative label with a confidence bar.
- Tested —
pytestsuite covers training, prediction, persistence, and accuracy.
git clone https://github.com/hamzanaeem627/ml-sentiment-webapp.git
cd ml-sentiment-webapp
pip install -r requirements.txt
streamlit run streamlit_app.pyThen open the local URL Streamlit prints (usually http://localhost:8501).
from model import SentimentModel
model = SentimentModel.load_or_train()
print(model.predict("I absolutely loved this"))
# {'label': 'positive', 'confidence': 0.78, 'positive_probability': 0.78}pytestmodel.py # TF-IDF + Logistic Regression pipeline (train/save/load/predict)
streamlit_app.py # thin Streamlit UI
test_model.py # pytest suite
Swap SEED_DATA in model.py for your own labeled dataset (list of
(text, label) where 1 = positive, 0 = negative) to train on real data.
Built by Hamza Naeem — AI Engineer. Portfolio · LinkedIn · GitHub
MIT