Back Page

Youtube Sentiment Analysis

A YouTube sentiment analysis model uses machine learning and NLP to classify user comments as positive, negative, or neutral, helping understand audience reactions, improve content strategy, and gain insights from large-scale feedback.

PyTorchNLPMLops
Gallery 0

End-to-end YouTube Sentiment

Environment Setup

conda create -n youtube python=3.11 -y
conda activate youtube
pip install -r requirements.txt

DVC

dvc init
dvc repro
dvc dag

AWS Setup

aws configure

API Demo (Postman)

Endpoint:

http://localhost:5000/predict

{
                  "comments": [
                    "This video is awsome! I loved a lot",
                    "Very bad explanation. poor video"
                  ]
                }

AWS CI/CD Deployment with GitHub Actions

1. Login to AWS Console

2. Create IAM User

  • EC2 Access (Virtual Machine)
  • ECR (Elastic Container Registry)

Deployment Flow:

  • Build Docker Image
  • Push to ECR
  • Launch EC2
  • Pull Image from ECR
  • Run Docker Container

Policies:

  • AmazonEC2ContainerRegistryFullAccess
  • AmazonEC2FullAccess

3. Create ECR Repository

Example URI:

315865595366.dkr.ecr.us-east-1.amazonaws.com/youtube

4. Create EC2 (Ubuntu)

5. Install Docker in EC2

sudo apt-get update -y
sudo apt-get upgrade
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker ubuntu
newgrp docker

6. Setup Self-Hosted Runner

Go to GitHub → Settings → Actions → Runner → Add New Runner and follow steps

7. GitHub Secrets

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=us-east-1
AWS_ECR_LOGIN_URI=566373416292.dkr.ecr.ap-south-1.amazonaws.com
ECR_REPOSITORY_NAME=simple-app