<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/election-2016-tracking-emotions-with-r-and-python/"></div></div><div><a data-url="https://www.r-bloggers.com/election-2016-tracking-emotions-with-r-and-python/" data-counturl="https://www.r-bloggers.com/election-2016-tracking-emotions-with-r-and-python/" data-count="horizontal" data-text="Election 2016: Tracking Emotions with R and Python" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2016/10/debate-emotions.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>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 <a target="_blank" rel="nofollow" href="http://www.economist.com/blogs/graphicdetail/2016/10/daily-chart-12">The Economist</a> used the Microsoft <a target="_blank" rel="nofollow" href="https://www.microsoft.com/cognitive-services/en-us/emotion-api">Emotion API</a> 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:</p>
<p></p>
<p><em>Economist</em> Data Journalist Ben Heubl explains how you can <a target="_blank" rel="nofollow" href="https://benheubl.github.io/data%20analysis/fr/">analyze emotions in a video file</a> 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.</p>
<p><a target="_blank" rel="nofollow" href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01bb0948a77e970d-pi"><img title="Face4" alt="Face4" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01bb0948a77e970d-800wi" border="0"></a></p>
<p>Ben provides Python code for passing a <a target="_blank" rel="nofollow" href="https://youtu.be/IIw025m0c7U">video clip</a> 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.</p>
<p><a target="_blank" rel="nofollow" href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8a5910a970b-pi"><img title="Facial" alt="Facial" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8a5910a970b-800wi" border="0"></a></p>
<p>Ben points out that emotion and sentiment analysis can be useful tools for data journalists, noting for example:</p>
<blockquote>
<p>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.</p>
</blockquote>
<p>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 <a target="_blank" rel="nofollow" href="http://www.economist.com/blogs/graphicdetail/2016/10/daily-chart-12">original article about the debates</a> from The Economist.</p>
<p>Ben Heubl: <a target="_blank" rel="nofollow" href="https://benheubl.github.io/data%20analysis/fr/">How to apply face recognition API technology to data journalism with R and python</a></p>
</div>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/election-2016-tracking-emotions-with-r-and-python/"></div></div><div><a data-url="https://www.r-bloggers.com/election-2016-tracking-emotions-with-r-and-python/" data-counturl="https://www.r-bloggers.com/election-2016-tracking-emotions-with-r-and-python/" data-count="vertical" data-text="Election 2016: Tracking Emotions with R and Python" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2016/10/debate-emotions.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/niXvibxmKjo"></a></div>