DEV Community

Cover image for Built a Sentiment Analysis Web App – My First Full-Stack ML Project
Elchin Nasirov
Elchin Nasirov

Posted on

Built a Sentiment Analysis Web App – My First Full-Stack ML Project

Hey dev.to 👋

After spending a month learning Machine Learning through Andrew Ng’s specialization, I wanted to build something real — not just notebooks.

So I created a Sentiment Analysis Web App — a full-stack project that takes any text and predicts whether it's Positive or Negative.

What I Built

  • Frontend: React with clean, modern UI
  • Backend: Flask API
  • ML Model: Random Forest using Scikit-Learn + TF-IDF
  • Features: Real-time prediction, confidence score, prediction history

Tech Stack

  • React (frontend)
  • Flask + Flask-CORS (backend)
  • Scikit-Learn (RandomForestClassifier)
  • TF-IDF Vectorizer for text processing

What I Learned

  1. From theory to practice — Going from notebooks to a real web app was the biggest leap.
  2. Connecting frontend and backend — Handling API calls, CORS, and state management.
  3. Model limitations — Small training data leads to bias. I learned the hard way why pre-trained models or larger datasets matter.
  4. Full-stack thinking — ML is not just about the model. Deployment, UI/UX, and user experience are equally important.

Challenges I Faced

  • Version conflicts between Colab and local environment
  • Model bias toward "Positive" predictions

Project Structure

sentiment-analysis/
├── backend/ # Flask API + ML model
│ ├── app.py
│ ├── train_model.py
│ └── sentiment_model.pkl
│
└── frontend/ # React application
├── src/
└── package.json

GitHub Repo: You can check out the full project here:

machine-learning-projects

(Go to projects/sentiment-analysis/ folder)

How to Run Locally

cd backend
python3 train-model.py
python3 app.py

cd frontend
npm start

What's Next?

I’m continuing to study ML and will be sharing more projects:

  • Image classification
  • Recommendation systems
  • More full-stack ML apps

If you're also learning ML, I'd love to hear your journey in the comments!

Top comments (0)