Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

US Presidential Debate 2024: Sentiment & Emotion Analysis

A comprehensive computational analysis of the September 10, 2024 presidential debate between Vice President Kamala Harris and Former President Donald Trump, hosted by ABC News in Philadelphia.

Overview

This project applies natural language processing (NLP) and sentiment analysis techniques to extract insights from the debate transcript, examining:

  • Sentiment patterns (polarity and subjectivity) across different topics
  • Emotional tone of each candidate's rhetoric
  • Topic distribution and focus areas
  • Temporal sentiment evolution throughout the debate

Features

  • Data Preprocessing: Automated text cleaning and speaker separation using regular expressions
  • Topic Classification: Multi-topic categorization including Economy, Immigration, Foreign Policy, Healthcare, Climate Change, and more
  • Sentiment Analysis: Polarity and subjectivity scoring using TextBlob
  • Emotion Detection: Granular emotion classification using NRCLex
  • Sliding Window Analysis: Temporal sentiment tracking across the debate timeline
  • Rich Visualizations: Heatmaps, line plots, and distribution charts for comprehensive insights

Dataset

Source: ABC News Presidential Debate Date: September 10, 2024 Location: National Constitution Center, Philadelphia, PA Moderators: David Muir and Linsey Davis Participants: Vice President Kamala Harris and Former President Donald Trump

The debate transcript (debate_transcript.txt) includes the complete exchange between candidates across multiple policy areas.

Methodology

1. Data Preprocessing

  • Removal of moderator commentary
  • Speaker-specific text extraction
  • Sentence-level segmentation
  • Keyword-based topic classification

2. Sentiment Analysis

  • Polarity: Measures positive vs. negative sentiment (-1 to +1)
  • Subjectivity: Measures factual vs. opinionated language (0 to 1)
  • Sliding Window: 50-word windows to track sentiment evolution

3. Emotion Analysis

  • Multi-dimensional emotion scoring (anticipation, joy, trust, fear, surprise, sadness, anger, disgust)
  • Dominant emotion identification per statement
  • Cross-tabulation of emotions by topic and speaker

Key Visualizations

  1. Polarity Over Time: Line chart showing sentiment trends throughout the debate
  2. Subjectivity Over Time: Evolution of objectivity vs. subjectivity in language
  3. Topic Distribution: Frequency of topics discussed by each candidate
  4. Dominant Emotions: Comparative emotion profiles between candidates
  5. Topic-Sentiment Heatmaps: Average polarity and subjectivity by topic and speaker
  6. Emotion-Topic Heatmap: Distribution of emotions across different discussion topics

Installation

Prerequisites

  • Python 3.7+
  • Jupyter Notebook or JupyterLab

Dependencies

Install required packages:

pip install pandas matplotlib seaborn textblob nrclex

Download TextBlob corpora:

python -m textblob.download_corpora

Usage

  1. Clone this repository:
git clone https://github.com/aaliusama/US_Presidential_Debates_Analysis.git
cd US_Presidential_Debates_Analysis
  1. Launch Jupyter Notebook:
jupyter notebook
  1. Open debate_analysis.ipynb and run all cells sequentially.

Project Structure

├── debate_analysis.ipynb          # Main analysis notebook
├── debate_transcript.txt          # Raw debate transcript data
└── README.md                      # Project documentation

Key Findings

The analysis reveals distinct rhetorical patterns between the two candidates across multiple dimensions:

  • Sentiment Patterns: Comparative polarity scores show varying approaches to positive vs. negative framing
  • Topic Focus: Clear differences in topic emphasis and distribution
  • Emotional Tone: Distinct emotion profiles characterizing each candidate's communication style
  • Temporal Dynamics: Evolution of sentiment intensity throughout the debate

For detailed results and visualizations, please refer to the Jupyter notebook.

Technologies Used

  • Python: Core programming language
  • Pandas: Data manipulation and analysis
  • TextBlob: Sentiment polarity and subjectivity analysis
  • NRCLex: Emotion detection and classification
  • Matplotlib & Seaborn: Data visualization
  • Regular Expressions: Text preprocessing and pattern matching

Future Enhancements

  • Comparative analysis with previous presidential debates
  • Real-time sentiment tracking during live debates
  • Topic modeling using LDA or other advanced NLP techniques
  • Fact-checking integration
  • Audience reaction correlation analysis

License

This project is available for educational and research purposes.

Author

Ali Usama

Acknowledgments

  • ABC News for the debate transcript
  • TextBlob and NRCLex development teams for their excellent NLP libraries

About

A comprehensive computational analysis of the September 10, 2024 presidential debate between Vice President Kamala Harris and Former President Donald Trump, hosted by ABC News in Philadelphia.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages