Sign inSign up

raghottam465/sentiment-app

By raghottam465

β€’Updated about 1 year ago

Flask Sentiment Analysis App

Image
Machine learning & AI
0

120

raghottam465/sentiment-app repository overview

⁠🧠 Flask Sentiment Analysis App with Docker

This project is a Flask-based Sentiment Analysis Web Application that uses Machine Learning to classify user-provided text (tweets, reviews, comments) into Positive or Negative sentiment. It’s designed to be lightweight, containerized using Docker, and deployable on any cloud platform like AWS EC2.

🎯 Main Aim The goal of this project is to:

  • Provide a simple, interactive web interface to classify sentiments in real-time
  • Use pre-trained NLP models for efficient predictions
  • Learn and implement Docker for containerizing ML applications
  • Deploy the containerized app to the cloud (e.g., AWS EC2) for public access

⁠🧠 Core Features

  • Flask web app with clean UI (index.html)
  • Accepts user text input and performs live sentiment prediction
  • Pre-trained Naive Bayes Classifier using TF-IDF vectorization
  • Fully containerized with Docker
  • Publicly accessible via deployment on AWS EC2

⁠Steps to Clone the GitHub Repo:

  • Clone the GitHub repo
  • Run the app locally
  • Containerize it using Docker
  • Push the image to Docker Hub
  • Run it anywhere using Docker

β πŸ“ Project Structure

sentiment-app/
β”œβ”€β”€ Dockerfile # Docker build instructions
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ sent.py # Main Flask application
β”œβ”€β”€ tfidf1_tweets.pkl # Pre-trained TF-IDF vectorizer
β”œβ”€β”€ NaiveBayes_Tweets.pkl # Pre-trained Naive Bayes model
└── templates/
└── index.html # Frontend HTML page

⁠🧾 Prerequisites

- Git
- Docker installed and running
- Docker Hub account

⁠🧬 Step-by-Step Instructions

β βœ… Step 1: Clone the Repository

git clone https://github.com/raghottam465/sentiment-app.git
cd sentiment-app

⁠πŸ–₯️ Deploy Dockerized Flask Sentiment App on Amazon Linux EC2

## βœ… Step 1: SSH into EC2 (Replace with your actual .pem and public IP)
ssh -i your-key.pem ec2-user@your-ec2-public-ip

## βœ… Step 2: Install Docker using yum
sudo yum update -y
sudo yum install docker -y


## βœ… Step 3: Start and enable Docker service
sudo systemctl start docker
sudo systemctl enable docker

## βœ… Step 4: Add ec2-user to docker group (logout and login again after this)
sudo usermod -aG docker ec2-user

## ⚠️ Important: After running the command above, log out and SSH again to apply the group change:
exit

## Then reconnect:
ssh -i your-key.pem ec2-user@your-ec2-public-ip

⁠🐍 Step 2: (Optional) Run Locally Without Docker

pip install -r requirements.txt
python sent.py

⁠🐳 Step 3: Create Docker Image

docker build -t sentiment-app .

β βœ… Step 4: Run Docker Container Locally

docker run -d -p 5000:5000 sentiment-app

⁠🐳Step 5: Login to Docker Hub

docker login

β βœ… Step 6: Tag the Docker Image

docker tag sentiment-app raghottam465/sentiment-app:latest

⁠🐳Step 7: Push to Docker Hub

docker push raghottam465/sentiment-app:latest

β βœ… Step 8: Pull and Run Anywhere

docker pull <username>/sentiment-app:latest
docker run -d -p 5000:5000 <username>/sentiment-app
⁠🧰 Libraries and Technologies Used
CategoryLibrary/ToolPurpose
BackendFlaskWeb framework for Python
ML/NLPScikit-learnNaive Bayes classifier & TF-IDF vectorizer
PickleModel serialization (load .pkl files)
WebHTML, Jinja2Frontend interface with Flask templates
ContainerDockerContainerization of app
DeploymentAWS EC2 (Ubuntu)Cloud hosting for Docker container

click here : https://hub.docker.com/r/raghottam465/sentiment-app⁠

β βœ… Use Cases

  • Customer feedback analysis
  • Social media sentiment tracking
  • Product review classification
  • Beginner-friendly ML + Docker + EC2 deployment example

Tag summary

Content type

Image

Digest

sha256:2ddf50092…

Size

254.3 MB

Last updated

about 1 year ago

docker pull raghottam465/sentiment-app