<?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 Sakshay Mahna on Medium]]></title>
        <description><![CDATA[Stories by Sakshay Mahna on Medium]]></description>
        <link>https://medium.com/@sakshum19?source=rss-687b97271d10------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*t4EgGqbYl7Hrm7qv.jpg</url>
            <title>Stories by Sakshay Mahna on Medium</title>
            <link>https://medium.com/@sakshum19?source=rss-687b97271d10------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 11:17:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sakshum19/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[Project Learning | Week 7]]></title>
            <link>https://sakshum19.medium.com/project-learning-week-7-645cd3277525?source=rss-687b97271d10------2</link>
            <guid isPermaLink="false">https://medium.com/p/645cd3277525</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[projects]]></category>
            <dc:creator><![CDATA[Sakshay Mahna]]></dc:creator>
            <pubDate>Sat, 22 May 2021 13:09:31 GMT</pubDate>
            <atom:updated>2021-05-22T13:09:31.795Z</atom:updated>
            <content:encoded><![CDATA[<p>Week 7 of the learning Machine Learning through a Project based approach</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bY8Tv_Afejo11K2H" /><figcaption>Photo by <a href="https://unsplash.com/@aedrian?utm_source=medium&amp;utm_medium=referral">Aedrian</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We have finally completed the Digit Recognizer competition and moved onto the next competition. The next competition that I finally decided to do is Connect X simulation challenge. Starting off with this competition, the learnings of this week are:</p><h3>Connect X | Simulation Competition</h3><p>In simple words, Kaggle has provided us with a simulation of checker game called Connect 4. We have to program an intelligent bot that is automatically able to play this game with various other opponents and of course be able to win the matches. Connect 4 is a two player game, the first player stacking 3 checkers in a row wins the game. The rows can be horizontal, vertical or even diagonal. Analytically, the game at any point of time has at most 7 possible moves a player can choose from, hence forming about 4,531,985,219,092 total possible ways a game can unfold. Here is an online version of the game:</p><p><a href="https://www.cbc.ca/kids/games/play/connect-4">Connect 4 | CBC Kids</a></p><h3>Introduction to Game AI and Reinforcement Learning</h3><p>The competition requires us to have a knowledge of Game AI and Reinforcement Learning. These are some topics which I am not well versed with, which requires me to learn and read about these topics before starting with the competition. The first towards that was a Kaggle offered course, Introduction to Game AI and Reinforcement Learning:</p><p><a href="https://www.kaggle.com/learn/intro-to-game-ai-and-reinforcement-learning">Learn Intro to Game AI and Reinforcement Learning Tutorials | Kaggle</a></p><p>The course has in total 4 lessons covering the following topics:</p><ul><li>One Step Lookahead bot</li><li>N Step Lookahead bot</li><li>Q Learning based bot</li></ul><p>The course provides very brief introduction on each of these topics and helps us to get started with simulation type of competitions. Well, this course is probably not enough to learn these skills, requiring me to look for more of them.</p><h3>Game Theory</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-zTvK5E3KOgjLT1l" /><figcaption>Photo by <a href="https://unsplash.com/@rihok?utm_source=medium&amp;utm_medium=referral">Riho Kroll</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Most of the Kaggle notebooks in this competition comprise of the Lookahead bots and Q Learning bots. The reason probably being that the course also takes us through this competition itself and helps submitting notebooks with the above mentioned agents.</p><p>After searching for some methods on the internet, I came across this website, that explains a probably good strategy for winning Connect 4:</p><p><a href="https://blogs.cornell.edu/info2040/2015/09/21/solving-connect-four-with-game-theory/">Solving Connect Four with Game Theory : Networks Course blog for INFO 2040/CS 2850/Econ 2040/SOC 2090 (cornell.edu)</a></p><p>However, the above blog post makes use of Game Theory concepts. Game Theory is the study of mathematical models of strategic among intelligent decision makers. Game Theory is definitely one thing that is completely alien to me. Hence, leading me to the direction of studying more about it. This course on YouTube explains the concepts very well:</p><p><a href="https://www.youtube.com/playlist?list=PLKI1h_nAkaQoDzI4xDIXzx6U2ergFmedo">(4) Game Theory 101 — YouTube</a></p><p>This course has small sized easily digestible videos. However, the duration of the course is quite long and will take some 2 or 3 weeks to complete which is going to be the main work for the next weeks.</p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JIih1orxKBizocZS" /><figcaption>Photo by <a href="https://unsplash.com/@alfonsmc10?utm_source=medium&amp;utm_medium=referral">Alfons Morales</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So, this was it for this week’s main learnings. This blog post is probably smaller than the other ones, because most of the time was spent on reading and doing different courses. This will probably continue for next 2 or 3 weeks until the Game Theory course is complete. Then, we can probably start with implementing some simple strategies on the competition, followed by complex Reinforcement Learning based ones.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=645cd3277525" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Learning | Week 6]]></title>
            <link>https://sakshum19.medium.com/project-learning-week-6-fd71cdb71919?source=rss-687b97271d10------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd71cdb71919</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[kaggle]]></category>
            <dc:creator><![CDATA[Sakshay Mahna]]></dc:creator>
            <pubDate>Sat, 15 May 2021 13:02:38 GMT</pubDate>
            <atom:updated>2021-05-15T13:02:38.583Z</atom:updated>
            <content:encoded><![CDATA[<p>Week 6 of the learning Machine Learning through a Project based approach</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LmuPwJVeNA5JRorW" /><figcaption>Photo by <a href="https://unsplash.com/@villxsmil?utm_source=medium&amp;utm_medium=referral">Luis Villasmil</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This was the final week for the Project Digit Classification. By the end of this week I have tried a lot of different ideas and models, and really learned a lot. My score and position on the leaderboard are good, but wish they were better. Anyways, we are moving on to the next competition next week. The learnings of this week were:</p><h3>Changes to Image Data Generator</h3><p>Last week, I tried making some changes to the Image Data Generator, which were applying Feature wise Normalization, ZCA Whitening and slight Sheering to images. There was certainly wrong with one of these additional options that I choose, because the model was not learning properly. After some additional tuning, I found that Feature wise normalization was the source of the problem.</p><p>The reason behind this is very simple. Feature wise normalization takes each feature and normalizes it’s value across each sample, which doesn’t really make sense for the dataset that we are working on.</p><p>Anyways, simply adding Shear to the generator options greatly improved the score of the model. More experiments were tried by increasing the range of these values, but the score remained almost the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*gErcjODoRAAn-voY2eyvIA.png" /><figcaption>Nice improvement to the score with Shear</figcaption></figure><h3>K Fold Validation</h3><p>To my surprise, the K Fold Validation technique did not work that well with a CNN model. The K Fold Cross Validation technique has been able to improve the score of every model I have trained before. But, this did not happen for Neural Networks. There were two ways to apply the K-Fold cross validation in the case of Neural Networks:</p><ul><li>Divide the total Epochs of the training between each of the K folds</li><li>Do the total Epochs on separate models for each of the K folds</li></ul><p>The first would just create a single model, that is trained and validated on a lot of data. The second would create an ensemble of models. I only tried the second approach, which showed not much improvement of performance. Increased the number of epochs as well, but not much improvement was observed. My aim was to try both these approaches, but maybe this could be done for any other competition that we see along the way.</p><h3>Changes to Optimizer</h3><p>Optimizers of Neural Networks are the main algorithms that make the Neural Networks learn. They decide how the parameters of the network change with respect to the gradient that we calculate. Mostly Neural Networks make use of First Order Optimizers like Adam, RMSProp and so on. Stochastic Gradient Descent is the simplest model of a First Order Optimizer, the other optimizers like RMSProp, AdaGrad, AdaDelta and Adam are improvements to the SGD by adding different terms like momentum and history of gradients.</p><p><a href="https://www.quora.com/What-are-differences-between-update-rules-like-AdaDelta-RMSProp-AdaGrad-and-AdaM">(151) What are differences between update rules like AdaDelta, RMSProp, AdaGrad, and AdaM? — Quora</a></p><p>Selecting an optimizer is once again a trial and error kind of approach. But, some intuition also plays a role in deciding an optimizer; which obviously comes from practice over the years.</p><p>For this problem, and the model that we were using RMSProp seemed to be performing the best. I tried changing the optimizer to Adam, but the improvement was not that good.</p><h3>Resnet Model</h3><p>After checking out some of the modifications to a simple straightforward CNN, I moved onto a Residual Network based CNN. This notebook describes Resnet and their implementation:</p><p><a href="https://www.kaggle.com/jmosinski/resnets-are-awesome-state-of-the-art">ResNets are Awesome! (state-of-the-art) | Kaggle</a></p><p>In addition to the straight path of Convolution Layer and Pooling, Residual Layers add one additional path directly connecting the input and output. This results in better propagation. This skip connection helps the calculated gradient better propagate across the network helping the networks learn a dataset effectively.</p><p>The Resnet Layers combined with some Data Preprocessing resulted in an increased score, which is my best score for this competition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*7jlrdll1FtJmA0pXkj_GOA.png" /><figcaption>The best score so far</figcaption></figure><h3>How to choose a CNN architecture?</h3><p>This is a question that almost everyone starting out with Deep Learning would ask at some point of their life. How do we decide which Neural Network would better fit the model, and which won’t. This is once again a Trial and Error method and varies for different datasets. This notebook very effectively explains the concept of selecting an architecture.</p><p><a href="https://www.kaggle.com/cdeotte/how-to-choose-cnn-architecture-mnist/">How to choose CNN Architecture MNIST | Kaggle</a></p><p>A rough number of layers can be determined by going through a dataset. After that, it is just a trial to see how many layers give the best result, what strides, padding and convolution window size are performing the best and so on. I would definitely try to use the techniques mentioned in this notebook to one of the next challenges I pick on.</p><h3>Conclusion and Further Work</h3><p>As I said, this week finally concludes the work for the competition Digit Recognizer. It was really great. After the Titanic competition, I got to try out the Data Exploration and non Deep Learning techniques learned in that competition. I also learned about Dimensionality Reduction techniques(PCA, LDA and tSNE) and the infamous Convolutional Neural Networks, and got to try some of them out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*f7MK3ZTo0vjDgwcG7i_D4g.png" /><figcaption>Not too bad</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*ESWpU5BzijSVGV_FZGeS8A.png" /><figcaption>On the leaderboard</figcaption></figure><p>Let’s see which challenge that we go through starting from next week!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd71cdb71919" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Learning | Week 5]]></title>
            <link>https://sakshum19.medium.com/project-learning-week-5-5c73d817503e?source=rss-687b97271d10------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c73d817503e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[kaggle]]></category>
            <dc:creator><![CDATA[Sakshay Mahna]]></dc:creator>
            <pubDate>Mon, 10 May 2021 14:15:44 GMT</pubDate>
            <atom:updated>2021-05-10T14:15:44.636Z</atom:updated>
            <content:encoded><![CDATA[<p>Week 5 of the learning Machine Learning through a Project based approach</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SU56C7G1m90X2zb-" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A little late (2 days) to record the previous week. Nonetheless, we are here. Previous week I finished up with non Deep Learning approach in the Digit Recognizer competition and also started with Custom Neural Networks and slightly tweaking them to vary their performance. Let’s see what we got!</p><h3>Final Non Deep Learning Model</h3><p>After trying out different dimensionality reduction techniques(3 to be precise), with Support Vector Machines. I also tried t-SNE with K-Nearest Neighbors algorithm. This algorithm is really simple compared to other machine learning algorithms anyone can come across. It just compares the distance of the K (hyperparameter) nearest neighbors and assigns a test data point according to a criteria like voting. The StatQuest video explains the same. Relative to the previous approaches I tried, this combination gave a good score of 0.96982, after which we moved onto the Deep Learning approach.</p><p><a href="https://www.youtube.com/watch?v=HVXime0nQeI">(1) StatQuest: K-nearest neighbors, Clearly Explained — YouTube</a></p><h3>Exploratory Data Analysis</h3><p>Before moving on, I mentioned in my previous post that there are a very small number(0 maybe; not sure) dedicated EDA notebooks on Digit Recognizer dataset. So, I worked on one, it includes the following:</p><ul><li>Basic Data Exploration (Number of samples, distribution of samples and checking for non null values)</li><li>Data Exploration (View the images, view images of a certain label)</li><li>Exploration in Lower Dimensions (PCA and t-SNE visualizations)</li></ul><p><a href="https://www.kaggle.com/sakshaymahna/exploratorydataanalysis-digitrecognizer">ExploratoryDataAnalysis-DigitRecognizer | Kaggle</a></p><h3>Deep Learning | Custom Neural Network</h3><p>Part of why I started with this Project Learning approach are Neural Networks. From the outset, these algorithms seem really interesting and exciting. Given a certain distribution of data, the networks automatically learn the features presented to them and then make predictions. The Neural Network animation shown in one of the 3Blue1Brown video would really spark anyone’s interest in Neural Networks.</p><p><a href="https://www.youtube.com/watch?v=aircAruvnKk">(1) But what is a Neural Network? | Deep learning, chapter 1 — YouTube</a></p><p>Enough of the motivation, the first approach I tried was following this notebook. This notebook has got the highest number of upvotes in the Digit Recognizer competition and is really great for a beginner starting out with Neural Networks.</p><p>An Image Data Generator augmenting images by shifting, rotating and zooming is used. The Neural Network architecture consists of 2 Convolutional Filters of size 32 followed by Max Pooling Layer and 2 Convolutional Filters of size 64 followed by Max Pooling Layer. This configuration is then attached to a Neural Network, with layers of size 256 and 10(10 digits). RMSProp is used as optimizer of the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*Kknp0NNu2raIUMUrqrXWBg.png" /><figcaption>Architecture of Neural Network</figcaption></figure><p>Using this architecture I was able to achieve a new high score of 0.98957 and a ranking of 1584(Top 36%).</p><p><a href="https://www.kaggle.com/sakshaymahna/digitrecognizer-dl">DigitRecognizer-DL | Kaggle</a></p><h3>Customization of Custom Neural Network</h3><p>The most customizable part I found with the above Neural Network was the Image Preprocessing part. After checking the incorrect predictions of the Neural Network, I saw that there were mainly two types of digits the network couldn’t understand. First were numbers that were written in skew or incorrect angle and second were numbers that were written in a very similar manner to other digits. The second type of digits don’t seem to be recognizable even after corrections, however, the first part could be improved in some way and that could potentially be through configuration of the Data Generator.</p><p>Image Data Generator of Keras library has a lot of adjustable parameters which were left untouched in the first version of the notebook. Some parameters are feature-wise normalization, sample-wise normalization, zca whitening and shear transformations. I tried various combinations of these changes but for reasons uncovered yet, I was not able to get the same performance as was demonstrated before. This is something I would like to study more about maybe in the next week.</p><p>The performance was so poor, that I even hesitated to submit these predictions. Hopefully, after some improvement I would do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*BrXjJkpcejbNms7RPOtD4Q.png" /><figcaption>Very bad overfitting of data</figcaption></figure><h3>Future Work</h3><p>Since, we have finally started with Deep Learning techniques on the Digit Recognition dataset, we can also start with using Premade Neural Networks(like LeNet, Inception Network or VGG). Along with implementing our for sure score increasing technique the K Fold Cross Validation. Let’s see what we can get done in the next week.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c73d817503e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Learning | Week 4]]></title>
            <link>https://sakshum19.medium.com/project-learning-week-4-186e552936da?source=rss-687b97271d10------2</link>
            <guid isPermaLink="false">https://medium.com/p/186e552936da</guid>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Sakshay Mahna]]></dc:creator>
            <pubDate>Sat, 01 May 2021 15:11:40 GMT</pubDate>
            <atom:updated>2021-05-01T15:11:40.932Z</atom:updated>
            <content:encoded><![CDATA[<p>Week 4 of the learning Machine Learning through a Project based approach</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V7CM_kGiyVX2vuPh" /><figcaption>Photo by <a href="https://unsplash.com/@matthew_t_rader?utm_source=medium&amp;utm_medium=referral">Matthew T Rader</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First week of the Digit Recognizer Challenge. Learning a lot of things through this challenge. There seems to be more and more knowledge that seems to unfold as progress is made every week. Some really amazing data visualization and dimensionality reduction techniques coming ahead in this post.</p><h3>Exploratory Data Analysis</h3><p>Every machine learning project has to start with some of data exploration. It enables us to know which machine learning approach to use(even to use a machine learning technique or not), what are some of the example data and so on. Quite interestingly, this competition does not seem to have any interesting/good EDA notebooks as such. The best everyone has done, is to combine the little data exploration they have done as a small section in their overall notebook(Just realized while writing this an EDA notebook would be quite useful for someone looking for the same #Opportunities).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*h8hq3nSRXpWGJOD9t_A-Zg.png" /><figcaption>Histogram Distribution of Training Examples</figcaption></figure><p>However, following the pipeline I developed some basic data exploration code. The final observations from the data analysis are:</p><ul><li>There are 42000 training examples and 28000 labels to predict</li><li>There are 784 pixels in every image, implying each image is of size 28x28</li><li>1 has the highest number of training samples(4684) and 5 has the smallest number of training samples(3795). However, this ratio is quite small and immaterial to our training process</li></ul><h3>Support Vector Machines</h3><p>The first non Deep Learning technique, that we tried for this project is Support Vector Machines. Support Vector Machines are extremely powerful for classification and regression tasks. The theory for them consists of a lot of definitions, so not appropriate for this blog. The StatsQuest video explains the concept quite brilliantly. Scikit-Learn library already has the implementation: SVC Support Vector Classifier. Making use of the RBF kernel and 1000 as the regularization parameter, the submission was able to make a score of 0.97953 giving a rank of 2415 (~ 60 percentile).</p><p><a href="https://www.youtube.com/watch?v=FgakZw6K1QQ">(3) StatQuest: Principal Component Analysis (PCA), Step-by-Step — YouTube</a></p><h3>Dimensionality Reduction</h3><p>Dimensionality Reduction is data compression kind of technique where we shorten the dimensions of the data in order for visualization or handling purposes. By combining this with other Machine Learning methods, we can achieve a faster training of a ML model and avoid the problem of “Curse of Dimensionality”; simply put some ML models perform poorly when given high dimension data. Following this wonderful notebook we had to try 3 dimensionality reduction techniques: PCA, LDA and t-SNE. This is again a Test and Examine approach to selection of Dimensionality Reduction technique.</p><h4>Principal Component Analysis</h4><p>PCA stands for Principal Component Analysis. This technique reduces dimensions by increasing the variance between data points(mathematically derivation starts along this increase of variance). After some testing, 60 principal components for this technique gave a good value of validation score. By keeping 60 principal components, the first, second and last components were retaining 9.7%, 7.1% and 0.24% of variance respectively. Overall variance retained was around 85%. Finally, by making use of PCA along with SVC gave a final score of 0.98715.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*eThO-IqLB8zIhtL_iF96Tg.png" /><figcaption>Representation of the 60 principal components</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*Fh7uWZ-wdeAnKjAHVAJpVg.png" /><figcaption>Image Reconstruction using those 60 components</figcaption></figure><h4>Linear Discriminant Analysis</h4><p>LDA stands for Linear Discriminant Analysis. This technique is almost very similar to PCA, however in contrast this is supervised learning technique(in implementation terms, we have to pass training data as well as their training labels). After some testing, keeping the number of components to 9 was giving the best results. Overall, by making use of LDA along with SVC gave a final score of 0.91917.</p><h4>t-distributed Stochastic Neighbor Embedding</h4><p>t-SNE stands for the huge name. t-SNE is very different from PCA and LDA and comes under the category of Manifold Learning techniques. These are a class of algorithms that transform the data into lower dimensions in a non Linear fashion. Extremely amazing talk was given at PyData on Manifold Learning, here’s the link:</p><p><a href="https://www.youtube.com/watch?v=j8080l9Pvic">(3) Manifold Learning and Dimensionality Reduction for Data Visualization… — Stefan Kühn — YouTube</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*wGf6kpxuhklVgwBetUIdXg.png" /><figcaption>t-SNE visualization of the clusters</figcaption></figure><p>t-SNE is an extremely powerful clustering technique. So powerful, that it can even generate some clusters from random noise(one drawback of this algorithm). Therefore, requires sensitive hyperparameter tuning. It has two main hyperparameters, Perplexity and Iterations. It is considered as one of the best Data Analysis technique.</p><h3>Future Work</h3><p>So, this was all the progress made in this week. I hoped to finish all non Deep Learning based techniques by the end of this week. There is still one left to try out, K-Nearest Neighbors and Logistic Regression. So that would be the work for next week.</p><p>Link of my notebook:</p><p><a href="https://www.kaggle.com/sakshaymahna/digitrecognizer?scriptVersionId=61386822">DigitRecognizer | Kaggle</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=186e552936da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Learning | Week 3]]></title>
            <link>https://sakshum19.medium.com/project-learning-week-3-c3f2e9a9890c?source=rss-687b97271d10------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3f2e9a9890c</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[projects]]></category>
            <dc:creator><![CDATA[Sakshay Mahna]]></dc:creator>
            <pubDate>Sat, 24 Apr 2021 13:04:44 GMT</pubDate>
            <atom:updated>2021-04-24T13:04:44.142Z</atom:updated>
            <content:encoded><![CDATA[<p>Week 3 of the learning Machine Learning through a Project based approach</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*glfwE-HJMickCitn" /><figcaption>Photo by <a href="https://unsplash.com/@foxxmd?utm_source=medium&amp;utm_medium=referral">Matt Duncan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This was the final week of our first Machine Learning Project, the Titanic-Machine Learning through Disaster competition. There were a lot of expectations this week with regards to improvements on score which we failed to meet up. Tried little variations on the base code, with a minimal success. Anyways, the purpose is to learn, which we did in a good amount.</p><h3>Weighted Mean of K Fold predictions</h3><p>Last week, by implementing the Survival Rate feature along with K Fold Cross Validation gave a huge boost to our score on the Leaderboard. A minor adjustment to K Fold prediction that we can logically do is to: Instead of directly averaging the K predictions, weighted average the K predictions. The weights of the K predictions can be taken proportional to the OOB score for each of K Fold validations.</p><p><strong>OOB Score: </strong>For Random Forest classifiers, the Out of Bag error measures in some form, the prediction accuracy of a model by feeding it examples that were not encountered in the training process. There is some subtle difference between validation score and oob score which are addressed along with more information on this Medium article:</p><p><a href="https://towardsdatascience.com/what-is-out-of-bag-oob-score-in-random-forest-a7fa23d710">What is Out of Bag (OOB) score in Random Forest? | by Navnina Bhatia | Towards Data Science</a></p><p>After applying the above change, a slight increase in the score was observed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-Iwcm-hTjUzA8bcddLPJg.png" /><figcaption>The best score possible till date</figcaption></figure><h3>Other Machine Learning models</h3><p>Next thing I wanted to try was to do some feature engineering on my own and come up with a new feature for the project. Very good features were already implemented in the code that I had. All I could think of was some rudimentary multiplications and additions, which would rarely be able to affect the performance of the algorithm.</p><p>Hence, before wrapping up with this competition(3 weeks were enough) I tried to check the performance on two other models as well: Multi Layer Perceptron Classifier and Logistic Regression Classifier. The reason being the complexity that Neural Networks can learn and the simplicity that Logistic Regression offers. The training and testing scores on the notebook seemed promising but the final submission score was very less compared to the current submission that we had.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmQ9tvB1qGIv6CuaWfD6ag.png" /><figcaption>The latest 4 submissions</figcaption></figure><h3>Things left to try</h3><p>After I had decided to move on to the next competition, I realized that I had not yet fully tried ensembling some models. This notebook on stacking machine learning models seemed worth a shot, but this technique can probably wait for the next competition. So, the final score that we have for this competition is 0.80622 with a rank of 1207 (Top 4%)</p><p><a href="https://www.kaggle.com/arthurtok/introduction-to-ensembling-stacking-in-python">Introduction to Ensembling/Stacking in Python | Kaggle</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*65YozEx6fTgJ04s2xhyZIw.png" /><figcaption>Titanic : Top 4%</figcaption></figure><h3>Next Competition | Digit Recognition</h3><p>The next big project that we are going to take up is the Digit Recognition competition. As the name suggests, in this competition, we have to develop a Machine Learning model that recognizes the value of digits given an image of the digit. This competition falls under the Computer Vision category.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c5V7rpQ69t4SAGwg" /><figcaption>Photo by <a href="https://unsplash.com/@volkanolmez?utm_source=medium&amp;utm_medium=referral">Volkan Olmez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The dataset used in this competition is the MNIST dataset, which is considered the “Hello World” dataset of Computer Vision. After going through some discussions and notebooks of this competition, the techniques that are commonly used for this competition are:</p><ul><li>Machine Learning without Deep Learning(KNN and SVM)</li><li>Machine Learning with Deep Learning (Prebuilt Neural Networks and Selfbuilt)</li><li>Dimensionality Reduction</li></ul><p>Once again we have a lot of scope for learning the practical implementations of a lot of Machine Learning techniques. Some of the interesting notebooks that I found for this competition are the following:</p><p><a href="https://www.kaggle.com/arthurtok/interactive-intro-to-dimensionality-reduction">Interactive Intro to Dimensionality Reduction | Kaggle</a></p><p><a href="https://www.kaggle.com/allunia/how-to-attack-a-machine-learning-model">How to attack a machine learning model? | Kaggle</a></p><p>From next week onwards, we would start working on the Digit Recognizer competition, using Machine Learning techniques without Deep Learning. So, let’s move forward with it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3f2e9a9890c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Learning | Week 2]]></title>
            <link>https://sakshum19.medium.com/project-learning-week-2-2ca7f0c7b8bc?source=rss-687b97271d10------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ca7f0c7b8bc</guid>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Sakshay Mahna]]></dc:creator>
            <pubDate>Sat, 17 Apr 2021 13:29:24 GMT</pubDate>
            <atom:updated>2021-04-17T13:29:24.628Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the week 2 of the learning Machine Learning through a Project based approach</p><p>I’m in the 2nd week of the Machine Learning challenge; to learn Machine Learning through a Project based approach. In the 1st week, we started with the Titanic-Machine Learning through Disaster competition and developed a baseline model. This week, I worked on improving the “Front End” of the Exploratory Data Analysis and the final submission score. Lot’s of learnings this week, so let’s get to it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DvzTW8esBgreGRe7" /><figcaption>Photo by <a href="https://unsplash.com/@fossy?utm_source=medium&amp;utm_medium=referral">Fab Lentz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Exploratory Data Analysis (Enhancement)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*sEJnKDClHANu_YXgWlQd6g.png" /><figcaption>Plot using plotly</figcaption></figure><p>Have to say Plotly is such a wonderful library. As it’s website says, “Front End for Machine Learning”. Plotly enables us to make interactive plots on a Python Notebook. Considering a typical workflow, after getting done with the basic Exploratory Data Analysis, using Plotly to make the final plots, definitely puts a cherry on the top. Here is my final EDA notebook:</p><p><a href="https://www.kaggle.com/sakshaymahna/exploratorydataanalysis-titanic">ExploratoryDataAnalysis-Titanic | Kaggle</a></p><h3>Ensemble Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9O3Fzi-7aLHLTbkgAEXVlg.png" /><figcaption>Poor score compared to Baseline</figcaption></figure><p>The next planned task for the week was to test Ensembled models. How they performed and scored. However, they scored worse than (just slightly) the Random Forest Classifier used earlier. For the ensemble technique, I trained 3 of the best performing models RandomForest, GradientBoosting and XGBoost algorithms, tuned their hyperparameters and used the Ensemble Voting Classifier provided by SKLearn. Not only it took a considerable time to learn but also scored lesser than the previous submission. Here is the notebook:</p><p><a href="https://www.kaggle.com/sakshaymahna/machinelearning-titanic?scriptVersionId=59504541">MachineLearning-Titanic | Kaggle</a></p><h3>Advanced Feature Engineering</h3><p>After going through various discussions and notebooks searching what optimizations could be done next, I came across this mind blowing notebook:</p><p><a href="https://www.kaggle.com/gunesevitan/titanic-advanced-feature-engineering-tutorial">Titanic — Advanced Feature Engineering Tutorial | Kaggle</a></p><p>Gunes, the author of this notebook has done an amazing work with this dataset. Extensively performed the data analysis and great feature engineering on the data. Following this notebook, I was able to get a score of 0.80143, which is quite a good improvement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*HDzQgNWxF_0BzdRxRHAmGQ.png" /><figcaption>Improvements</figcaption></figure><p>The following are the points learned from the notebook:</p><h4>Mean or Median for Data Imputation?</h4><p>If the data is skewed, it is better to use Median. If the data is not skewed and has even Gaussian distribution, it is better to use Mean. This gives Median a form of outlier resistance, which Mean is not able to provide, because the Mean has to deliver a representative of the data.</p><p>One additional point, not related to Mean/Median but to Data Imputation. The data can be imputed by any means necessary, even if we have to search about it on the internet. In the notebook, there were 2 missing boarding ports of passengers. In order to impute the data, Gunes googled the name of the passengers to get their boarding ports. Implying, such techniques should also be to the Data Imputation part.</p><h4>How does binning help a model learn?</h4><p>There were a lot of features that Gunes binned before feeding it to the Machine Learning model, like Age and Fare. Using binning does lead to a loss of data as we subsample the data that we have. However, it also helps form a good classification of the data if the number of bins are appropriate. It also helps normalize the data in terms of the range of their values, and the frequency of their occurrence.</p><p>Also, one important implementation point mentioned in the notebook is:</p><blockquote>Splits and Spikes are easier for a Decision Tree to learn</blockquote><p>Therefore, we may observe in the Data Analysis part whether a Decision Tree should be used or not.</p><h4>K Fold Cross Validation</h4><p>K Fold cross validation is a very good technique to perform validation while training on a dataset. The technique Gunes used for predicting on the test set values is mostly used in Competitions, but is worth having a look at. In brief, the steps are:</p><ul><li>Divide the training dataset into N parts</li><li>Train your model on K-1 parts and validate/test the model on 1 part</li><li>Do these training iterations for every K-1, 1 combination of dataset (There will be K iterations for this)</li><li>For every training iteration, make the model predict the test set data and keep a note of the probabilities of prediction for each iteration</li><li>Finally, we can average the probabilities and return the result for the test set</li></ul><p>This technique slightly improved the score that I already had. Also, for this step, we had to use slightly overfitted model. The reason being, since we are taking an average (dividing by K) in the final step, it is good to have larger individual values. Overfit models, give larger probability values when we feed them values. Therefore, the case. This video from StatsQuest was really useful in understanding the concept:</p><p><a href="https://www.youtube.com/watch?v=fSytzGwwBVw">Machine Learning Fundamentals: Cross Validation — YouTube</a></p><h4>Feature Engineering : Survival Rate</h4><p>This feature combined with the K Fold validation technique boosted the score from 0.77990 to 0.80143, massive improvement. The rationale behind using this feature is that, people travelling in families survived if most members of the family survived. This same logic is applied to Tickets, since families or people travelling together would have the same Tickets. The steps for it’s implementation are:</p><ul><li>Group the data based on Family Name and Ticket</li><li>Find the median Survival value for the groups based on Family and Ticket, and the total average Survival Rate of the whole data</li><li>In the training set assign the total average to people who were travelling alone, and the median value to members of the family. Do this same for Ticket survival rate</li><li>Similarly, do for the testing set, accordingly if their family members were present in the training set. Do this same for Ticket Survival Rate</li><li>Finally, for each entry of the data, compute and store the average of Family Survival Rate and Ticket Survival Rate</li></ul><p>Final analysis of training showed that Survival Rate was the 4th most important feature for learning the dataset.</p><p>So, these were all the major improvements and learnings from the Advanced Feature Engineering notebook. The steps for the next week would be to trying to come up with a new feature and keep reading discussions to improve the score and learn something new. Here is the current version of my notebook:</p><p><a href="https://www.kaggle.com/sakshaymahna/machinelearning-titanic?scriptVersionId=59929029">MachineLearning-Titanic | Kaggle</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ca7f0c7b8bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning | Project Based Learning]]></title>
            <link>https://sakshum19.medium.com/machine-learning-project-based-learning-fb78d8f448f0?source=rss-687b97271d10------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb78d8f448f0</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[kaggle]]></category>
            <dc:creator><![CDATA[Sakshay Mahna]]></dc:creator>
            <pubDate>Sun, 11 Apr 2021 04:59:20 GMT</pubDate>
            <atom:updated>2021-04-11T04:59:20.898Z</atom:updated>
            <content:encoded><![CDATA[<p>Roadmap to Machine Learning using a Project based approach</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IWwOsCPpU-oL7S-U" /><figcaption>Photo by <a href="https://unsplash.com/@roadtripwithraj?utm_source=medium&amp;utm_medium=referral">Road Trip with Raj</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Here goes another post regarding the road map to learning Machine Learning. But, let’s try making this a little different. There are a lot of posts on the Internet, that describe how to get started with your Machine Learning journey; what courses to take, what projects to do and what not! Honestly, I have tried a lot of them. Watched a number of courses, took the Machine Learning course in my college and even took part in a Kaggle competition(very disappointing performance), but still don’t have the confidence to say that given a problem, I can solve it using Machine Learning. In order to bridge this confidence gap, I have come up with a new kind of Project Learning approach. So, let’s get to it!</p><h3>Background</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1BiS44bsmNV6PHRg" /><figcaption>Photo by <a href="https://unsplash.com/@hindawi?utm_source=medium&amp;utm_medium=referral">AHMED HINDAWI</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Before starting, I would like to enumerate over my previous Machine Learning knowledge and other related skills. I am currently a third year CSE undergraduate. I have completed the Coursera based <a href="https://www.coursera.org/specializations/deep-learning">Deep Learning Specialization</a> (Auditing each course) and currently doing <a href="https://cse.iitrpr.ac.in/ckn/courses/s2020/cs503/cs503.html">this Machine Learning course</a> at my college. I have also completed 2 <a href="https://www.kaggle.com/learn/overview">Kaggle Courses</a>: Intro to Machine Learning and Feature Engineering. Some of the projects that I have worked on include the assignments of the courses and the<a href="https://www.kaggle.com/c/lyft-motion-prediction-autonomous-vehicles"> Lyft Motion Prediction</a> Kaggle Competition. Other than that, I have a mathematical background and good coding skills (Computer Science and Engineering student).</p><h3>Idea and Approach</h3><p>Considering the background knowledge that I have, anyone would suggest me to work on some projects to get the momentum going. This is exactly what I thought! In order to improve your skills the best way is to apply them. So, here is the plan that I have come up with, to improve my Machine Learning skills through projects.</p><p>Kaggle has a number of competitions, ranging from Knowledge based to Prizes based. As one can guess, the Prizes based competitions are tough and have a time frame. However, Knowledge based competitions are infinitely ongoing competitions, are relatively easier and have a lot of discussions and notebooks. Hence, these Knowledge based competitions seem really good for someone starting out and learning for the first time. Also, looking at the list of Knowledge based Competitions, we can see that the competitions range from all kinds of Machine Learning domains:</p><ul><li>Titanic-Machine Learning from Disaster (Supervised Machine Learning)</li><li>House Prices-Advanced Regression (Supervised Machine Learning)</li><li>Natural Language Processing with Disaster Tweets (NLP)</li><li>Contradictory, My Dear Watson (NLP)</li><li>Digit Recognizer (Computer Vision)</li><li>Petals to the Metal (Computer Vision)</li><li>I’m something of a Painter Myself (Computer Vision)</li><li>Connect X (Reinforcement Learning)</li></ul><p>Hence, even working on these competitions would gain a great amount of experience if we can patiently try different approaches to each problem and thoroughly work on them. Also potentially, by keeping our notebooks public, we may even receive some feedback on the work we have done and how that could be improved.</p><p>So, here is the Final Idea : Over the next couple of months, work on these competitions one by one.</p><ol><li>Perform, all the steps of Machine Learning: Data Preprocessing, Exploratory Data Analysis, Model Building and Testing.</li><li>Submit a baseline approach and work on improving the score for some weeks by making use of Discussions and Notebooks on Kaggle.</li><li>Keep updating the learning of each week on Medium Blogs.</li><li>Keep repeating the same for other competitions.</li></ol><h3>Getting started with Titanic-Machine Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k-Lgdh4CEd9V28NM" /><figcaption>Photo by <a href="https://unsplash.com/@anniespratt?utm_source=medium&amp;utm_medium=referral">Annie Spratt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is the first week of the Project Learning challenge. The first project we would work on is the Titanic-Machine Learning from Disaster. This is the most basic competition on Kaggle. In this competition, we would have to use Machine Learning to create a model that predicts which passengers survived the Titanic shipwreck.</p><p><a href="https://www.kaggle.com/c/titanic">Titanic — Machine Learning from Disaster | Kaggle</a></p><p>We first start off with the Exploratory Data Analysis of the Dataset. Exploratory Data Analysis comprises of Dataset exploration, Univariate Analysis, Bivariate Analysis and Multivariate Analysis. In one sentence, Dataset Exploration gives insight into the various fields present in the dataset, the number of null values and the summary of each field of the dataset. Univariate Analysis comprises of comparing a single data field with the target output, Bivariate Analysis comprises of comparing two data fields with the target output and Multivariate Analysis comprises of comparing multiple data fields with the target output.</p><p>Some insights gained into the data were: more number of men died, more rich people survived, people with spouse and kids survived in greater number and so on. This data exploration also suggested the non-linear nature of the data.</p><p>I also got two comments on my Exploratory Data Analysis notebook and 5 upvotes. Would work on the feedback I received in one comment.</p><p><a href="https://www.kaggle.com/sakshaymahna/exploratorydataanalysis-titanic">ExploratoryDataAnalysis-Titanic | Kaggle</a></p><p>Some work also went into the model building part. This particular <a href="https://medium.com/i-like-big-data-and-i-cannot-lie/how-i-scored-in-the-top-9-of-kaggles-titanic-machine-learning-challenge-243b5f45c8e9">Medium article</a> was really helpful in setting up a baseline model. Using some Data Preprocessing and simple Feature Engineering, a Random Forest Classifier resulted in a score of 0.77990 (top 26%). As a next step, following <a href="https://www.kaggle.com/chienhsianghung/titanic-top-11-starter-i-models-comparing">this notebook</a>, I compared the performance of different Machine Learning models, work on optimizing the hyperparameters for the best model and use that for the final predictions. Well, the score for that was a little lesser than the previous one (0.74641).</p><p><a href="https://www.kaggle.com/sakshaymahna/machinelearning-titanic">MachineLearning-Titanic | Kaggle</a></p><p>Now, one question that would come up to any beginner would be; How do we decide which Machine Learning model to use for any particular problem. Since, we tried different Machine Learning models and took the one which performed best, shouldn’t there be a metric to choose from. The answer to this question depends: We can draw some insights by visualizing the distribution of data and the number of samples, but the best model can only be determined by trial and error. Machine Learning in itself, is a trial and error based technique. Hence, it is fine to try a number of different approaches to see which fits the dataset in the best way possible. This <a href="https://www.kaggle.com/c/titanic/discussion/230894">discussion page</a> helped clear the doubt.</p><h3>Future Work</h3><p>The next week’s work would involve : Reading about the Machine Learning models that I randomly fit and selected, building ensemble models for better performance, exploring the Exploratory Data Analysis using Plotly (interactive graphs), and finally keeping up with consistently following this learning approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z7u1owv6zPXMUZSy" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is it, for this story. Thank you, for patiently reading through this post. Please let me know about any comments or improvements over this post. The next part would be uploaded the next week.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb78d8f448f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>