楼主: oliyiyi
1308 0

Political Data Science: Analyzing Trump [推广有奖]

版主

已卖:2994份资源

泰斗

1%

还不是VIP/贵宾

-

TA的文库  其他...

计量文库

威望
7
论坛币
84105 个
通用积分
31671.0967
学术水平
1454 点
热心指数
1573 点
信用等级
1364 点
经验
384134 点
帖子
9629
精华
66
在线时间
5508 小时
注册时间
2007-5-21
最后登录
2025-7-8

初级学术勋章 初级热心勋章 初级信用勋章 中级信用勋章 中级学术勋章 中级热心勋章 高级热心勋章 高级学术勋章 高级信用勋章 特级热心勋章 特级学术勋章 特级信用勋章

楼主
oliyiyi 发表于 2016-6-26 17:59:18 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

This post shares some results of political text analytics performed on Twitter data. How negative are the US Presidential candidate tweets? How does the media mention the candidates in tweets? Read on to find out!

By Quentin Simms, ParseHub.

The US Presidential Primaries have been the world’s biggest news sensation for the past 12 months, and the coverage will only increase now that both major parties have their presumptive nominees for the general election. Twitter is one of the most powerful media platforms used by news stations and politicians alike, so I explored just how many, and what kind, of political messages were being seen by the public during the month of May – at the end of the presidential primaries. In total I collected and analyzed 27,000 tweets by combining the powerful graphical web scraping tool ParseHub and the sentiment analysis API from text-processing.com with python and Jupyter Notebook.

The data was collected from the twitter accounts of the candidates and USA’s biggest new sources – Fox News, MSNBC and CNN. The process I used to scrape the data and to analyze sentiment can be repeated for any twitter account of media page. You can analyze any data from the web with Python by yourself, instead of paying consultancies that will charge you thousands of dollars. I will show you exactly how here.

Does Donald Trump get the most media attention?


Over half of @msnbc’s last 3000 tweets mention a primary candidate. Two-thirds of the total tweets for political accounts of CNN (@cnnpolitics), Fox News (@foxnewspolitics) and NBC mention (@NBCpolitics) mentioned a candidate.

Majority of the attention fell on one very specific and most controversial candidate. Donald Trump received ~60% of the mentions by every single one of the 6 media twitter accounts. Between February and May, Trump received more mentions than all three of his Republican opponents combined from @NBCpolitics and @foxnewspolitics. This leads me to wonder -– if this attention continues, will it decide whether Trump wins the general election?

Are Donald Trumps tweets really that insulting?


Trump is infamous for the insults and accusations he makes on twitter. The sentiment analysis tool detected that he did, in fact have the highest percentage of negative tweets. The most surprising result, as you can see from the graph below, is that Trump also has the greatest percentage of tweets that registered as positive.

Looking over Trump’s tweets I can confirm he does in fact tweet a lot of positive things, which I assume go unnoticed due to the more aggressive tweets. I did notice that many of the ones flagged positive did in fact contain insults, however.

For example, Trump has “insulting” nicknames for everyone – “Crazy Bernie Sanders”, “Crooked Hillary Clinton” and “Goofy Elizabeth Warren”. Despite the insults, the tweets have an undeniably enthusiastic tone. Thus, text-analysis.com picked up on more positive sentiment than negative sentiment.

Out of Clinton, Sanders and Trump, Trump was the only candidate who was consistently more often negative than positive when mentioning the other candidates. You can see in the graph below that this is true for all five of his political opponents.

Hillary Clinton talked about Donald Trump far more often than she talked about her direct opponent, Bernie Sanders. When she mentioned Trump, her tweet was more often negative than positive.

Meanwhile, Sanders mentioned Clinton far more often than he mentioned Trump during his campaign. His tweets were predominantly neutral compared to his opponents, but his tweets that mention Clinton were almost as likely to have a negative sentiment than a positive one.

How does the media mention the candidates?


I expected that Fox News would show more negative sentiment when mentioning Bernie Sanders, based on the public’s perception that they cater to a conservative audience. This turned out to be the complete opposite of the truth: for both @foxnews and @foxnewspolitics, Donald Trump received the most negative sentiment, followed by Hillary Clinton and then Bernie Sanders with less negative sentiment than either.

How I got the results
  • To get the 3,000 most recent tweets for each twitter account I used a website called snapbird.org.
  • To automate the process of collecting 27,000 tweets I used a web scraping tool called ParseHub. It is available as a desktop app and no coding was required to get the data.
  • Snapbird.org had a number of interactive interactive elements that I had to deal with when collecting my data: an ajax pop-up window, text input boxes to search of the twitter account and a load more button that added more tweets to the bottom of the page. I also had to log-in with my Twitter account before being able to collect all of the data.
  • I quickly put together a set of instructions that would crawl the text and date of every available tweet for any given account behind a log-in. See ParseHub’s documentation to see what else it can do.
  • I integrated the text-processing.com API into my iPython Notebook. I looped through the text of each tweet in the pandas objects and sent them, through an HTTP Post, to the text-processing.com URL.
  • In return I was sent a JSON with two elements which I saved into the pandas objects: the “negative”, “neutral” or “positive” label, as well as the probabilities for each sentiment that the API calculated. To learn more about the text-processing.com API, check out the demonstrations here.

A complete summary of my results and more interesting statistics about the presidential race can be found in this article here. I put the specific ParseHubinstructions and HTTP POSTS that I used in this step-by-step tutorial. It will teach you to mine the sentiment of tweets just as I did for this article, and will give you an idea of how it can be done for other social media sites.

To see the entirety of my python code and tables of data, see the second part of the tutorial, where I explain my process for creating the graphs in this article.

Bio: Quentin Simms is all about growth and marketing at ParseHub. Lover of statistics and data visualizations. Engineering physics students at Queen's University for 8 months of the year, catching up on lost sleep for the other 4.



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Data Science Political Analyzing Science politic Trump sensation performed political increase

缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-30 02:45