<?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 Tonnam Balankura on Medium]]></title>
        <description><![CDATA[Stories by Tonnam Balankura on Medium]]></description>
        <link>https://medium.com/@tonnam?source=rss-9132b8d13751------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mbGaWeM0bMXeCZ9sfmtakg.jpeg</url>
            <title>Stories by Tonnam Balankura on Medium</title>
            <link>https://medium.com/@tonnam?source=rss-9132b8d13751------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:17:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tonnam/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[Cast Your Tweet! Predicting the 2016 Presidential Election.]]></title>
            <link>https://medium.com/@tonnam/cast-your-tweet-predicting-the-2016-presidential-election-3313a640ec87?source=rss-9132b8d13751------2</link>
            <guid isPermaLink="false">https://medium.com/p/3313a640ec87</guid>
            <category><![CDATA[2016-election]]></category>
            <category><![CDATA[politics]]></category>
            <dc:creator><![CDATA[Tonnam Balankura]]></dc:creator>
            <pubDate>Tue, 18 Apr 2017 04:09:12 GMT</pubDate>
            <atom:updated>2017-08-22T13:41:30.731Z</atom:updated>
            <content:encoded><![CDATA[<p>According to our Twitter analytics, Republican, Donald Trump, wins the 2016 presidential election with 28 states. Hillary Clinton was a close second with 22 states. These predictions have 63% accuracy by state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*91JpLbhXIIq34fdBXN0MSQ.png" /><figcaption><a href="https://plot.ly/~tonnamb/209">See the interactive plot</a></figcaption></figure><p>For this year’s HackPSU, Sarah Kidder and I had hoped to predict the presidential election via Twitter. In order to do so, we sampled real-time tweets produced from each state, labeling each unique user tweet as a particular vote for 1 of 4 candidates. For example, tweets that contained the hashtags #ImWithHer, #Hillyes, #Hillarymostqualified or #VoteHillary counted as a tally for Senator Clinton. Using the tweet’s location origin, we also were able to determine the winner by state.</p><p>We were skeptical in how accurate these hashtags can represent positive opinions toward a nominee, as one might argue that a tweet may read I am not #feelingthebern. To combat this, for each hashtag we screened 100 tweets to determine whether it was positive, negative or unrelated to the candidate. The results below indicate the accuracy of each hashtag used.</p><p>Hillary Clinton:</p><ul><li>ImWithHer — 86 % accuracy</li><li>Hillyes — 100 %</li><li>Hillarymostqualified — 100 %</li><li>VoteHillary — 99 %</li></ul><p>Bernie Sanders:</p><ul><li>FeelingtheBern — 88 %</li><li>Berniestrong — 95 %</li><li>Bernieorbust — 96 %</li><li>VoteBernie — 100 %</li></ul><p>Donald Trump:</p><ul><li>TrumpArmy — 100 %</li><li>MakeAmericaGreatAgain — 97 %</li><li>Trumptrain — 99 %</li><li>VoteTrump — 100 %</li></ul><p>Ted Cruz:</p><ul><li>UniteWithCruz — 100 %</li><li>CruzCrew — 97 %</li><li>ChooseCruz — 99 %</li><li>VoteCruz — 100 %</li></ul><p>We used the tweepy and <a href="https://github.com/inactivist/twitter-streamer">twitter-streamer</a> to sample tweets from Twitter. The datasets are stored in SQLite databases. We sampled 1000 to 2000 tweets from each state and tagged them according to the pertaining hashtag. Tweets with the same maximum number of hashtags supporting different nominees were considered as non-voter. We visualized our predictions using Plotly’s Choropleth Maps.</p><p>For our source code, please see our <a href="https://github.com/tonnamb/twitter-election">GitHub repository</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3313a640ec87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup your own local Python module to enhance your data science workflow]]></title>
            <link>https://medium.com/@tonnam/setup-your-own-local-python-module-to-enhance-your-data-science-workflow-3aac797c3259?source=rss-9132b8d13751------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aac797c3259</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Tonnam Balankura]]></dc:creator>
            <pubDate>Tue, 18 Apr 2017 04:01:37 GMT</pubDate>
            <atom:updated>2017-04-18T04:01:37.374Z</atom:updated>
            <content:encoded><![CDATA[<h3>The problem with ad-hoc scripts</h3><p>For years, I’ve been writing Python scripts to read data from files, analyze the data and visualize the results. When I want to reuse the script, I would have to look for it in my maze-like folder structure to copy-and-paste the file.</p><p>The problem is worse when I refactor/update the script because I would have to look for the folder with the latest version of the script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*yq77_iMWRJ61zboM6OfBWQ.png" /></figure><p>I’ve recently discovered a solution to my problem, which is setting up my own local Python module. This allows me to easilyimport the module from anywhere and have the latest version of my scripts all in one place.</p><h3>How to setup your own local Python module</h3><p>To setup your own local Python module, first decide on a designated module folder and add it to your PYTHONPATH. This can be done by adding export PYTHONPATH=&quot;path/to/your/folder/modules:$PYTHONPATHto your ~/.bash_profile , which gets executed every time you start your terminal. By adding the directory to your PYTHONPATH, Python will look in this directory for modules to import everytime you run Python.</p><p>Then, create a folder inside, in which the folder’s name will be your module name. In my example, my folder and module was named mypymod.</p><p>Next, create a Python file filename.py to store your data analysis and visualization functions. Note that you can have multiple Python files in this folder, where each file can be imported by from mypymod import filename. For example, I have multiple files to organize different types of scripts that I have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*r5nBjb08GnZX3Mt_tynCgA.png" /></figure><p>From your old ad-hoc scripts, you can refactor them into functions and store them inside the Python files. My ui.py file contains my plot function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*vKmXjlJ6fSKoEmoC5EdOcQ.png" /></figure><p>Now, whenever I want use this plot function, I can just write a simple declarative script at the folder that contains the data files to call my plot function from the ui.py file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*-q1teTbM0HmcWrcyjyVZGA.png" /></figure><p>And there you have it, your own local Python module. As simple as that. For those who are ambitious and have a more general use case, you can develop it into an open-source library and share it with the world.</p><p><a href="https://docs.python.org/3/tutorial/controlflow.html#defining-functions">For more information on defining Python functions, I find the official tutorial to be pretty awesome.</a> Thank you for reading and I hope this was useful!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aac797c3259" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>