How positive are 2016's candidates during presidential debates?

Update: this article was featured in The US News & World Report.

While watching some of 2016's presidential debates, I remember having the distinct feeling that some candidates appeared to view the United States as a country replete with problems to solve rather than opportunities to grow. Indeed, it seemed to be a far cry from President Obama's rallying call of hope, the ideological platform that propelled him to the White House in 2008. While diction may be no more than how one frames the same situation, a candidate's level of a positivity can play an important role in how they are viewed by the public.

Using the full debate transcripts from UC Santa Barbara's "The American Presidency Project", I evaluated just how positive the candidates were during debates. For each debate, I combined each candidate's speech, then passed it through a natural language processor located here (see footnote 1) to calculate the sentiment.

Both Hillary Clinton and Bernie Sanders maintained a fairly high level of positive language throughout their debates, only dropping to 50% in the February 11th debate.

Jeb Bush, Ted Cruz and Marco Rubio equally tilted toward positive language, on par with the Democratic candidates. Chris Christie spiked lower at times (sometimes significantly), as did John Kasich.

However, there is one candidate who, as usual, found a way to differentiate himself:

The data speaks for itself: Donald Trump is extremely negative.

All in all, there is surprisingly more positive language than I expected. In a later project, it could be worthwhile to compare these results to President Obama's debate transcripts in 2008 and 2012.

1. This data set uses Python's natural language toolkit package ("nltk") to evaluate sentiment in text. It was trained on Twitter messages and movie reviews - as a result, it may not be as accurate as it would be by using actual political speeches.

Code, data and graphs for this project can be found on GitHub.