<?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 Gauri Shankar Mishra on Medium]]></title>
        <description><![CDATA[Stories by Gauri Shankar Mishra on Medium]]></description>
        <link>https://medium.com/@gaurishankarmishra?source=rss-2a92d5f19f0e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1AGCcKFL101_XCFh</url>
            <title>Stories by Gauri Shankar Mishra on Medium</title>
            <link>https://medium.com/@gaurishankarmishra?source=rss-2a92d5f19f0e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:50:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gaurishankarmishra/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[My approach to ML Hikeathon]]></title>
            <link>https://medium.com/@gaurishankarmishra/my-approach-to-ml-hikeathon-898825b69b14?source=rss-2a92d5f19f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/898825b69b14</guid>
            <category><![CDATA[friend-problems]]></category>
            <category><![CDATA[hike-messenger]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Gauri Shankar Mishra]]></dc:creator>
            <pubDate>Tue, 09 Apr 2019 23:00:16 GMT</pubDate>
            <atom:updated>2019-04-09T23:00:16.564Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone today i will share with you all my approach to<a href="https://datahack.analyticsvidhya.com/contest/hikeathon/"> ML Hikeathon</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VIkprOz5BOytdbM-mDsIPQ.png" /></figure><p>The problem statement was</p><p><em>Link Prediction on Hike’s Social Network Social networks are highly dynamic; they grow and change quickly over time through the addition of new edges, signifying the appearance of new interactions in the underlying social structure. The fundamental computational problem underlying social-network evolution is the Link Prediction problem:</em></p><p><em>Hike is a social platform and predicting links in their network forms the basis for recommending new friends to our users with whom they can possibly start a chat. High-quality recommendations help in strengthening the network by aiding the creation of new social connections between existing users. It also helps in the retention of new users by helping them find friends as they join the platform.</em></p><p><em>Can you develop an algorithm to predict whether a Hike user will chat another Hike user who is part of his/her phone contact book?</em></p><p>Sounds cool right . Lets dig into it and helps friends to connect with each other :)</p><p>I will be using Google Colab as my pc sucks 😔</p><p>So lets us set things up</p><pre># Install the PyDrive wrapper &amp; import libraries.<br># This only needs to be done once per notebook.<br>!pip install -U -q PyDrive<br>from pydrive.auth import GoogleAuth<br>from pydrive.drive import GoogleDrive<br>from google.colab import auth<br>from oauth2client.client import GoogleCredentials<br><br># Authenticate and create the PyDrive client.<br># This only needs to be done once per notebook.<br>auth.authenticate_user()<br>gauth = GoogleAuth()<br>gauth.credentials = GoogleCredentials.get_application_default()<br>drive = GoogleDrive(gauth)</pre><pre>import os<br>file_list = drive.ListFile().GetList()<br><br><br>for f in file_list:<br>  # 3. Create &amp; download by id.<br>  print(&#39;title: %s, id: %s&#39; % (f[&#39;title&#39;], f[&#39;id&#39;]))<br>  fname =  f[&#39;title&#39;]<br>  print(&#39;downloading to {}&#39;.format(fname))<br>  f_ = drive.CreateFile({&#39;id&#39;: f[&#39;id&#39;]})<br>  f_.GetContentFile(fname)</pre><p>Now I have imported the required data zip files from my drive</p><p>Lets unzip them</p><pre>import zipfile<br>import pandas as pd<br> <br>zf = zipfile.ZipFile(&#39;train.zip&#39;) <br>train_df = pd.read_csv(zf.open(&#39;train.csv&#39;))<br>train_features = pd.read_csv(zf.open(&#39;user_features.csv&#39;))</pre><p>Now lets check out our train data</p><pre>display(train_df.shape)<br>display(train_df.is_chat.value_counts())<br>$(70661802, 3)<br>$0    68410018<br>$1     2251784<br>$Name: is_chat, dtype: int64</pre><p>Here comes the data reprocessing steps</p><pre>t2 = train_df.iloc[:100000,:]<br>train_features = train_features.set_index(&#39;node_id&#39;)<br>cols = train_features.columns<br>for col in cols:<br>  t2[&#39;1&#39;+col] = t2[&#39;node1_id&#39;].apply(lambda x: train_features.loc[x,col])<br>for col in cols:<br>  t2[&#39;2&#39;+col] = t2[&#39;node2_id&#39;].apply(lambda x: train_features.loc[x,col])<br>t2.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yzdjkXAqyzmCZzjnH6s9Mg.png" /><figcaption>now the data looks fine</figcaption></figure><p>now lets import some important libraries</p><pre>import numpy<br>import pandas<br>from keras.models import Sequential<br>from keras.layers import Dense<br>from keras.wrappers.scikit_learn import KerasClassifier<br>from sklearn.model_selection import cross_val_score<br>from sklearn.preprocessing import LabelEncoder<br>from sklearn.model_selection import StratifiedKFold<br>from sklearn.preprocessing import StandardScaler<br>from sklearn.pipeline import Pipeline</pre><p>labeling the data as X and Y</p><pre>X = t2.iloc[:,3:].values.astype(float)<br>Y = t2.loc[:,&#39;is_chat&#39;].values</pre><p>Now we will use Keras Sequentially model for our training of data set</p><pre>model = Sequential()<br>model.add(Dense(60, input_dim=26, kernel_initializer=&#39;normal&#39;, activation=&#39;relu&#39;))<br>model.add(Dense(100, input_dim=60, kernel_initializer=&#39;normal&#39;, activation=&#39;relu&#39;))<br>model.add(Dense(20, input_dim=100, kernel_initializer=&#39;normal&#39;, activation=&#39;relu&#39;))<br>model.add(Dense(1, kernel_initializer=&#39;normal&#39;, activation=&#39;sigmoid&#39;))<br># Compile model<br>model.compile(loss=&#39;binary_crossentropy&#39;, optimizer=&#39;adam&#39;, metrics=[&#39;accuracy&#39;])<br>model.fit(X,Y, epochs = 10, batch_size = 1000)<br>model.predict(X)</pre><p>It will take sometime for the model to train (depending upon your pc specs)</p><p>Now lets import our test data</p><pre>import zipfile<br>import pandas as pd<br> <br>zf2 = zipfile.ZipFile(&#39;./test.zip&#39;) <br>test_df = pd.read_csv(zf2.open(&#39;test.csv&#39;))<br># train_features = pd.read_csv(zf.open(&#39;user_features.csv&#39;))</pre><p>Now comes the hard part which requires a lot of patience</p><pre>l =[]<br>t =0<br>for i in range(59):<br>  print(i)<br>  test1 = test_df.iloc[t:t+200000,:]<br><br><br>  for col in cols:<br>    test1[&#39;1&#39;+col] = test1[&#39;node1_id&#39;].apply(lambda x: train_features.loc[x,col])<br><br>  for col in cols:<br>    test1[&#39;2&#39;+col] = test1[&#39;node2_id&#39;].apply(lambda x: train_features.loc[x,col])<br><br>  l.append(model.predict(test1.iloc[:,3:].values))<br>  t+=200000</pre><p>this code snippet took almost 1.67 hrs to finish so hold , finish your game of thrones episode and come back</p><pre>test_f = test_df[[&#39;id&#39;,&#39;Score&#39;]]<br>test_f.shape<br># test_f[&#39;Score&#39;] = test_f[&#39;Score&#39;].values<br>type(test_f.Score[0]<br>test_f[&#39;is_chat&#39;] = test_f[&#39;Score&#39;].apply(lambda x: x[0])<br>test_f.drop(columns = &#39;Score&#39;, inplace = True)<br>test_f.head()</pre><p>writing the predictions to a csv file</p><pre>test_f[[&#39;id&#39;,&#39;is_chat&#39;]].to_csv(&#39;prediction.csv&#39;, index= False)</pre><p>now lets download it</p><pre>from google.colab import files<br>files.download(&#39;prediction.csv&#39;)</pre><p>And we are done</p><p>Through this code you will be able to get an accuracy of 80 %</p><p>which is pretty good</p><p>You can find my code <a href="https://github.com/gaurishankar9793/ML-Hikeathon">here</a>.(don’t forget to star the repo 😃)</p><p>Also if you want a better code with a better accuracy you can go to <a href="https://github.com/karthiktsaliki/Hikeathon_Analytics_Vidhya">here</a> as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=898825b69b14" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>