<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by MarketLytics on Medium]]></title>
        <description><![CDATA[Stories by MarketLytics on Medium]]></description>
        <link>https://medium.com/@marketlytics?source=rss-dac537ebe777------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gHVLr-2y_A8cCl_P.png</url>
            <title>Stories by MarketLytics on Medium</title>
            <link>https://medium.com/@marketlytics?source=rss-dac537ebe777------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 15:52:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marketlytics/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Kaptaan in the light of Data: Exploratory and Sentiment Analysis — Part 2]]></title>
            <link>https://medium.com/@marketlytics/kaptaan-in-the-light-of-data-exploratory-and-sentiment-analysis-part-2-5cb5fbaab14e?source=rss-dac537ebe777------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cb5fbaab14e</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[election-2018]]></category>
            <category><![CDATA[imran-khan]]></category>
            <dc:creator><![CDATA[MarketLytics]]></dc:creator>
            <pubDate>Wed, 22 Aug 2018 09:03:01 GMT</pubDate>
            <atom:updated>2018-08-22T09:03:01.370Z</atom:updated>
            <content:encoded><![CDATA[<p><em>By Rehan Ahmed</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*8QC_el53R9gzLoI1.jpeg" /></figure><p>This is the second part in a series analyzing sentiment about Imran Khan in over eight hundred articles written about him in Dawn since 2004. To read the first part, please visit <a href="http://marketlytics.com/blog/kaptaan-in-the-light-of-data">here</a></p><p>One of the most interesting tools in a data scientist’s toolbox is sentiment analysis. Belonging to the branch of Natural Language Processing, Sentiment Analysis is the ability to evaluate a people’s opinion about something, or in this case, someone.</p><h3>WHAT IS SENTIMENT?</h3><p>Simply put, sentiment is the view or opinion of a person about a subject. It can be anything from anger, sympathy, sadness, happiness, hate, love, basically the whole spectrum of emotions a human being is capable of feeling.</p><p>Sentiment Analysis is a technique that tries to evaluate the exact sentiment from a given sentence. There are a number of different algorithms in use today, each with its own pros and cons. While some try to evaluate the sentiment by checking the ratio of positive to negative words — using a bag of words model, others take a more efficient yet complicated approach by judging the sentence as a whole. This allows it to handle negation in a sentence, for example, knowing the difference between ‘I am happy’ and ‘I am not happy’.</p><p>I will take a detailed look at the different methods I tried out and which one worked best for me in the third part of this series. Meanwhile, for the purpose of this article, here is some basic terminology I would like you to get used to before reading on,</p><p>Basic Terminology</p><ul><li><em>Article Score </em>— The sentiment score of the overall article, found out by averaging the sentiment of each sentence in the article. I wanted to capture the sentiment of all the comments, and also consider the ones that were extremely leaning to one side (positive or negative) so I used a mean instead of a median. I found this to be a more accurate measure of the overall comments polarity.</li><li><em>Comment Score</em> — The sentiment score of all the comments on an article, found out by averaging the sentiment of each comment on that article.</li><li><em>Title Score</em> — The sentiment score of the Article’s title</li></ul><p>Here is a sample<a href="https://www.dawn.com/news/1419616"> article</a> and how it resides in my dataset,</p><h3>Imran Khan summoned by NAB for ‘misusing’ KP govt’s helicopters</h3><p><em>Title Score: </em>— 0.189</p><p><em>Article Score: </em>0.039</p><p><em>Comment Score: </em>— 0.0169 Positive to Negative Words: 35/939</p><p>The Title, quite obviously negative (but not too negative), is captured quite accurately in the title score. The article, covered in a more factual way rather than an op-ed article, loses the negativity a bit and shows a moderately neutral score. The comments on the page are clearly negative but the score doesn’t reflect that after it has been averaged out.</p><h3>The Analysis</h3><p>First, I managed to gather all the 38,866 comments in one data frame and found out their Comment Scores. Then, in another data frame that contained all the articles, I found the Article Score and the Title Score. Lastly, I merged these into one grouped data frame that now contained one row for each article, containing the author name, the publishing date, the title, the Title Score, the Article Score, the Comment Score, and the number of total positive and negative words in the comments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*I8A9rX5fRXLexOlS.png" /></figure><p>Then, I plotted this on a scatter plot by year, using the Comment Score as the y-axis. Here, it shows how the polarity for each article’s comments has changed over time (the dotted black line is the neutral line),</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*myhaTyBE6VvKn49k.png" /></figure><p><em>The bigger the dot, the more the comments (hype) on that date. The higher the dot above the black dotted line, the more positive the comments will be.</em></p><p><em>The red line shows the median and the yellow line represents the mean.</em></p><p>There is a noticeable positive spike in the graph over 2015, showing an increase in positive sentiment in the comments on the articles written that year. To see the difference more closely, I plotted both — the positive articles (average polarity of comments greater than 0) and the negative articles (average polarity of comments less than 0) separately, showing how positive interest changes significantly over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*_9PNTkVLlPKrHUPS.png" /></figure><p>I also used the bag of words model to find the ratio of positive to negative words in each article’s comment section. However, as you can see in the scatter plot below, this didn’t give me any meaningful results except the fact that, the people commenting on Dawn’s website tend to use a lot more negative words than positive ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*02XF72dbAuQAo9DC.png" /></figure><p>The articles above the dotted line have more positive words than negative words in the comments.</p><blockquote><em>“Only one article had comments with a total positive word count higher than the total negative word count.<br>”</em></blockquote><p>While 2014 was the year when interest around Imran Khan spiked, he attracted mostly neutral comments, but you can see how in 2015, the median, as well as the mean, jumps up considerably. This was the year when Imran Khan got married to Reham Khan and resolved most of his conflicts.<a href="https://www.dawn.com/news/1156062/pti-celebrates-imrans-marriage"> Imran Khan’s marriage</a> in January of 2015 attracted pretty positive comments, but his<a href="https://www.dawn.com/news/1191667"> nephew’s subsequent arrest</a> and his<a href="https://www.dawn.com/news/1195674"> backing of talks with the TTP</a> brought down the average a bit. Overall however, this one was one of his best years.</p><p>To look closer, I plotted a graph of just 2015 and looked at the articles with the average sentiment score in the top 5% or the lowest 5% — i.e. the articles with the most positive and the most negative comments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Q9QR1J4SyPqjx3lT.png" /></figure><p>The grey line represents the moving average for sentiment scores</p><p>For comparison, here is a look at 2018,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*pHjmDoxm2pnDnSYI.png" /></figure><p><strong>A look at the articles with the 1% most positive and the 1% most negative comments from 2011 to 2018,</strong></p><p>A look at the articles with the 1% most positive and the 1% most negative comments from 2011 to 2018,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*kKEX8iN2lH60wG0i.png" /></figure><p>One interesting thing I noticed, while looking at the outliers that got picked out above, is that the text of the articles with the most positive or negative comments had significant polarity as well.</p><p>To see if there was a relationship between how positive or negative an article was and how positive or negative the comments on that article were, I plotted another scatter plot with each article’s Article Score vs the Comment Score,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*PFxXuWscEfawU4Jq.png" /></figure><p>Since the sentiment score is averaged out over all the comments, I didn’t see as much variance in it as I saw in the polarity of each individual article. But to really see if an article affected the polarity, I decided to remove the most neutral articles (between a polarity of -0.1 and 0.1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*TYL16MweTHOvNBNc.png" /></figure><p>While the comments for the articles with negative polarity are spread out evenly between negative and positive, I found a significant relation between a positive article’s Article Score and the sentiment of comments on that article.</p><p>‘94.2% of the articles with a positive sentiment score (above 0.1) had overall positive comments.’</p><p>What if we there was an even simpler way of predicting if an article’s comments would be positive or negative? Is it possible to predict it using just the title of the article? In the age of social media, people rarely go through the whole article before making a go for the comment box at the bottom. Does it affect their view?</p><p>Here is a scatterplot with the Title Score of an article on the x-axis and the Comment Score on the y-axis,</p><p>According to my findings, if an article’s title had a positive polarity score (0.1 or more), it had a 90.1% chance of getting positive comments overall. However, take this with a pinch of salt as this observation is made only on the topic of Imran Khan and 77.7% of the articles about Imran Khan already attracted positive comments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/0*79x3pIblYvWxQdDs.png" /></figure><p>For articles having an Article Score or Title Score below 0.1, there was no significant relation with comment polarity evenly spread out almost evenly.</p><h3>Does Article or Comment Polarity depend on the author?</h3><p>Lastly, I wanted to have a look if an author’s writing style had any effect on having the most polarity-charged comments or not. After removing the authors who wrote less than 4 articles and removing the generic names like ‘Dawn Staff’, ‘The Dawn Correspondent’, I plotted a bar chart with the authors who had the most positive comments overall.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*fAiO0LVXGDpTNlXs.png" /></figure><p><em>Green</em> — Average Comment Score</p><p><em>Red</em> — Average Article Score</p><p>You can see how Article Score is generally pretty close to the Comment Score. Next, I plotted the authors with the most negative comment score and you can see how, here too, the correlation between both of them is pretty noticeable. So, it is fair to say that an author’s writing style (or the type of the news he or she generally covers) can have an effect, even if not significant, on the general sentiment of the comments people post.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ZFx3HmfeZqOKKUoO.png" /></figure><p>It is interesting to see how much insights can be gathered by a simple analysis of one newspaper’s article on just one political personality. However, it isn’t without its own share of problems. Here are some of the biggest issues I faced,</p><ul><li>The sentiment analysis models available today are not ideally suited for use in Pakistan, especially for analyzing informal forms of communication like comments or messages — us Pakistanis have a serious problem of slipping into Roman Urdu everywhere.</li><li>There are only two ways to fix this problem; either build a syntactical model that is capable of dealing with Roman Urdu which will require a lot of time, hard work, and intelligent minds, but will be extremely useful for the future. Or build a training model by feeding it all the data that you possibly can which is extremely resource-intensive, requires you to have access to a treasure trove of data but won’t work as accurately as a syntactical model.</li><li>A lack of APIs for public forums, leading me to spend a lot of time designing and running web scraping scripts, as well as problems and limitations with the APIs for social networks — Twitter imposes a limit on the number of tweets you can download while Facebook doesn’t even allow access to public content without making you develop a legitimate application and making you go through a lengthy review process.</li><li>A lack of local resources or guides for working on a local project. While I found tons of tutorials detailing what and how to do, I didn’t find many good projects by Pakistani experts on doing a data analytics project. It is sad to see as I have come across a lot of people who are doing some great work in this field and could help a lot of people if they decided to share their experience and knowledge.</li></ul><p><em>Originally published at </em><a href="http://marketlytics.com/blog//kaptaan-in-the-light-of-data"><em>marketlytics.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cb5fbaab14e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Politycs — Political Analysis]]></title>
            <link>https://medium.com/@marketlytics/politycs-political-analysis-9adfc8841fff?source=rss-dac537ebe777------2</link>
            <guid isPermaLink="false">https://medium.com/p/9adfc8841fff</guid>
            <category><![CDATA[politics]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[analysis]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[MarketLytics]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 17:16:52 GMT</pubDate>
            <atom:updated>2018-07-26T17:16:52.086Z</atom:updated>
            <content:encoded><![CDATA[<p><em>By Jaweria Khan</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXYboC4ZEEin2VkXaZEH2w.png" /><figcaption><a href="https://www.flickr.com/photos/20119750@N00/1339936000">“Prime Minister’s Residence (Islamabad, Pakistan)”</a> by <a href="https://www.flickr.com/photos/bigberto/">Shubert Ciencia</a>, <a href="http://www.flickr.com/">Flickr</a> is licensed under <a href="http://creativecommons.org/licenses/by/2.0">CC BY 2.0</a></figcaption></figure><p>The long-awaited extraordinary elections are now on our doorsteps. In a democratic country like ours, elections with their utmost importance are the best way to make our voice heard. Our vote is not just a constitutional right, but our responsibility towards the nation.</p><blockquote><em>“Always vote for principle, though you may vote alone, and you may cherish the sweetest reflection that your vote is never lost.”~ John Adams”</em></blockquote><p>The General elections in Pakistan are scheduled to be held on 25th of July 2018. Since the establishment of Pakistan in 1947, as a democratic state, Pakistan has had a federal government consisting of two houses, named National Assembly (Urdu: ایوان زیریں پاکستان) and Provincial Assembly (Urdu:صوبائی اسمبلی).</p><p>In this report, our focus will be mainly on the National Assembly.</p><h3>How does the Electoral System work?</h3><p>The National Assembly consists of a total of 342 members. These are elected by two methods into 3 categories:</p><ol><li>272 are elected in single-member constituencies by popularity voting method, also known as first-past-the-post voting</li><li>60 seats are reserved for females</li><li>10 seats for religious and ethnic minorities</li></ol><p>To win a simple majority, a party would have to take at least 137 seats.</p><h3>Final Delimitation 2018</h3><p>General Elections 2018 will be held under new a delimitation of constituencies which was the result of 2017 census. As per the notification issued on March 5 2018, there are in total 272 constituencies. (A complete list of constituencies can be found <a href="https://www.ecp.gov.pk/Documents/delimitation2018/reports/02.National%20Assembly%20of%20Pakistan.pdf">here</a>.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/0*bLv7bJ7rQRn_Q1fB.png" /></figure><p>There will be a total of 122 parties competing in Pakistan for the General Elections and a total of 3,675 candidates in the electoral arena for the National Assembly’s seats this year. According to The Election Commission of Pakistan (ECP), 1,696 candidates are contesting from Punjab; 872 from Sindh; 760 from Khyber Pakhtunkhwa; and 303 will be contesting from Balochistan for the lower house of the Parliament. (A complete list of candidates can be found <a href="https://www.thenews.com.pk/latest/337844-pakistan-election-2018-list-of-national-assembly-candidates-for-general-election-2018">here</a>.)</p><h3>The History of Elections in Pakistan (1997–2013)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*9BxNAwCtsrnLUU04.png" /></figure><p>The Elections of 2013 are considered to be the most successful elections in the history of Pakistan with a total 47 million votes cast and the highest overall turnout (55%) ever recorded. Pakistan has always been one of the states that has a poor voter turnout, which was 41% on an average, till 2008. Surprisingly enough, elections of 2013 experienced a phenomenal overall increase of more than 11% in the voter turnout, raising the average turnout from 41.3% to 44.8% and labeling these elections as the most successful so far.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*5HhYxmzz4WoypTYK.png" /></figure><p>With Punjab being the most populated province of Pakistan having the highest number of votes cast, its contribution towards the General Elections is vital. It won’t be wrong to say that the elections in Punjab basically decide the fate of the General Election across the country. While the rest of the country has faced a drop in turnout in ’97, Sindh, however has seen a constant improvement throughout. In case of KPK we can observe an alternating pattern.</p><blockquote><em>“Did you notice the similarity between the overall turnout trend (black) and Punjab’s turnout trend?”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*bzlRA0-WZFei8u_C.png" /></figure><p>Even though we term 2013 as the most successful in terms of turnout, we also noticed that the elections of 2013 faced major discrepancies. The rejected votes rose to a high. 1.5 out of 47.2 million votes were rejected in 2013 alone. Around 6% votes from Balochistan, 3.7% from Sindh, 3.2% from KPK and 3% from Punjab were discarded.</p><p>The increase in the number of discarded votes is alarming. These discrepancies usually occur due to vote rigging and need to be paid attention upon since they affect the results adversely. In 2002, there were a total of 30 constituencies in Pakistan where the discarded votes were exceeding the votes that determined the victory (Margin of votes). These discrepancies increased in 2008 to 45 and reduced to 25 NA constituencies in 2013 out of which 16 belonged to Punjab, 4 to Sindh, 2 to Balochistan and only 1 to KPK.</p><p>Among the 16 seats in Punjab and 4 in Sindh, majority were won by PMLN and PPP respectively.</p><h3>Political Parties and their trends</h3><p>Among the major political parties are Pakistan Muslim League (Nawaz) — PMLN, winning a total of 415 seats in National Assembly so far from 1997, followed by Pakistan Peoples Party Parliamentarians- PPP, with 290 seats so far. If we plot the number of seats won by each party every year, we would see a graph similar to a child’s drawing depicting how unpredictable Pakistani politics and the fate of each party has been throughout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/0*w6U1-o8H4UM-XsFA.png" /></figure><p>Except however, we can notice an alternating behavior between the fate of PMLN and PPP. Everytime PMLN is successful in grabbing the majority votes, PPP fails and vice versa except for 2008 where both the parties formed a coalition government together. On the other hand, PTI (claiming to be the only non-family party) seems to have a exponential improvement from winning just one seat in 2002 to grabbing 28 in 2013 (skipping the elections of 2008). According to the 2013 election results, PTI was the third largest party in National Assembly, and emerged as the governing party of Khyber Pakhtunkhwa. PML-Q however reached its downfall in 2013 while MQM and Independents have maintained their positions. With respect to this behaviour and also the current political happenings around the country with Nawaz Sharif being arrested for corruption, it can be said that the prevailing conditions can be very much in favour of PPP and PTI. 2018 might also be the year for PPP to make a comeback given their campaign goes strong.</p><p>However, considering these number of seats won by the top 2 parties from 2002 to 2013, we can observe the increase in the Margin of Victory among them. The competition loosens and margin increases as we move forward. In 2002, the difference between the seats won by the top 2 parties was 15, which increased to 20 in 2008. However, 2013 was a one sided clean sweep by PMLN winning from 125 NA constituencies and PPP grabbing only 34 seats in the National Assembly.</p><p>Interestingly, plotting the same variables for the province of Punjab gives us a very similar graph which clearly establishes the fact that Punjab determines the fate of General Elections in Pakistan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/0*zSnMgU5pebntOHoX.png" /></figure><blockquote><em>“What determines the victory of a party? Contesting for a high number of constituencies or focusing on the quality of the candidates contesting for each seat?”</em></blockquote><p><strong>Considering the total number of seats for which a party contested each year versus the constituencies they won, we can determine what drives a party towards victory.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/0*y1FomXE2ahH2PxFV.png" /></figure><p><em>Blue — total constituencies<br>Purple — constituencies won</em></p><p>In 2008, out of 8 constituencies, PTI managed to win only 1 which was Imran Khan himself. While in 2013 even after exponentially increasing the number of constituencies to fight for, only 28 out of 172 candidates i.e 16.5% managed to win. On the other hand, parties like MQM managed to bag around 18 out of 33 seats in 2013, having a remarkable victory rate of 54%. Thus, rather than increasing the number of candidates, working on their credibility and a strong campaign might lead to better results.</p><h3>Sindh</h3><blockquote><em>“Increasing the number of candidates does not in any way promise a better winning rate.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/0*Bs8oYPCOgydnATmQ.png" /></figure><p>Since 2002, we can see that Pakistan People’s Party has been the most dominant among all other parties in Sindh. Winning the majority constituencies in the province, PPP has emerged as the governing party of Sindh in the past 3 elections. The voter turnout also seems to have improved from 2002 to 2013 in all of the constituencies of Sindh. For example, in NA 228 and NA 238 the turnout rose by 20% from 2008 to 2013 while the overall turnout increased by 10% in Sindh. The size of the bubbles here determines the closeness of the competition or margin of victory. In 2013, even though PPP managed to bag the majority of seats, the competition faced by them was very close.</p><p>The constituencies from NA-239 to NA-257 that belong to Karachi however favour MQM the most. The voter turnout in this urban city is the highest and MQM seems to have a stronger hold over the seats in 2013 as compared to the previous elections, having a large margin of victory and a low competition.</p><h3>Punjab</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/0*DHwQ9SI5HonH-hfV.png" /></figure><p>Punjab being the most important player in the elections of Pakistan with the highest number of constituencies (147 according to Delimitation 2002–2013) than any province, has seen a gradual shift of power from PPP &amp; PML-Q to PMLN. Where PPP and PMLQ influenced Punjab in 2002 winning the seats with a low margin, they seem to have little or no influence by 2013. PMLN seems to have a stronger grip on the politics in Punjab in 2013, winning majority seats with a high margin.</p><p>The voter turnout around NA 115 — NA 125 (Narowal District) seems to have doubled from 2002 to 2013. After further digging up the data, it appeared that most of PMLN’s prominent leaders namely Khuwaja Saad Rafique, Makhdoom M. Javed Hashmi, Sardar Ayaz Sadiq, Muhammad Riaz Malik, and Ahsan Iqbal have been contesting from these constituencies for the past two elections and winning them. These members have had a stronghold in these areas and their popularity attracts voters. However, one of the major reasons for this increase in turnout in 2013 can be the fact that two important players Hamza Shahbaz Sharif and Mian Muhammad Nawaz Sharif contested and won from NA-119 and NA-120 respectively in the elections of 2013. Similarly, NA 150 has seen a tough competition between two major parties, PMLN and PTI since 2002. After holding the office for two consecutive tenures, Rana Mehmood ul Hassan from PMLN lost to Makhdoom Shah Mehmood Qureshi in 2013.</p><h3>Balochistan</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*-Nz9ovwsVtZ6vVKN.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*oexHO3lBgSzzBM8H.png" /></figure><p>Balochistan being the least populated and the most neglected province of Pakistan consists of only 13 constituencies (now 14) . The political trends in this province aren’t very impressive or predictable. The voter turnout seems to have increased by 6% overall but NA-269 to NA- 272 (Khuzdar, Lasbela and Gwadar) have seen a downfall<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*4leQhuC3XLZK35NQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*geLEEv8SwAmA8Kst.png" /></figure><p>Khyber Pakhtunkhwa, consisting of around 35 constituencies (39 now) has also experienced a shift in power from Muttahidda Majlis e Amal having complete dominance in 2002 to PPP and ANP sharing equal shares in 2008 and to PTI taking over control in 2013. The voters in KPK seem more experimental while choosing a government for their province and won’t hesitate to move on to another party if one fails to achieve its goals<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*2qYG-sx-FhTKYZqv.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/0*piiM4rgAptmBcZpB.png" /></figure><p>The Islamabad Capital Territory consists of 13 constituencies altogether (15 according to Delimitation 2018). Since 2002 the natives in these areas have favoured Independent candidates. The turnout has increased over the years but so has the competition. The margin of victory got narrower over the years<strong>.</strong></p><h3>Conclusion</h3><p>As we all know, democracy is defined as a government of the people, for the people, and by the people. This analysis helps us in determining the political trends over the years in Pakistan. The shift in power in KPK from MMA to PTI and in Punjab from PPP to PMLN is one such example of how party loyalty changed over a period of time. The impact of Punjab on the election results on the whole reflect that for any party a stronghold in Punjab is extremely vital to ensure its supremacy. This makes Punjab the most important province in terms of politics. We can also examine that since 1992, only 4–5 parties have been predominant all across the country taking turns to form the government, specifically in the case of PPP and PMLN. In this scenario, PTI as a new addition has emerged as a new player in the political dynamics of Pakistan. Interestingly, we have also observed a gradual improvement in the voter turnout in the past two decades reflecting a rise in people’s faith in the electoral system.</p><p>Data source :<a href="https://github.com/colincookman/pakistan_elections">https://github.com/colincookman/pakistan_elections</a></p><p><em>Originally published at </em><a href="http://marketlytics.com/blog//politycs-political-analysis"><em>marketlytics.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9adfc8841fff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kaptaan in the light of Data]]></title>
            <link>https://medium.com/@marketlytics/kaptaan-in-the-light-of-data-8c775b8886e3?source=rss-dac537ebe777------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c775b8886e3</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[election-2018]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[MarketLytics]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 15:33:54 GMT</pubDate>
            <atom:updated>2018-07-25T15:33:54.969Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*cuG_jbMSNzv_2Lpj.png" /></figure><h3>Exploratory and Sentiment Analysis — Part 1</h3><p><em>By Rehan Ahmed</em></p><p>Pakistan election 2018 being just around the corner is probably the perfect pint of motivation needed, to try and really push the boundaries of mathematics and science and see what is revealed. For those who like their politics brewed with just a dash more data, this is part one, of a series centered towards exploring the data about the election.</p><p>The Pakistani Kaptaan, Imran Khan, is a major contender for the position of Pakistan’s Prime Minister. Given his monumental rise in popularity since the last election, and especially his brief ‘dharna’ stunt in the capital, I thought it would be interesting to take a look at all that people have been saying about him. More importantly, I wanted to see if the general public’s sentiment around him has changed, or if it has, by how much?</p><p>With the elections nearly upon us, I hoped that armed with data science and the arsenal of tools that come with it, I would be able to make an educated guess about how much Imran Khan has managed to achieve during the past few years and how it has affected people’s opinion about him. Moreover, I also wanted to see what were the biggest and most notable events in the past few years that forced people to talk about him (be it in a positive or negative light).</p><h3>The Goal</h3><blockquote><em>“‘Applying exploratory sentiment analysis on comments, tweets, Facebook, and forum posts to gauge the general interest and opinion about Imran Khan.’<br>”</em></blockquote><p>The original aim was to extract the views of the Pakistani public using data from tweets, Facebook comments, political forums and comments on popular news websites. However, I faced several issues, from a limit on the number of tweets I could scrape to a new review policy implemented by Facebook, put into action after the recent Cambridge Analytica scandal. In the end, I turned to the websites of newspapers and news channels in Pakistan.</p><p>Only Dawn, one of Pakistan’s oldest and most respected newspaper, had enough comments on each article to be worth analyzing. The problem? They don’t provide any API or a direct way to download and search through all the comments so I decided to develop a web scraping script on my own using R’s ‘<a href="https://cran.r-project.org/web/packages/rvest/rvest.pdf">rvest</a>’ package.</p><h3>Exploratory Analysis</h3><p>I scraped 845 articles from Dawn containing ‘Imran Khan’ in the title, from 16th July, 2018, to as far back as 2002 to. However, since I was only focusing on comments, I only considered articles with at least one comment.</p><p>Here is the distribution of all the articles on Dawn’s website with ‘Imran Khan’ in the title and with at least one published comment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*nacpdAOcPYpshvGP.png" /></figure><p>You can see a clear spike in 2014 — the year of the ‘Azadi March’, also known as the tsunami march. 2015 managed to keep up the hype but 2016 was the year when interest died down a little.</p><p>In 2017, with just a year to go till the elections, more articles started appearing and with 2018 barely halfway through, Dawn has written almost the same number of articles in 6 and a half months than it wrote all of last year.</p><p><strong><em>Note: These are only the articles with at least one comment.</em></strong></p><p>Next, I decided to take a look at the number of comments (or the hype) generated each year. In total, I got 38,866 comments from 717 articles. Here is how they are distributed, over the years,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*-ErWU7_BXJnicNDn.png" /></figure><blockquote><em>““2015 was the year with the most number of comments — 8709.””</em></blockquote><p>Since 2011, the number of comments has gradually increased but it is also worth noting that, during the same time period, internet users in Pakistan also increased significantly, from just <a href="http://www.internetlivestats.com/internet-users/pakistan/">9% in 2011 to 10.9% in 2013</a>. Even then, there is a clear spike in comments in 2014 (8648 comments), during the days of the Azadi March, which can also be due to the increasing interest in Imran Khan.</p><p>Here is a look at the comment and article charts for 2014. See how the number of comments climbed as more articles were written about Imran Khan and his quest to overturn the government,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*xOecp1GMfCpI3zu9.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*8XK_TlnjeIh0tr9Q.png" /></figure><p><strong><em>The articles labelled above the dotted line are the 5% articles from 2014 with the most number of comments.</em></strong></p><p>There is an obvious and significant relationship between the number of articles and the number of total comments in a year. In August 2014, Imran Khan initiated his march and there were 29 articles written about Imran Khan in this month, attracting over two thousand comments, but did the number of comments per article also increase at the same level? To find this out, I plotted a scatter plot of the total number of comments per total number of comments for each month of 2014,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*1adTU1Ds5gevSmQX.png" /></figure><p><strong>Green — Number of Articles</strong></p><p><strong>Grey — Number of Comments Per Article</strong></p><p>There isn’t much to infer from this, except that the number of comments per article climbed as the number of articles climbed. However, a similar increase in the number of articles in November didn’t see the number of comments following a similar path. In conclusion, it seems that August was an anomaly with more and more people wanting to talk about Imran Khan.</p><p>Next, I tried the same technique for all the years to see how the number of comments per article has fared and this gave me a better answer,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*koGfQ0j3N0w-zGQ6.png" /></figure><p>Surprisingly, the number of comments per article has gone down over the years, except for 2014 (which is to be expected given his Imran Khan’s abrupt rise to popularity). The median number of comments per article is 25 while the mean comes at around 45.8.</p><p>Here is a look at all the articles, plotted based on the number of comments. The articles labeled above the dotted line are the 1% articles with the most number of comments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*bolAf6ZCmI6e9kvF.png" /></figure><p>These 850 articles were written by 150 writers, although the number may be higher because my web scraping script only picked up the name of the writer written first (a Dawn article can have multiple authors mentioned in a single post ). After removing the articles written by generic staff pseudonyms like ‘Dawn.com’, ‘The Newspaper’s Correspondent’, etc., I found the writers who have written the most about Imran Khan,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*g8innl4xOCM965Nd.png" /></figure><p>Does a writer’s writing style have an effect on the number of people who comment on his or her articles? To find out, I plotted the average number of comments per article each writer attracted on a bar chart. I only chose writers who have written at least five articles. Only 19 writers have written five or more articles and attracted an average of 25 comments per article.</p><p>Irfan Haider has written articles like ‘Imran Khan joins civil disobedience movement, burns power bill’, ‘Imran accuses HRCP of promoting foreign agenda’, and ‘Imran Khan suspends Justice (r) Wajihuddin’s PTI membership’, mostly around the 2014–2015 period, averaging 65 comments per article.</p><p>Here is a look at the top 5 writers who have generated the most hype in the comments section of Dawn’s website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*eImuaMOnodqA-AU6.png" /></figure><p>Conclusively, based on the data from Dawn, it is fair to say that the interest factor around Imran Khan has grown considerably over the past few years, especially since his dharna in 2014. While 2016 may have been a somewhat slow year, he bounced back in 2017, generating a whole lot of interest with his campaign to become the next Prime Minister of Pakistan.</p><p>To wrap things up, in Part — 1, I took a look at the data using exploratory data analysis to visualize and summarize its main characteristics. The next part will be focused on sentiment analysis of the articles and the comments to find out more insights on the general opinion around Imran Khan.</p><p><em>Originally published at </em><a href="http://marketlytics.com/blog/kaptaan-in-the-light-of-data"><em>marketlytics.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c775b8886e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>