Election 2016: Tracking Emotions with R and Python

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Temperament has been a key issue in the 2016 presidential election between Hillary Clinton and Donald Trump, and an issue highlighted in the series of three debates that concluded this week. Quantifying “temperament” isn’t an easy task, but The Economist used the Microsoft Emotion API to chart the anger, contempt, sadness and surprised expressed in the faces of the candidates during key sequences of the debates, like this from the third debate: Economist Data Journalist Ben Heubl explains how you can analyze emotions in a video file using Python and R. The Emotion API provides scores for eight attributes of emotion as expressed by a face in a still image or video clip. For example, this expression by Donald Trump expresses mostly anger, with a touch of disgust and a soupçon of contempt. Face4 Ben provides Python code for passing a video clip into the Emotion API and retriving frame-by-frame emotion scores. He then uses R to analyze and chart the scores: mostly happiness for Clinton; mostly sadness for Trump. Facial Ben points out that emotion and sentiment analysis can be useful tools for data journalists, noting for example:
Facial recognition data, as the one that we collected via the Microsoft emotion API, suggests that when Trump is challenged with arguments which he doesn’t like, his facial attitude changes. In the second debate, Clinton provoked him with mentioning his involvement in degrading a former Miss Universe. His expression promptly changed to a mixture of an angry and sad expression.
For more analysis of emotion in the debates, including a text-based sentiment analysis of the debate transcript, check out Ben’s complete blog post linked before. And be sure to check out the original article about the debates from The Economist. Ben Heubl: How to apply face recognition API technology to data journalism with R and python

To leave a comment for the author, please follow the link and comment on their blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)