<?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 abhishek pakrashi on Medium]]></title>
        <description><![CDATA[Stories by abhishek pakrashi on Medium]]></description>
        <link>https://medium.com/@apakrashi?source=rss-7a8cbe07dcd4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*z2YOCWrp-b3d1xtDl5s05A.jpeg</url>
            <title>Stories by abhishek pakrashi on Medium</title>
            <link>https://medium.com/@apakrashi?source=rss-7a8cbe07dcd4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:28:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@apakrashi/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[But sir, they just killed the President]]></title>
            <link>https://medium.com/@apakrashi/but-sir-they-just-killed-the-president-86e47301c9bb?source=rss-7a8cbe07dcd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/86e47301c9bb</guid>
            <category><![CDATA[nsa]]></category>
            <category><![CDATA[nsa-surveillance]]></category>
            <category><![CDATA[surveillance]]></category>
            <category><![CDATA[terrorism]]></category>
            <category><![CDATA[privacy]]></category>
            <dc:creator><![CDATA[abhishek pakrashi]]></dc:creator>
            <pubDate>Mon, 16 Apr 2018 12:11:11 GMT</pubDate>
            <atom:updated>2018-04-16T23:18:42.999Z</atom:updated>
            <content:encoded><![CDATA[<p>A story of conspiracy and power of modern surveillance</p><p><strong>0:00</strong>: A sniper head shot, gushing blood splatters from the head to the nearby standing Secret Service Agent’s shirt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*3AHq6gTmIvclsizWHbhJ8g.jpeg" /></figure><p>The assassin’s best move was to detonate a small explosive charring himself/herself and all his weapons so that no trace is left.</p><p>The next sequence of Chronological events were:</p><p><strong>0:01–0:30 </strong>: General chaos as the Secret Service forms a bubble around the situation.<br><strong>0:30–1:00</strong> : Secret Service goes into complete lock down and emergency signals about what has happened are transmitted to where they need to go to begin the cascading series of preparations and alerts. <br><strong>1:00–2:00</strong> : VP is made aware of the assassination, is being prepped to be put in a secret and protective location. <br><strong>1:00–5:00</strong> : The Secret Service has sent emergency coded messages to the sundry branches of Government that the President has been “incapacitated” and the aides and messengers are fanning out to those who need to know . Every cell phone and beeper (still in use) on Planet Earth is going off about now. All allies, are starting to go into lock-down because of fears of how this incident will cause destabilization around the world. <br><strong>5:00–10:00</strong> : Every senior US Government official (the leaders of the Congress, the Supreme Court and the Cabinet, who are all protected by the Secret Service) have already been quickly grabbed wherever they are, and transported (or are being transported) to the nearest secure government facilities (this would be military bases, designated DC locations, local police departments, etc). They are made aware of the incident and have been requested to sign a letter temporarily transferring powers to the VP. This process takes time. <br><strong>5:00–15:00</strong> : During this time, every governor is put on alert and is most likely put into protective confinement by that state’s protective service. The US military is put on high alert. Every consulate is likely closed and every embassy around the world is put on lock-down.</p><p>Fast forward to 20 days, the sleeper cells have been activated all over the world. Europe, Asia, Australia. The earth is burning red hot. This only meant nuclear war to eradicate ISIS. However they are a new breed of enemy. ISIS is hidden everywhere and no where in specific.</p><p>The CIA,NSA, Department of Homeland Security and all other agencies in the world are collaborating for the whereabouts to scramble for Abu Bakr al-Baghdadi, the leader of ISIS.</p><p>Over a VPN connection, a conversation was made which could avoid Nuclear war:</p><p>“20 days, that is all I can give you.”</p><p>“Thank you Mr President”</p><p>The leaders of Google and Apple are visiting the pentagon.</p><p>“Gentlemen, at this moment, we will have to let go of Civil Liberties at times of War, and we need your support to suspend it”, the conversation was started by the Secretary of Defense.</p><p>The heads of the corporations, after a 10 hour long event are come out of the Pentagon. The world was about to change its way of privacy, at the cost of war.</p><p>In the next few days, Apple, Google and NSA formed a massive task force.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MFA5tdkYTYV9h0SFR8DCDg.jpeg" /></figure><p>Google photos already knows your face and can identify it even if you have a beard or have changed your looks. iOS phones can unlock the screen based on your face.</p><p>Every phone on the planet began streaming all faces collected to the NSA’s Utah DataCenter, where a distributed cluster was scanning for the possible faces of the terrorists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atTNFR66RFLWMwEXN7pZTw.jpeg" /></figure><p>Lets do a disruptive and odd ending now. We do not know if the terrorist was ever caught, or if the world peace was restored. What I wanted to portray was how android and iOS are placed strategically in the world of surveillance and how one day our privacy could/should(?) be compromised for looking at the big picture.</p><p><em>Credits:</em></p><p><em>Chronological events for Presidents Assassination: </em><a href="https://www.quora.com/What-would-happen-if-someone-assassinated-President-Obama-right-now/answer/Dan-Holliday"><em>Quora</em></a></p><p><em>Images: Google Images</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86e47301c9bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kaggle: The Titanic story]]></title>
            <link>https://medium.com/@apakrashi/kaggle-the-titanic-story-fd65e6f83f81?source=rss-7a8cbe07dcd4------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd65e6f83f81</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[abhishek pakrashi]]></dc:creator>
            <pubDate>Thu, 12 Apr 2018 13:01:35 GMT</pubDate>
            <atom:updated>2018-05-23T22:47:21.950Z</atom:updated>
            <content:encoded><![CDATA[<p>With the AI revolution the retinas of the masses are increasingly getting fixated on the machine learning algorithms. More so since scikit-learn has revolutionized the deployment speed and we often see clickbait titles: solving the cancer ML problem in 12 lines of code. However the truth is that is still the field is largely about by acquiring and cleaning the data. And to demonstrate that the devil is in the data(okay, I made that line up), I am going to illustrate using Kaggle very own starter problem: The Titanic story.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*aEthLjVs-0asm0RqTVIQqg.jpeg" /><figcaption>everyone expects quick answers</figcaption></figure><p>Caution for beginners: As much tempting it is, do not try running machine learning code directly on the data, the accuracy will wrench your gut out!(something like below)</p><pre>import pandas as pd<br>from sklearn.tree import DecisionTreeClassifier                                               train_data = pd.read_csv(&#39;train.csv&#39;)                       <br>test_data = pd.read_csv(&#39;train.csv&#39;)                                               survived = train_data[&#39;Survived&#39;]                       train_data.drop(&#39;Survived&#39;, axis=1, inplace=True)                                               clf = DecisionTreeClassifier() <br>clf.fit(train_data, survived)<br>predictions = clf.predict(test_data)                                               print(predictions</pre><p>I am not even going into the accuracy of the output or the result. Instead what this taught was a much needed lesson: Feature Engineering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*neUZEAUzfXEup-7qq0sGFA.jpeg" /></figure><p>Lets start with getting the libraries(full code at <a href="https://github.com/apakrash/kaggle_titanic/blob/master/titanic-3.ipynb">Github</a>)</p><pre>from sklearn.linear_model import LogisticRegression<br>from sklearn.ensemble import RandomForestClassifier<br>from sklearn.model_selection import GridSearchCV</pre><pre>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br>plt.style.use(&#39;ggplot&#39;)<br>%matplotlib notebook</pre><pre>import seaborn as sns<br>sns.set()</pre><pre>#loading data</pre><pre>train=pd.read_csv(&#39;train.csv&#39;)<br>test=pd.read_csv(&#39;test.csv&#39;)</pre><p>Lazyness is the mother of all inventions!, wait that is not correct, but that worked for me, as it turned out that <a href="https://github.com/pbegle/Kaggle-Competitions/blob/master/Titanic/kaggle_titanic_challenge.ipynb"><em>combining the train and test data</em></a> for feature engineering makes the job easier</p><pre>titanic=train.append(test,ignore_index=True)</pre><pre>train_index=len(train)<br>test_index=len(titanic)-len(test)</pre><p>Checking how are the empty space looks:</p><pre>#To check if any column has null<br>print(titanic.isnull().sum())</pre><pre>Output:<br>Age             263<br>Cabin          1014<br>Embarked          2<br>Fare              1<br>Name              0<br>Parch             0<br>PassengerId       0<br>Pclass            0<br>Sex               0<br>SibSp             0<br>Survived        418<br>Ticket            0<br>dtype: int64</pre><p>Now, after tinkering for a bit, you would want to start with the title:</p><pre>#creating title for feature engineering</pre><pre>titanic[&#39;Title&#39;]=titanic.Name.apply(lambda name:name.split(&#39;,&#39;)[1].split(&#39;.&#39;)[0].strip())</pre><pre>print(titanic.Title.unique())</pre><pre>[&#39;Mr&#39; &#39;Mrs&#39; &#39;Miss&#39; &#39;Master&#39; &#39;Don&#39; &#39;Rev&#39; &#39;Dr&#39; &#39;Mme&#39; &#39;Ms&#39; &#39;Major&#39; &#39;Lady&#39;<br> &#39;Sir&#39; &#39;Mlle&#39; &#39;Col&#39; &#39;Capt&#39; &#39;the Countess&#39; &#39;Jonkheer&#39; &#39;Dona&#39;]</pre><p>Now, doing a little google and checking how they can be placed together, one come to the dictionary</p><pre># normalize the titles<br>normalized_titles = {<br>    &quot;Capt&quot;:       &quot;Officer&quot;,<br>    &quot;Col&quot;:        &quot;Officer&quot;,<br>    &quot;Major&quot;:      &quot;Officer&quot;,<br>    &quot;Jonkheer&quot;:   &quot;Royalty&quot;,<br>    &quot;Don&quot;:        &quot;Royalty&quot;,<br>    &quot;Sir&quot; :       &quot;Royalty&quot;,<br>    &quot;Dr&quot;:         &quot;Officer&quot;,<br>    &quot;Rev&quot;:        &quot;Officer&quot;,<br>    &quot;the Countess&quot;:&quot;Royalty&quot;,<br>    &quot;Dona&quot;:       &quot;Royalty&quot;,<br>    &quot;Mme&quot;:        &quot;Mrs&quot;,<br>    &quot;Mlle&quot;:       &quot;Miss&quot;,<br>    &quot;Ms&quot;:         &quot;Mrs&quot;,<br>    &quot;Mr&quot; :        &quot;Mr&quot;,<br>    &quot;Mrs&quot; :       &quot;Mrs&quot;,<br>    &quot;Miss&quot; :      &quot;Miss&quot;,<br>    &quot;Master&quot; :    &quot;Master&quot;,<br>    &quot;Lady&quot; :      &quot;Royalty&quot;<br>}</pre><pre># mapping to the normalized titles using the above defined dictionary</pre><pre>titanic.Title=titanic.Title.map(normalized_titles)</pre><p>Now, lets check how that helped:</p><pre>titanic.Title.value_counts()</pre><pre>out[15]:<br>Mr         757<br>Miss       262<br>Mrs        200<br>Master      61<br>Officer     23<br>Royalty      6<br>Name: Title, dtype: int64</pre><p>Now, <strong><em>group the age it based on </em></strong>‘Pclass’ and ’Sex’ <strong><em>and apply it on the age:</em></strong></p><pre>titanic.Age=grouped.Age.apply(<strong>lambda</strong> x: x.fillna(x.median()))</pre><pre>titanic.isnull().sum()</pre><pre>Output:</pre><pre>Age          263<br>Cabin       1014<br>Embarked       2<br>Fare           1<br>Name           0<br>Parch          0<br>Pclass         0<br>Sex            0<br>SibSp          0<br>Survived     418<br>Ticket         0<br>Title          0</pre><p>For cabin, there are no clear winners, so we will fill up the blanks with ‘U’:</p><pre>titanic.Cabin=titanic.Cabin.fillna(&#39;U&#39;)</pre><p>For Embarked, lets check what is the percentage frequency of each:</p><pre>titanic.Embarked.value_counts(normalize=<strong>True</strong>)</pre><pre>Output:<br>S    0.699311<br>C    0.206580<br>Q    0.094109</pre><p>Hence, filling up with the most used value:</p><pre>most_embarked=titanic.Embarked.value_counts().index[0]<br>titanic.Embarked=titanic.Embarked.fillna(most_embarked)</pre><p>For Fare, filling up the blanks with the median value:</p><pre>titanic.Fare=titanic.Fare.fillna(titanic.Fare.median())</pre><p>Now, we all have seen Titanic and we know that Jack died(sob!) and that women and children were given first preference, lets check the frequency distribution of the surviving:</p><pre>group_by_sex=titanic.groupby(&#39;Sex&#39;).Survived.mean()<br>group_by_sex<br>Ouput:<br>Sex<br>female    0.742038<br>male      0.188908</pre><p>Now, lets check among the survivors and among the Jack’s kind(not so much on the survivor’s side :() what is the distribution of men and women:</p><pre>group_class_sex=titanic.groupby([&#39;Pclass&#39;,&#39;Sex&#39;]).Survived.mean(<br>_ = sns.factorplot(x=&#39;Sex&#39;,col=&#39;Survived&#39;,data=titanic,kind=&#39;count&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*F1QmiB09zE2gzkDg8ifPog.png" /><figcaption>Titanic:Sex and Survived frequency distribution</figcaption></figure><p>Now, to add a new feature: FamilySize. The rationale is that the evacuation was been done with family and that bigger families has lesser mobility</p><pre>titanic[&#39;FamilySize&#39;]=titanic.Parch+titanic.SibSp+1</pre><p>The Cabin, was a tricky one since a few had many associated with them. Some could be near the evacuation deck. I could not demystify that, for now, lets just extract the first letter and live with it:</p><pre>titanic.Cabin=titanic.Cabin.map(<strong>lambda</strong> x:x[0])<br>titanic.Cabin.value_counts(normalize=<strong>True</strong>)</pre><pre>Output:</pre><pre>U    0.774637<br>C    0.071811<br>B    0.049656<br>D    0.035141<br>E    0.031322<br>A    0.016807<br>F    0.016043<br>G    0.003820<br>T    0.000764</pre><p>Thereafter, converting the non-numeric categories to categorical:</p><pre>titanic.Sex=titanic.Sex.map({&#39;male&#39;:0,&#39;female&#39;:1})<br>pclass_dummies = pd.get_dummies(titanic.Pclass, prefix=&quot;Pclass&quot;)<br>title_dummies = pd.get_dummies(titanic.Title, prefix=&quot;Title&quot;)<br>cabin_dummies = pd.get_dummies(titanic.Cabin, prefix=&quot;Cabin&quot;)<br>embarked_dummies = pd.get_dummies(titanic.Embarked, prefix=&quot;Embarked&quot;)<br>titanic_dummies.drop([&#39;Pclass&#39;,&#39;Title&#39;,&#39;Cabin&#39;,&#39;Embarked&#39;,&#39;Name&#39;,&#39;Ticket&#39;],axis=1,inplace=<strong>True</strong>)</pre><p>Now to concatenate all the dummies and dropping the original fields</p><pre><em>#concatenating dummies</em><br><br>titanic_dummies = pd.concat([titanic,pclass_dummies,title_dummies,cabin_dummies,embarked_dummies],axis=1)<br><br><em>#dropping some fields</em><br>titanic_dummies.drop([&#39;Pclass&#39;,&#39;Title&#39;,&#39;Cabin&#39;,&#39;Embarked&#39;,&#39;Name&#39;,&#39;Ticket&#39;],axis=1,inplace=<strong>True</strong>)</pre><h3>Phew! finally the machine learning arrives</h3><p>I would not bore with the usual steps, directly jump to the ‘fitting’ part:</p><pre><em># build and fit model </em><br>forest_cv = GridSearchCV(estimator=forrest,     param_grid=forrest_params, cv=5) <br><br>forest_cv.fit(X, y)<br>print(&quot;Best score: <strong>{}</strong>&quot;.format(forest_cv.best_score_))</pre><pre>Output:<br>Best score: 0.8417508417508418</pre><p>Now, if you have come this far, I wanted to say that unless you are doing Deep Learning(in some cases even in Deep Learning) curating and manipulating the data is the major part. Happy coding.</p><p>So, go ahead, as Andrew Ng says, feature engineering is an art, go ahead and spring up even better features and let me know in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd65e6f83f81" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>