🚀 Python AI Sentiment Analysis is a powerful AI-driven project that extracts comments from YouTube videos and classifies their sentiment using three different models: BERT, RoBERTa, and OpenAI's GPT models. This allows a deeper comparison between models and provides valuable insights into audience reactions.
✅ Scrapes YouTube comments via API
✅ Applies sentiment analysis with BERT, RoBERTa, and OpenAI GPT
✅ Compares results using Confusion Matrices
✅ Generates insightful visualizations
The project follows this pipeline:
1️⃣ Extract comments from YouTube using the YouTube API.
2️⃣ Process comments using Natural Language Processing (NLP).
3️⃣ Apply sentiment classification using BERT, RoBERTa, and OpenAI's GPT.
4️⃣ Compare results using confusion matrices and statistical analyses.
5️⃣ Generate visualizations to better understand sentiment distributions.
📦 python_ai_sentiment_analysis
┣ 📜 youtube_sentiment_analysis.ipynb # Main script
┣ 📜 requirements.txt # Project dependencies
┣ 📜 README.md # Documentation
git clone https://github.com/RenanBjj/Python-AI-Sentiment-Analysis.git
cd Python-AI-Sentiment-Analysispip install -r requirements.txtCreate a .env file and add your credentials:
YOUTUBE_API_KEY=your_youtube_api_key
OPENAI_API_KEY=your_openai_api_keypython youtube_sentiment_analysis.pyThe system generates bar charts displaying the distribution of sentiments across different models.
We compare how well the models align using heatmaps that illustrate model agreement and divergence.
Example of Confusion Matrix for BERT vs OpenAI:
plt.figure(figsize=(8, 6))
sns.heatmap(conf_matrix, annot=True, fmt='d', cmap="Blues", linewidths=0.5, linecolor='gray')
plt.title("Confusion Matrix: BERT vs OpenAI Sentiments")
plt.xlabel("Sentiment OpenAI")
plt.ylabel("Sentiment BERT")
plt.show()🔹 Python 3.8+
🔹 Pandas & NumPy - Data handling and manipulation
🔹 Matplotlib & Seaborn - Data visualization
🔹 Transformers (Hugging Face) - BERT & RoBERTa models
🔹 OpenAI API - Sentiment classification via ChatGPT
🔹 Google YouTube API - Fetching YouTube comments
Want to enhance this project? Here’s how you can help:
✅ ⭐ Star this repository to show support!
✅ 💡 Open an issue with suggestions or improvements.
✅ 📌 Submit a pull request with new features or optimizations.
This project is open-source under the MIT License. Feel free to use, modify, and share! 🚀
👨💻 Developed by Renan Marques - Bringing AI to Data! 🚀
