<?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 Namratesh Shrivastav on Medium]]></title>
        <description><![CDATA[Stories by Namratesh Shrivastav on Medium]]></description>
        <link>https://medium.com/@namratesh?source=rss-e14e32836c01------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*c45uNSgO8yIDF7psLBBzAg.jpeg</url>
            <title>Stories by Namratesh Shrivastav on Medium</title>
            <link>https://medium.com/@namratesh?source=rss-e14e32836c01------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 03:27:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@namratesh/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[From KNN to BERT: A Data Science Interviewee’s Guide to Algorithms and Techniques]]></title>
            <link>https://namratesh.medium.com/from-knn-to-bert-a-data-science-interviewees-guide-to-algorithms-and-techniques-da20b445b8fd?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/da20b445b8fd</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Mon, 10 Apr 2023 08:43:18 GMT</pubDate>
            <atom:updated>2023-04-10T08:43:18.217Z</atom:updated>
            <content:encoded><![CDATA[<p>When preparing for a data science interview, it’s essential to have a solid understanding of several key topics. Some topics are necessary for all data science roles, while others may be more job-specific. Below are some crucial topics to prepare for your interview:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sCziuBrosuBjYiY5" /><figcaption>Photo by <a href="https://unsplash.com/ko/@mkvandergriff?utm_source=medium&amp;utm_medium=referral">Maranda Vandergriff</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Machine Learning Algorithms</h3><ul><li>K-Nearest Neighbors (KNN)</li><li>Naive Bayes</li><li>Logistic Regression</li><li>Linear Regression</li><li>Support Vector Machines (SVM)</li><li>Decision Trees</li><li>Random Forest</li><li>XGBoost</li><li>K-Means</li><li>Density-Based Spatial Clustering of Applications with Noise (DBSCAN)</li><li>Hierarchical Clustering</li><li>Agglomerative Clustering</li></ul><h3>Performance Metrics</h3><ul><li>Accuracy</li><li>Confusion Matrix</li><li>F1 Score</li><li>Precision, Recall</li><li>Mean Squared Error (MSE) and Root Mean Squared Error (RMSE)</li><li>Mean Absolute Percentage Error (MAPE) and Mean Absolute Error (MAE)</li><li>R-Squared (R²) and Adjusted R-Squared (Adjusted R²)</li></ul><h3>Optimization</h3><ul><li>Gradient Descent</li><li>Stochastic Gradient Descent</li><li>Batch Gradient Descent</li><li>Adam Optimization</li><li>Adagrad</li><li>RMSProp</li></ul><h3>Basics of Deep Learning Algorithms</h3><ul><li>Neural Network</li><li>Activation Functions</li><li>Batch Normalisation</li><li>Dropout</li><li>Pooling</li><li>Convolutional Neural Networks (CNNs)</li><li>Recurrent Neural Networks (RNNs)</li><li>Long Short-Term Memory (LSTM)</li><li>Autoencoders</li><li>Transfer Learning</li></ul><h3>Basics of Natural Language Processing (NLP):</h3><ul><li>Bag of Words</li><li>Term Frequency-Inverse Document Frequency (TF-IDF)</li><li>Word2Vec</li><li>Stemming</li><li>Lemmatization</li><li>Tokenization</li></ul><h3>Advanced Techniques of NLP</h3><ul><li>Attention</li><li>Transformer</li><li>Bidirectional Encoder Representations from Transformers (BERT) and its variations</li><li>Generative Pre-trained Transformer (GPT) models</li></ul><h3>Computer Vision</h3><ul><li>VGG</li><li>Residual Networks (ResNet)</li><li>AlexNet</li><li>Inception</li><li>You Only Look Once (YOLO)</li></ul><p>It’s worth noting that not all of these topics may be relevant to your specific role, so focus on the ones that are most important to your job responsibilities. If you’re applying for an NLP-focused role, for example, you may not need to know much about computer vision algorithms, and vice versa.</p><p>If you think we missed any important topics, please let us know.</p><p>Happy learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da20b445b8fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extract Tables from PDF with 2 Lines of Code]]></title>
            <link>https://medium.com/analytics-vidhya/extract-tables-from-pdf-with-2-lines-of-code-cdd15b195020?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdd15b195020</guid>
            <category><![CDATA[extraction]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Sun, 12 Jun 2022 14:19:42 GMT</pubDate>
            <atom:updated>2022-06-12T14:19:42.686Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Tabula</strong> is the library that can be used to extract tables from pdf. So first let’s install the library with the below command:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0ea92ddbbcc66511761cd29dd3f9237/href">https://medium.com/media/c0ea92ddbbcc66511761cd29dd3f9237/href</a></iframe><p>After installing the tabula, We can use pdf to extract the data. I’m using <a href="https://slicedinvoices.com/pdf/wordpress-pdf-invoice-plugin-sample.pdf">this pdf</a> to extract the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NqvFvopsamUqMyb_nalXaA.png" /><figcaption>Sample of PDF — <a href="https://slicedinvoices.com/pdf/wordpress-pdf-invoice-plugin-sample.pdf">https://slicedinvoices.com/pdf/wordpress-pdf-invoice-plugin-sample.pdf</a></figcaption></figure><h3>Code</h3><p>Let’s extract the Table from the PDF</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed0ba73af94e82c2e7f73275e6783f38/href">https://medium.com/media/ed0ba73af94e82c2e7f73275e6783f38/href</a></iframe><p>The above pdf has 3 tables, so we’ll be getting a list with 3 pandas dataframe</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d80249e2bad1a381522ab2f1636cc937/href">https://medium.com/media/d80249e2bad1a381522ab2f1636cc937/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*ZnYs3Y0zv65Lg9JbkRPe7w.png" /><figcaption>Table-1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9hSov5MVAoFfBzZf3oSbg.png" /><figcaption>Table-2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*Q-j7b7XaX4nqaWMDhnegcw.png" /><figcaption>Table-3</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdd15b195020" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/extract-tables-from-pdf-with-2-lines-of-code-cdd15b195020">Extract Tables from PDF with 2 Lines of Code</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extract Tables from Images Using Tablenet]]></title>
            <link>https://medium.datadriveninvestor.com/extract-tables-from-images-using-tablenet-249627142e0d?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/249627142e0d</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[transfer-learning]]></category>
            <category><![CDATA[vgg19]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Tue, 15 Jun 2021 06:34:03 GMT</pubDate>
            <atom:updated>2022-12-27T03:53:50.994Z</atom:updated>
            <content:encoded><![CDATA[<h3>Extract Tables from Images Using Tablenet — An End-to-End Solution</h3><p>Hello Readers,</p><p>Welcome to my blog, In this blog, I’m going to show you how can you implement a research paper from scratch and deploy your model using streamlit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cpk1wdAbajZKkknq_jldYw.jpeg" /><figcaption><a href="https://www.hebergementwebs.com/image/07/077db1b99fd856e3a14d349798a91ae5.webp/2021-icdar-competition-table-detection-by-image-recognition2021-icdar-competition-table-detection-by-image-recognition-0.webp">https://www.hebergementwebs.com/image/07/077db1b99fd856e3a14d349798a91ae5.webp/2021-icdar-competition-table-detection-by-image-recognition2021-icdar-competition-table-detection-by-image-recognition-0.webp</a></figcaption></figure><h3>Table of Contents:</h3><ol><li>Business Problem</li><li>Dataset Source and overview</li><li>Performance Matrix</li><li>Why Deep Learning Solution Not The Traditional Machine Learning</li><li>Dataset Preparation and Basic EDA</li><li>TableNet Model Architecture — Overview</li><li>Model Implementation using Tensorflow</li><li>Tensorflow Data Pipeline for Training</li><li>Custom Callbacks and Train the model</li><li>Text Extraction from Table</li><li>Post EDA of our Solution</li><li>Deployment on Streamlit</li><li>Future Improvements</li><li>References</li></ol><h3>Business Problem</h3><p>We don&#39;t find any good or end-to-end solution when we talk about table detection and extraction from pdf/images. It is one of the most major areas which yet needs to be explored in the machine learning field.</p><p>Many processes are yet to automate, like writing data from images/pdf to excel or Validating the table and its content from the pdfs in the testing domain. We can’t automate validation of table in pdfs using selenium or another automation tool. We have some tools that can extract the data from pdf or we can use the OCR method to extract the data. But these solution doesn’t work in a table. As these tools/ocr methods read the file line-wise, when we extract the data from PDFs/ images, the formatting of the table is mixed up, so we cannot validate which row corresponds to which column versa.</p><h3>Dataset Source and overview</h3><p>We have taken the dataset from the below source:</p><p><a href="https://www.icst.pku.edu.cn/cpdp/sjzy/index.htm">Marmot Dataset</a></p><p>The dataset contains 494 images and all the images contain the table. Table dimensions that are present in images are given in an XML format like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0de56789cc4c8564ed9cb1e7c2d3ab2/href">https://medium.com/media/f0de56789cc4c8564ed9cb1e7c2d3ab2/href</a></iframe><p>XML files contain two things size and object:</p><ul><li><strong>Size: </strong>Element has the height, width, and depth of the image.</li><li><strong>Object: </strong>Element has every single col region in an image.</li></ul><h3><strong>Performance Matrix</strong></h3><p>To measure the performance of our model, we’ll be using F1 score. As it penalizes both precision and recall. F1 score: It is the harmonic mean of precision and recall.</p><p><strong>Why did we choose the F1 score as our performance matrix</strong></p><p><strong>Precision </strong>= It is all about positive class. Precision is all the points that are declared to be positive but what percentage of them are actually positive? <strong>Recall </strong>= It is all the points that are actually positive but what percentage declared positive.</p><p>As, we are planning to deploy in the testing domain, where a false positive and false negative both are important, so we’ll be using the F1 score.</p><p>In our model, we’ll be calculating precision and recall for all the individual images as a post-EDA to see which images are working fine on our model and which are not.</p><h3><strong>Why Deep Learning Solution Not The Traditional Machine Learning</strong></h3><p>There is no traditional ML method that can be used to extract the data from images. We have to go for OpenCV, deep learning methods like CNN, DNN to complete our task</p><h3>Dataset Preparation and Basic EDA</h3><p>A dataset in XML and image format, we’ll be following the 5 below steps to create our dataset:</p><ul><li>Extract of table’s height, width, and column’s xmin, ymin, xmax, and ymax and store it in a dataframe.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34ac8b9f4edeeaa132784761855a53e6/href">https://medium.com/media/34ac8b9f4edeeaa132784761855a53e6/href</a></iframe><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*LamBLB2uAkelpGoiaFQanQ.png" /></figure><ul><li>Save the image path of the individual image in dataframe</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c62600f676c9e4b9a6ed4500691d7c60/href">https://medium.com/media/c62600f676c9e4b9a6ed4500691d7c60/href</a></iframe><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*gGxEwyKK64XwQOXOX9nUEQ.png" /></figure><ul><li>Create a mask of each image using tables and columns dimensions and store it in a new folder tableMask and columnMask respectively.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5567476f1475b682626c75171db77647/href">https://medium.com/media/5567476f1475b682626c75171db77647/href</a></iframe><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*GJ9K1EFx911YnUBVBCWPlQ.png" /></figure><ul><li>Convert all BMP(bitmap images) in JPEG format.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4290fd9409611518f834990a50e3807/href">https://medium.com/media/f4290fd9409611518f834990a50e3807/href</a></iframe><ul><li>Save the table mask and column mask images path in the dataframe.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b46b1c060bc3d39ad387cefcf8bccbc/href">https://medium.com/media/3b46b1c060bc3d39ad387cefcf8bccbc/href</a></iframe><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vdxCWSmvhC8L-PVV1l84VQ.png" /></figure><ul><li>After getting the data, We’ll be using <a href="https://www.tensorflow.org/guide/data">tensflows’s tf. data </a>API to build our data pipeline.</li></ul><h3>TableNet Model Architecture — Overview</h3><p><a href="https://arxiv.org/pdf/2001.01469.pdf">TableNet Architecture </a>is based on a semantic segmentation model. The model is derived into two parts. In the first part, they have used per trained vgg-19 model and their weights. They have disconnected the fully connected layer to the 1*1 convolution layer. Where all the layers of a convolution block are connected with the Relu activation function and a dropout layer of 0.8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*_Moq2cYMVPeNLP3ycDKjXQ.png" /><figcaption>TableNet Architecture : <a href="https://arxiv.org/pdf/2001.01469.pdf">https://arxiv.org/pdf/2001.01469.pdf</a></figcaption></figure><blockquote>The input image for the model is first transformed into an RGB image and then, resized to 1024 * 1024 resolution. This modified image is processed using Tesseract OCR. Since a single model produces both the output masks for the table and column regions, these two independent outputs have binary target pixel values, depending on whether the pixel region belongs to the table/column region or background respectively.</blockquote><h3>Model Implementation using Tensorflow</h3><p>We are going to split the model implementation into 4 sections:</p><ul><li>VGG 19 model and get 3rd and 4 max pool layer output as can been seen in the image</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbf17481f8f3314b899f6de5245b0934/href">https://medium.com/media/cbf17481f8f3314b899f6de5245b0934/href</a></iframe><ul><li>Implement Table detection layer:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*1JBpXys4-m_r3bO9njRMOA.png" /><figcaption>Table Detection layer</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/599565210a25928fbf4763e7226fc71d/href">https://medium.com/media/599565210a25928fbf4763e7226fc71d/href</a></iframe><ul><li>Implement Column detection layer:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*Vjfz3h0DZWYIJm0iJD3tPQ.png" /><figcaption>Column Detection Layer</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89441666f3720f2a6dc9aa8a3f428690/href">https://medium.com/media/89441666f3720f2a6dc9aa8a3f428690/href</a></iframe><ul><li>Final Implementation to add all 3 above implementation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*NLZkbbYxd3E7BVozdi1UDQ.png" /><figcaption>Add all layers</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17a9db4c03c02a104d519f9c22ba1d94/href">https://medium.com/media/17a9db4c03c02a104d519f9c22ba1d94/href</a></iframe><h3>Tensorflow Data Pipeline AndTraining</h3><p>To Build the dataset, we’ll follow 3 small steps:</p><ul><li>Split the data in train and test and cast in TensorFlow dataset using from_tensor_slices.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b36dea8fe2733aec0577037c52e33dd5/href">https://medium.com/media/b36dea8fe2733aec0577037c52e33dd5/href</a></iframe><ul><li>Create a function to load data and do preprocess of image: read, decode and normalize.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/014462ed8eaccdb8fa2337a83bcb687d/href">https://medium.com/media/014462ed8eaccdb8fa2337a83bcb687d/href</a></iframe><ul><li>Use tf.data to map, shuffle and define the batch size</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c662b28fe5ba35e97631a4f31540a5a/href">https://medium.com/media/0c662b28fe5ba35e97631a4f31540a5a/href</a></iframe><h3>Custom Callbacks and Train the model</h3><p>Before Training the model, We are going to define our custom callback function to have more control over our training.</p><p>We are using 4 below callbacks:</p><ul><li><strong>ReduceLROnPlateau: </strong>This will reduce the training by 10% if our previous loss is decreased from the current loss.</li><li><strong>Tensorboard: </strong>This will be used for tracking and visualizing metrics such as loss and accuracy.</li><li><strong>ModelCheckpoint</strong>: This will save our best model in the given directory at every end of the epoch.</li><li><strong>EarlyStopping: </strong>This will stop our training if the validation loss is constant for 3 epochs.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80c2ec60769b3e5fff8c80034b597de3/href">https://medium.com/media/80c2ec60769b3e5fff8c80034b597de3/href</a></iframe><p><strong>Training the Model</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00e49e6ee086c977b63a6fe775416fc3/href">https://medium.com/media/00e49e6ee086c977b63a6fe775416fc3/href</a></iframe><h3>Text Extraction from Table</h3><p>We have two free options to extract the text from images tesseract and easyocr. In this project, we are using tesseract to detect tests.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5ae0cdca19f8699cc0a0ab1394280ee/href">https://medium.com/media/a5ae0cdca19f8699cc0a0ab1394280ee/href</a></iframe><p>Let’s see our model prediction for an image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c367a05efcc2eb1e5cdaa708abe4250/href">https://medium.com/media/3c367a05efcc2eb1e5cdaa708abe4250/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x8HiY4Hfs6M_fbTe-QcsxA.png" /><figcaption>mask output of our model</figcaption></figure><blockquote><strong>Text Prediction</strong></blockquote><blockquote>Th 44 vi Aatche. 1000 | 10 85 35 2000 | 10 198 100° | 101 12. roc | 200 V7 1000 | 500 5M 12.3 Tooo | 0 T 21.9 33 1000 | 50e 10 73 100 | 10F 10 — TS ioe | 50 254 1oc | o 501 100 | o ‘ 101 a 100 | 106 101 101 164.4 500 | 106 10 101 147 1000 | 500 250 100 207. 500 [10 10 10 T 14.2 100 | 10 10 1 10 500 | 50 50 Ww 30 500 | 10r 10 101 10: 51 10% | 0 ) 1 10) 17 1000 | 106 10 Lor 108 222.2 1000 [0 0 0 0 10 21.2 soo | oO o o 0 qor 152. 100 | 0 a : o 10t ar 1000 tou ak 10: ioe 1002s table ten cca 10,000 4 be</blockquote><h3>Post EDA of our Solution</h3><p>Our Solution is working for some images and for some, it’s not working. So let’s do a quick eda where we feed every image to our model and get the precision and recall for each image :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fef089f35a0a42850c319537277ffbbb/href">https://medium.com/media/fef089f35a0a42850c319537277ffbbb/href</a></iframe><p><strong>Analysis with Precision</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68c2d8d0b4519005f051016d18cec521/href">https://medium.com/media/68c2d8d0b4519005f051016d18cec521/href</a></iframe><p>→The worst precision of the model is 0.1981318145990372, and the best precision is 0.9996676445007324</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*DlVJa8zhV0D_zBSpl7NVog.png" /><figcaption>distribution plot of precision</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*zMS4rctgEsmD28Gou1_gpg.png" /><figcaption>Image with low precision = 0.26</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*pX3Sm2BcxotiaQ_6bwpMqQ.png" /><figcaption>Image with High Precision: 0.994</figcaption></figure><p><strong>Analysis with Recall:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/091d5d6fca6b76bd5e06713fd78ca6a0/href">https://medium.com/media/091d5d6fca6b76bd5e06713fd78ca6a0/href</a></iframe><p>→The worst recall of the model is 0.002588098868727684, and the best recall is 0.998153805732727</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*OslmPCKBY8mv2rEnB0yO9w.png" /><figcaption>distribution of Recall</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*h7jGZkoxa_kxjk2gr9EIcQ.png" /><figcaption>low recall with 0.0025</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*DZGz-ubc88e7Mluc3Vc-3A.png" /><figcaption>High Recall with 0.9935</figcaption></figure><p><strong>Observations: </strong>As we can see from above the low and high value of precision and recall, when we have a blurry table in the image, the precision and recall are low, and when we have a good table the precision and recall are high.</p><h3>Deployment on Streamlit</h3><p>We have saved our model and its weight and now we are going to use the same to deploy on streamlit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5b20807550f5f3940dc5771b153b126/href">https://medium.com/media/b5b20807550f5f3940dc5771b153b126/href</a></iframe><h4>Demo Video</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F02TtGWCNE5U%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D02TtGWCNE5U&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F02TtGWCNE5U%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/50cc877d8428fd5a0020db432a74a191/href">https://medium.com/media/50cc877d8428fd5a0020db432a74a191/href</a></iframe><h3>Future Improvements</h3><p>It can be further improved by using data as we have only 494 images and it’s working pretty well on this.</p><h3>References</h3><ul><li><a href="https://colab.research.google.com/drive/1dpojRslAA15q4tswH_9j8WIQRo0BITSp?usp=sharing">Google Colaboratory</a></li><li><a href="https://udibhaskar.github.io/practical-ml/debugging%20nn/neural%20network/overfit/underfit/2020/02/03/Effective_Training_and_Debugging_of_a_Neural_Networks.html">Effective Training and Debugging of a Neural Networks</a></li><li><a href="https://nanonets.com/blog/table-extraction-deep-learning/">Table OCR for Detecting &amp; Extracting Tabular Information</a></li></ul><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//arxiv.org/pdf/2001.01469.pdf&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/c58d78f189f3bc320f27b969a40c7431/href">https://medium.com/media/c58d78f189f3bc320f27b969a40c7431/href</a></iframe><ul><li><a href="https://www.tensorflow.org/tutorials/images/segmentation">Image segmentation | TensorFlow Core</a></li><li><a href="https://streamlit.io/">Streamlit * A faster way to build and share data apps</a></li><li><a href="https://www.appliedaicourse.com/">Applied Roots</a></li></ul><p>Notebook Link: <a href="https://github.com/namratesh/TableDetection">https://github.com/namratesh/TableDetection</a></p><p>Let’s connect on LinkedIn <a href="https://www.linkedin.com/in/namratesh/">https://www.linkedin.com/in/namratesh/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=249627142e0d" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/extract-tables-from-images-using-tablenet-249627142e0d">Extract Tables from Images Using Tablenet</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[M5 Forecasting — Accuracy]]></title>
            <link>https://medium.com/analytics-vidhya/m5-forecasting-accuracy-9fbbb28e0e6f?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fbbb28e0e6f</guid>
            <category><![CDATA[timeseries-forecasting]]></category>
            <category><![CDATA[competition]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[m5-forecasting]]></category>
            <category><![CDATA[kaggle]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Fri, 09 Apr 2021 14:08:53 GMT</pubDate>
            <atom:updated>2021-05-01T10:23:53.199Z</atom:updated>
            <content:encoded><![CDATA[<h3>M5 Forecasting — Accuracy</h3><h4>Estimate the unit sales of Walmart retail goods</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3zniUD4nSJpDMwxO" /><figcaption><a href="https://mofc.unic.ac.cy/launch-m5-forecasting-competition/">https://mofc.unic.ac.cy/launch-m5-forecasting-competition/</a></figcaption></figure><h3><strong>Table of contents:</strong></h3><ol><li>Business Problem</li><li>Source of Data</li><li>Why ML approach, and Why not normal Statistical Method</li><li>Performance metrics</li><li>Existing approaches to the problem</li><li>Exploratory Data Analysis</li><li>First Cut Solution</li><li>Model Explanation</li><li>Comparison of models</li><li>Future Work</li><li>References</li></ol><h3><strong>Business Problem</strong></h3><p>In the era of online stores, It’s become essential and mandatory to know the demand for any product in near future. It will help stores to stock the product which demand is going to be high in near future. If we are able to do so, it will directly improve the revenue of the company.</p><p>i.e.<em> if we have an event next week, definitely the sell will increase on some products depends on the event</em>.</p><h3>Source of Data</h3><figure><img alt="Walmart" src="https://cdn-images-1.medium.com/max/990/0*6XDwRWjD4ilMvO7H.png" /><figcaption><a href="https://www.bestdesigns.co/uploads/inspiration_images/4350/990__1511457498_404_walmart.png">https://www.bestdesigns.co/uploads/inspiration_images/4350/990__1511457498_404_walmart.png</a></figcaption></figure><p>To solve this problem, We‘ll be using <a href="https://www.kaggle.com/c/m5-forecasting-accuracy">M5 Forecasting — Accuracy </a>data from Kaggle. It is a competition hosted on Kaggle by Walmart to predict the product’s sell for the next 28 days.</p><h4>Overview of Dataset</h4><p>It’s <a href="https://otexts.com/fpp2/hts.html"><em>hierarchal time series forecasting</em></a> where we need to predict the daily sale for the next 28 days of given items. Dataset is given by Walmart and, <em>covers stores in three US States (California, Texas, and Wisconsin)</em> and includes<em> item level, department, product categories, and store details</em>. In addition, it has explanatory variables such as price, promotions, day of the week, and special events. The dataset involves the unit sales of <em>3,049 products, classified into 3 product categories (Hobbies, Foods, and households) and 7 product departments</em>, in which the above-mentioned categories are disaggregated. The products are sold across ten stores, located in three states (CA, TX, and WI)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ghR6ojoph0d4w2JwkgrkSA.png" /></figure><p>We have given 3 data frames calendar, sale_train_evaluation, and sell_price in CSV format. We have also given a format for Kaggle submission in sample_submission.csv</p><p><strong>calendar.csv</strong> — Contains information about the dates on which the products are sold.</p><p>● <strong>sell_prices.csv </strong>— Contains information about the price of the products sold per store and date.</p><p>● <strong>sales_train_evaluation.csv </strong>—Contains the historical daily unit sales data per product and store [d_1 — d_1941]</p><p>● <strong>sample_submission.csv</strong> — The correct format for submissions.</p><h3>Why ML approach, and Why not normal Statistical Method</h3><p>The statistical method can perform well when we have a univariate dataset or one-step prediction. It has been seen that for multi-step prediction, ML methods work well.</p><h3><strong>Performance metrics</strong></h3><p>We will be using <strong>RMSE (Root Mean Square Error)</strong> to evaluate our model. RMSE is a good measure when we care more about prediction. It is a square root of the average squared error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/0*s57PsIaomnWSmemt.jpg" /><figcaption><a href="https://media.geeksforgeeks.org/wp-content/uploads/20200622171741/RMSE1.jpg">https://media.geeksforgeeks.org/wp-content/uploads/20200622171741/RMSE1.jpg</a></figcaption></figure><p>RMSE gives more importance to the most significant error. If there is a slight error in demand our RMSE will increase significantly.</p><h3>Existing approaches to the problem</h3><p>We’ll be seeing the first two solutions discuss no<a href="https://www.researchgate.net/profile/Evangelos-Spiliotis/publication/344487258_The_M5_Accuracy_competition_Results_findings_and_conclusions/links/5f7c0258458515b7cf6a25e2/The-M5-Accuracy-competition-Results-findings-and-conclusions.pdf"> <em>The M5 Accuracy competition: Results, findings, and conclusions</em></a></p><h4><strong>First Placed solution:</strong></h4><p>a. He uses an equally weighted combination of various LightGBM models.</p><p>b. To train a model to produce forecasts for the product store series using data per store (10 models), store-category (30 models), and store-department (70models).</p><p>c. 220 models were built and each series was forecasting with an average of 6 models which includes two variations of each type of model, recursive and non-recursive.</p><p>d. The models considered various identifiers, calendar-related information, special events, promotions, prices, and unit sales data, both in a recursive and a non-recursive format.</p><p>e. The method was fine-tuned using the last four 28-day-long windows of available data for CV and by measuring both the mean and the standard deviation of the errors produced by the individual models and their combinations.</p><p>f. The final solution was chosen because it was providing both accurate and robust forecasts.</p><h4>Second Place Solution:</h4><p>a. This method also used equally weighted LightGBM models, however, was externally adjusted through multipliers according to the forecasts produced by N-BEATS.</p><p>b. Total 50 models were trained in which first trained per store 10 models and then five different multipliers were used to adjust their forecast.</p><p>c. LightGBM models were trained using only some basic features about calendar effects and prices (past unit sales were not considered), while the N-BEATS model was based solely on historical unit sales.</p><h4>Improvements:</h4><p>The solution discussed on the paper were used by first and second-place winners. Their solutions are very good but the main issue was it’s too complicated to understand and implement when you have very low-end devices. As we already discussed, the dataset has a very huge size. We’ll try to implement a simple solution with some good scores.</p><h4>Downcasting Data</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90d19ca4a501a852a30a793ae93c180d/href">https://medium.com/media/90d19ca4a501a852a30a793ae93c180d/href</a></iframe><p>In the downcast function, we are checking the data frame object type and changing it to low memory required type. i.e Pandas create 64bit integer value, so our downcast will change it into 8 bit.</p><h4>Merging Data</h4><p>We have given 3 data frame calendar, sale_train_evaluation, and sell_price which has <em>no unique</em> <em>columns</em> to merge the sale_train_evaluation to calendar and sell_price. First, let’s look into each data frames:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n6_lX0b34i3phidwe_W5Xg.png" /><figcaption>top 5 values of calendar</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YhfzRjO35MdMflvGFUoVBA.png" /><figcaption>top 5 values of sale_train_evaluation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*vtiPU54rfVf9kDyN7tPejw.png" /><figcaption>top 5 values of sell_price</figcaption></figure><p>we can merge the sell_price and sale_train_evaluation on item_id but if we see the calendar, there are no columns on which we add. So we are going to create two new columns ‘<em>d’</em> and ‘<em>demand’ in </em>sale_train_evaluation. Where “<em>d</em>” will be the days from <em>d_1 to d_1941 </em>with the help of pandas melt function which will help to change columns to rows. <em>and demand</em> will give the demand of a particular item on that day.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26d02b8de697b395135aaa946162e765/href">https://medium.com/media/26d02b8de697b395135aaa946162e765/href</a></iframe><p>After merging the data, our data frame will look like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cquKXpeaXxfOaw8Pr9gZXA.png" /></figure><h3>Exploratory Data Analysis</h3><ul><li><strong>How many stores are located in each state? (State has more sell which has more store)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*Z-RqFN3JLq94lWHjfQqmJw.png" /><figcaption>We have 23672436, 17754327, 17754327 stores data in CA, TX, and WI</figcaption></figure><ul><li><strong>No of products of each category?</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*P46TQ7qeWfxbv0CX0UKkKA.png" /><figcaption>We have 27892170, 10966650, 2032270 products from foods, hobbies, and household</figcaption></figure><ul><li><strong>Demand on weekday</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzXO7S3Qbg_hFgEdaUs0wQ.png" /><figcaption>We have more demand on Saturday and Sunday as compare to other days.</figcaption></figure><ul><li><strong>Demand by each store</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*hQ-n_XdRB8b3apzHLbBUqA.png" /><figcaption>Stores that are located in CA and TX has more demand as compare to WI</figcaption></figure><ul><li><strong>sell price and demand co-relation</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*lPAdc5Dy47g-0LrF5l304g.png" /><figcaption>1 . There is a negative relationship between demand and sell price. 2. We can state that if we have price high then demand will be low, vice versa</figcaption></figure><ul><li><strong>Sell on weekdays and when there is an event type 1</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QY01bFqLDALjPPtPtt0SzQ.png" /></figure><ul><li><strong>Demand in each year from 2011- 2016</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/833445f97a5b12e0acb83f7385274d1d/href">https://medium.com/media/833445f97a5b12e0acb83f7385274d1d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mp13XN3I9Zw8CDllDrxkLw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X4Ja5sJqV7NPuwBlinntXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MSax4nTEjTUoNiVy7z2lYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KrHxbJa0Xr4KNehWTzBZug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pHc7f61L_BCFqYly6QCnhQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ma9XBrDfUsDc68wWTEH3aw.png" /></figure><p><em>Observation:</em></p><ol><li>There is no or very little on Christmas every year.</li><li>There is seasonality in our data. Every year it repeats.</li></ol><h4>Final Observation</h4><ul><li>CA and TX have more demand for products as compare to WI.</li><li>We have very few days in a year when snap purchasing is allowed.</li><li>There is a negative trend in demand and sell price.</li><li>We have a higher demand for National and Religious events.</li><li>We have more product in Food department and less product in Hobbies department.</li><li>Saturday and Sunday have high demand.</li><li>Cultural events and National events have more demand.</li><li>Snap_purchasing does not make any significant impact.</li><li>If there is any event, demand is going to be increase certainly.</li><li>There is no or very little sell on Christmas every year.</li><li>There is seasonality in our data. Every year it repeats.</li></ul><h3>First Cut Solution</h3><p><strong>Handle missing values:</strong></p><ol><li>event type 1 and event_type2 event_name1 and event_name2 has 91 and 99% missing values. We’ll create one new category as new_event and will fill in all the null values.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/91c0ff11fa945e2e3e84af8e5570e607/href">https://medium.com/media/91c0ff11fa945e2e3e84af8e5570e607/href</a></iframe><p>2. Sell price has missing values, we can use interpolate method from pandas to fill the nan values</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96a56cdb1c1b31740b1c8f869d8a150c/href">https://medium.com/media/96a56cdb1c1b31740b1c8f869d8a150c/href</a></iframe><p><strong>Data Preparation</strong></p><p>To prepare data, we’ll follow below steps:</p><ul><li>Melt the sale_train_eval and downcast it</li><li>Use sample_submission to create the format to submit the prediction on Kaggle</li><li>split the data by days</li><li>create one new column as part which has our train, test1, and test2</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85df04f9f6cdd62c718718566ab60f2b/href">https://medium.com/media/85df04f9f6cdd62c718718566ab60f2b/href</a></iframe><ul><li>Drop ‘weekday’, ‘wday’, ‘month’, ‘year’ from the calendar</li><li>merge data with calendar and sell_price</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4804f807c424de2b3373fddd8ebf2b58/href">https://medium.com/media/4804f807c424de2b3373fddd8ebf2b58/href</a></iframe><p>If everything goes well, we’ll get 60034810 rows in our final file.</p><h3>Feature Engineering</h3><p>1. For ‘event_name_1’, ‘event_type_1’, ‘event_name_2’ and ‘event_type_2’ will check null values and fill no_event and then label encode<br>2. For state_id, store_id, cat_id, dept_id, item_id will direclty label encode</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6e5c9665bdbbab90b5d9ed750091033/href">https://medium.com/media/b6e5c9665bdbbab90b5d9ed750091033/href</a></iframe><p>3. Change date columns type in data frame</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed4224ed2a496bede96a7c731995df3d/href">https://medium.com/media/ed4224ed2a496bede96a7c731995df3d/href</a></iframe><p>4. <strong>Lag Feature: </strong>3 days shift from 28 days to 30 days.</p><ul><li>Here we will create 3 new features lag_28, lag_29, and lag_30 which will be a shift by days 28, 29, and 30 respectively.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/161fea1af48b119dc1903e9d6e6ffb8f/href">https://medium.com/media/161fea1af48b119dc1903e9d6e6ffb8f/href</a></iframe><p>5.<strong>Rolling: </strong>taking a group of n (here 7 days) and take the avg of it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83f6c0844a0e7858268a8712702408db/href">https://medium.com/media/83f6c0844a0e7858268a8712702408db/href</a></iframe><p>6. Filling all the nan values created by rolling and lag features</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c540645dfb6a827d671c457102b169bf/href">https://medium.com/media/c540645dfb6a827d671c457102b169bf/href</a></iframe><p>7. Split Data</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afd75bc692fb515cd0da83e4fae44834/href">https://medium.com/media/afd75bc692fb515cd0da83e4fae44834/href</a></iframe><h3>Models</h3><ol><li><strong>XGBoost : </strong>XGBoost stands for “Extreme Gradient Boosting”. It is an efficient implementation of gradient boosting that can be used for regression predictive modeling.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43f3fd4ac0f6e0681cc36697c51d640d/href">https://medium.com/media/43f3fd4ac0f6e0681cc36697c51d640d/href</a></iframe><p>→ Our val rmse score is 13.258448600769043</p><p>2.<strong> XGboost with no extra features</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2cca06f2f3be006232368015e6bde60/href">https://medium.com/media/f2cca06f2f3be006232368015e6bde60/href</a></iframe><p>→ Our val rmse score is 13.223123550415039</p><p>3. <strong>LightGBM : </strong>Light GBM is tree based gradient boosting algorithm. It grows tree vertically. It is prefixed as ‘Light’ because of its high speed. It can handle the large size of data , null values and takes lower memory to run.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08d218f841c5fef7b0873d17dadbe34f/href">https://medium.com/media/08d218f841c5fef7b0873d17dadbe34f/href</a></iframe><p>→ our rmse score is 5.179855518187406</p><p>4. <strong>Stacking: </strong>Stacking is an ensemble learning technique to combine multiple classification models via a meta-classifier. The individual classification models are trained based on the complete training set; then, the meta-classifier is fitted based on the outputs — meta-features — of the individual classification models in the ensemble.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1500fe7ef4269dd5385d0f206c450353/href">https://medium.com/media/1500fe7ef4269dd5385d0f206c450353/href</a></iframe><p>→our rmse score is 5.836832340786545</p><p>5. <strong>Adaboost:</strong> AdaBoost is also a meta-algorithm, It helps helps us combine multiple “weak classifiers” into a single “strong classifier”.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0043fd720d6c68fb15bf79f167e638f/href">https://medium.com/media/d0043fd720d6c68fb15bf79f167e638f/href</a></iframe><p>→ rmse score is 8.115268548276887</p><h3>Comparison of models</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fdaf3c77c3cd33e6597fb1aeeed2693/href">https://medium.com/media/0fdaf3c77c3cd33e6597fb1aeeed2693/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*bc_Gs2eAt1d0R5vF81akuw.png" /></figure><h3>Future Work</h3><ol><li>Adding more features can lead to a good result.</li><li>Deep learning methods like LSTM or FB prophet.</li></ol><h3>References</h3><ul><li><a href="https://www.kaggle.com/anshuls235/time-series-forecasting-eda-fe-modelling/notebook">https://www.kaggle.com/anshuls235/time-series-forecasting-eda-fe-modelling/notebook</a></li><li><a href="https://www.kaggle.com/c/m5-forecasting-accuracy/discussion/143070">https://www.kaggle.com/c/m5-forecasting-accuracy/discussion/143070</a></li><li><a href="https://www.kaggle.com/c/m5-forecasting-accuracy/discussion/133468">https://www.kaggle.com/c/m5-forecasting-accuracy/discussion/133468</a></li><li><a href="https://www.kaggle.com/c/m5-forecasting-accuracy/discussion/133834">https://www.kaggle.com/c/m5-forecasting-accuracy/discussion/133834</a></li><li><a href="https://lightgbm.readthedocs.io/en/latest/index.html">https://lightgbm.readthedocs.io/en/latest/index.html</a></li><li><a href="https://otexts.com/fpp2/intro.html">https://otexts.com/fpp2/intro.html</a></li><li><a href="http://rasbt.github.io/mlxtend/user_guide/classifier/StackingClassifier/">http://rasbt.github.io/mlxtend/user_guide/classifier/StackingClassifier/</a></li><li><a href="https://towardsdatascience.com/what-makes-lightgbm-lightning-fast-a27cf0d9785e">https://towardsdatascience.com/what-makes-lightgbm-lightning-fast-a27cf0d9785e</a></li><li><a href="https://machinelearningmastery.com/xgboost-for-regression/">https://machinelearningmastery.com/xgboost-for-regression/</a></li><li>https://www.appliedaicourse.com/</li></ul><h4><strong>NoteBook link:</strong></h4><ul><li><a href="https://github.com/namratesh/M5-forecasting/">https://github.com/namratesh/M5-forecasting/</a></li></ul><p>Linkedin profile:</p><p><a href="http://www.linkedin.com/in/namratesh">www.linkedin.com/in/namratesh</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fbbb28e0e6f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/m5-forecasting-accuracy-9fbbb28e0e6f">M5 Forecasting — Accuracy</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hypothesis Testing]]></title>
            <link>https://medium.datadriveninvestor.com/hypothesis-testing-bbfa5819a8bf?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbfa5819a8bf</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[python3]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Tue, 26 Jan 2021 12:24:22 GMT</pubDate>
            <atom:updated>2021-01-26T14:45:23.212Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BK_DNNtWwLK8HtkW.jpg" /><figcaption><a href="https://luminousmen.com/post/demystifying-hypothesis-testing">https://luminousmen.com/post/demystifying-hypothesis-testing</a></figcaption></figure><p>Hypothesis Testing is a statistical way to test our experiment to see if we have a meaningful result or not.</p><p><strong>By </strong><a href="https://en.wikipedia.org/wiki/Statistical_hypothesis_testing"><strong>Wikipedia </strong></a><strong>:</strong></p><blockquote>“ statistical hypothesis is a hypothesis that is testable on the basis of observed data modeled as the realized values taken by a collection of random variables”</blockquote><h3>Table of Content</h3><ul><li>Hypothesis Testing Methodology</li><li>Steps to perform Hypothesis Testing</li><li>Case Study 1: <strong>Is there any difference in height of classroom 1 and classroom 2 students?</strong></li><li>Case Study 2 : <strong><em>A company manufacturing RAM chips claims the defective rate of the population is 5%. Let p denote the true defective probability.</em></strong></li><li>Properties of hypothesis testing</li></ul><h3>Hypothesis Testing Methodology</h3><p>Before going into details of Hypothesis testing let’s define some important terms</p><blockquote>H0 = Null Hypothesis</blockquote><blockquote>H1 = Alternative Hypothesis</blockquote><blockquote>P-value = <strong>p value</strong> is the evidence against a null hypothesis. The smaller the <strong>p</strong>-<strong>value</strong>, the stronger the evidence that you should reject the null hypothesis.</blockquote><h3>Steps to perform Hypothesis Testing:</h3><ol><li>Choose Null Hypothesis</li><li>Choose Alternative Hypothesis</li><li>Choose the p-value</li><li>Define your result by accepting or discarding the hypothesis.</li></ol><p>In simple word, hypothesis Testing can be understood as :</p><blockquote>“We choose a result that everybody would expect(<strong>Null Hypothesis</strong>). But we actually performed the experiment and it is very unlikely that Null Hypothesis is True.Then<em> </em>We tried with a different model and found out our Null hypothesis is not True, So we are rejecting our Null Hypothesis and accepting Alternative hypothesis”</blockquote><p>In Hypothesis testing, we want that <strong>H1 is likely True.</strong></p><p>So there are <em>two possible outcomes</em>:</p><ul><li><em>Reject H0 and accept H1 because of sufficient evidence in the sample in favor or H1</em></li><li><em>Do not reject H0 because of insufficient evidence to support H1.</em></li></ul><h3><strong>Case Study 1:</strong></h3><blockquote>Q. <strong>Is there any difference in height of classroom 1 and classroom 2 students?</strong></blockquote><p>Let’s take sample data of 10 students of each class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/0*mLrM9kINg-tBJPJg" /></figure><p><strong>Choose a test statistic.</strong></p><p><strong>X = µ2 — µ1</strong></p><p><strong>where </strong>µ1: mean height of classroom 1, and µ2: mean height of classroom 2,</p><p>Let’s plot the distribution of heights of students in classroom 1</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5c07b0c4c8d3beb4b8ec8c372049c3f/href">https://medium.com/media/a5c07b0c4c8d3beb4b8ec8c372049c3f/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/0*iSECU5XH03TEQwO7" /><figcaption>heights of students in classroom 1</figcaption></figure><p>Let’s plot the distribution of heights of students in classroom 2</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbe09685738eac203afa1fd82f1bcf75/href">https://medium.com/media/dbe09685738eac203afa1fd82f1bcf75/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/0*UIYUBfgbP_MrCdyB" /><figcaption>heights of students in classroom 2</figcaption></figure><p><strong>Hypothesis Testing Steps:</strong></p><ol><li><strong>Define Null Hypothesis</strong></li></ol><blockquote>H0 : no difference in µ1 and µ2</blockquote><p>2. <strong>Define Alternative Hypothesis</strong></p><blockquote>H1 : Difference in µ1 and µ2</blockquote><p>3.<strong> Calculate P-value</strong>: Probability of observing (µ2-µ1) if the <em>null hypothesis</em> is true.</p><p>Let’s say our</p><blockquote>P-value is 0.9 then the probability of (µ2-µ1) is 0.9 if H0 is True.</blockquote><blockquote>P-value is 0.05 then the probability of (µ2-µ1) is 0.05 if H0 is True.</blockquote><p>4. <strong>Define your result by accepting or discarding the hypothesis.</strong></p><p>Calculate µ1 = mean height of class 1 students = 167.2</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90344265f3bb0b5dd67c2d72d501cc71/href">https://medium.com/media/90344265f3bb0b5dd67c2d72d501cc71/href</a></iframe><p>µ2 = mean height of class 2 students = 134.6</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11acb796a6e0b98e209baae30f6bfd23/href">https://medium.com/media/11acb796a6e0b98e209baae30f6bfd23/href</a></iframe><p>Now, as per our analysis, it is found that there is a significant difference between µ1 and µ2. So we can discard our null Hypothesis and <strong>accept alternative Hypothesis H1.</strong></p><h3>Case Study 2</h3><blockquote><strong><em>A company manufacturing RAM chips claims the defective rate of the population is 5%. Let p denote the true defective probability.</em></strong></blockquote><p>We want to test if:</p><p>• H0 : p = 0.05</p><p>• H1 : p &gt; 0.05</p><p><strong>Solution :</strong></p><p>Let’s take a sample of 100 chips.</p><p>X → no of defective in the sample of 100</p><ol><li>Reject H0 if <strong>X &gt;= 10</strong> in the sample of 100. The image below shows that if X has a value greater than 10 then our p &gt; 0.05 and You reject H0 and accept H1.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c0tGU2aMSkH9XTX4" /></figure><p>You might be wondering <strong>Why we choose 10 as a critical value</strong>. So, the Critical value is chosen from the <strong>Bernoulli process.</strong></p><p>The defect in sample is <strong><em>n*p = 100*0.05 = 5, </em></strong>Therefore, 10 defectives would be strong evidence that p &gt; 0.05.</p><p>As It is a decision based on a finite sample, there is a very high chance of making a mistake.</p><p>Possible outcomes are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/0*P9y0oRpxy1jqpZgW" /><figcaption><a href="https://sphweb.bumc.bu.edu/otlt/MPH-Modules/BS/SAS/SAS4-OneSampleTtest/SAS4-OneSampleTtest3.html">https://sphweb.bumc.bu.edu/otlt/MPH-Modules/BS/SAS/SAS4-OneSampleTtest/SAS4-OneSampleTtest3.html</a></figcaption></figure><h4><strong>Type 1 Error</strong></h4><p>It is <strong>Acceptance of H1 when H0 is True. </strong>It is also known as the level of significance denoted by <strong>α</strong> (alpha)</p><h4><strong>Type 2 Error :</strong></h4><p>It is a <strong>Failure to reject H0 when H1 is True. </strong>The probability of committing a type 2 error is denoted by<strong> β.</strong></p><p><strong>Note: </strong>It is impossible to compute β unless we have a specific alternate hypothesis.</p><ol><li><strong>Calculation on Alpha α:</strong></li></ol><ul><li>The lower alpha is the less likely we are to commit a type 1 error.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VLZNfx0rQjcYnAu3" /></figure><p><strong>Calculation of β</strong></p><p>We cannot compute β for H1 : p &gt; 0.05 because the true p is unknown.</p><p>However, we can compute it for testing</p><p>H0 : p = 0.05 against the alternative hypothesis that</p><p>H1 : p = 0.1, for instance.</p><p><strong><em>Let’s calculate β</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lJLu0cHjTghrrS-B" /></figure><p>As per alpha = 0.282, so we can reject the H0 as it is not equal to 0.05 and accept H1.</p><h3><strong>Properties of hypothesis testing</strong></h3><p>1. α and β are related; decreasing one generally increases the other.</p><p>2. α can be set to the desired value by adjusting the critical value. Typically, α is set at 0.05 or 0.01.</p><p>3. Increasing n(sample size) decreases both α and β.</p><p>4. β decreases as the distance between the true value and hypothesized value (H1) increases.</p><h3><strong>Refernces:</strong></h3><ul><li><a href="https://stats.stackexchange.com/questions/123287/how-to-choose-the-null-and-alternative-hypothesis">https://stats.stackexchange.com/questions/123287/how-to-choose-the-null-and-alternative-hypothesis</a></li><li><a href="https://www.statisticshowto.com/probability-and-statistics/hypothesis-testing/">https://www.statisticshowto.com/probability-and-statistics/hypothesis-testing/</a></li><li><a href="http://media.news.health.ufl.edu/misc/bolt/Intro/PHC6050-6052/Unit4/0408-Unit4A-Hypothesis-Testing-Steps.pdf">http://media.news.health.ufl.edu/misc/bolt/Intro/PHC6050-6052/Unit4/0408-Unit4A-Hypothesis-Testing-Steps.pdf</a></li><li><a href="http://www.sci.utah.edu/~arpaiva/classes/UT_ece3530/hypothesis_testing.pdf">http://www.sci.utah.edu/~arpaiva/classes/UT_ece3530/hypothesis_testing.pdf</a></li><li><a href="https://www.wallstreetmojo.com/hypothesis-testing/">https://www.wallstreetmojo.com/hypothesis-testing/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbfa5819a8bf" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/hypothesis-testing-bbfa5819a8bf">Hypothesis Testing</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to run Jupyter Notebook on Andriod?]]></title>
            <link>https://medium.com/analytics-vidhya/how-to-run-jupyter-notebook-on-andriod-dfc5bccca7ca?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfc5bccca7ca</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[andriod]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Mon, 28 Dec 2020 13:15:42 GMT</pubDate>
            <atom:updated>2020-12-30T04:35:21.564Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to run Jupyter Notebook on Android?</h3><p>Recently, I was searching for Jupyter Notebook to run my Android mobile. But there was no straight way to install it. So I thought let’s write about it.</p><p>We will divide it into two parts, the first will be application installation, and the second will be the Android Setup.</p><h3>1. Installation</h3><p>There are two things you need to install from the google play store to get started.</p><p>1 . Install <a href="https://play.google.com/store/apps/details?id=ru.iiec.pydroid3&amp;hl=en_IN&amp;gl=US"><strong><em>Pydroid 3 — IDE for Python 3 </em></strong></a>from google play store</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*ikIQMz4Zj3J7bjFcnSgvLA.png" /></figure><p>2. Install <a href="http://Pydroid repository plugin"><strong><em>Pydroid repository plugin</em></strong></a><strong><em> </em></strong>from google play store</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*xgvJfstmQTmEvforlszLJQ.png" /></figure><p>After installing the above 2 applications we are good to install jupyter Notebook.</p><h3>2. Android Setup</h3><p>Open <a href="https://play.google.com/store/apps/details?id=ru.iiec.pydroid3&amp;hl=en_IN&amp;gl=US"><strong><em>Pydroid 3 — IDE for Python 3</em></strong></a></p><ul><li>click on<strong> pip </strong>icon</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*o-8Lk2pdVrsnFkAauUOT9A.png" /></figure><ul><li>search for<strong> jupyter -notebook </strong>and install it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*8hsN52VM83qjLcJ0iazHEQ.png" /></figure><ul><li>Click on the <strong>terminal </strong>icon</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*o-8Lk2pdVrsnFkAauUOT9A.png" /></figure><ul><li>type jupyter-notebook in terminal</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*Kiv2WTfgf0KMfgRT2UI43A.png" /></figure><ul><li>A new page will be launched as a local host</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*w6uqG28sNGXnoXjdNTAzGg.png" /></figure><ul><li>create a new python file and your jupyter notebook is ready.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*2zknzTbbuSBoxGmISKw2sA.png" /></figure><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfc5bccca7ca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/how-to-run-jupyter-notebook-on-andriod-dfc5bccca7ca">How to run Jupyter Notebook on Andriod?</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Automation using Selenium with Python]]></title>
            <link>https://namratesh.medium.com/web-automation-using-selenium-with-python-c02081a1e740?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/c02081a1e740</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[web-automation]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[selenium]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Sun, 26 Apr 2020 19:00:12 GMT</pubDate>
            <atom:updated>2020-04-26T19:00:12.796Z</atom:updated>
            <content:encoded><![CDATA[<p>Automatic any activity on a web browser called <strong><em>Web Automation. </em>Selenium </strong>is one of the most practiced open-source frameworks for automation.</p><p>I have divided this blog into two parts. The <em>first section</em> will cover the introduction of selenium &amp; installation of selenium in python and the <em>second part</em> will cover automation using python.</p><h4>What is Selenium?</h4><p>Selenium is a portable framework for testing web applications. It provides a single interface that lets you write test scripts in programming languages like <strong><em>Ruby, Java, NodeJS, PHP, Perl, Python, and C#</em></strong>, among others. Selenium is composed of several components with each taking on a specific role in aiding the development of web application test automation.</p><ul><li><strong>Selenium IDE:</strong> Selenium IDE is a complete integrated development environment (IDE) for Selenium tests. It is implemented as a Firefox Add-On and as a Chrome Extension. <em>It allows for recording, editing, and debugging of functional tests</em>. It was previously known as Selenium Recorder. It is used to create quick bug reproduction scripts, create scripts to aid in automation-aided exploratory testing.</li><li><strong>Selenium client API: </strong>As an alternative to writing tests in Selenese(set of selenium commands which are used to test your web application), tests can also be written in various programming languages. These tests then communicate with Selenium by calling methods in the Selenium Client API. Selenium currently provides client APIs for Java, C#, Ruby, JavaScript, R, and Python.</li><li><strong>Selenium Remote Control(RC): </strong>Selenium Remote Control (RC) is a server, written in Java, that accepts commands for the browser via HTTP. RC makes it possible to write automated tests for a web application in any programming language, which allows for better integration of Selenium in existing unit test frameworks.</li><li><strong>Selenium WebDriver: </strong>Selenium WebDriver is the successor to Selenium RC. Selenium WebDriver accepts commands (sent in Selenese, or via a Client API) and sends them to a browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*tRTnLagnu8Hyflo-.png" /><figcaption><a href="https://www.javatpoint.com/selenium-webdriver">https://www.javatpoint.com/selenium-webdriver</a></figcaption></figure><ul><li><strong>Selenium Grid: </strong>Selenium Grid is a server that allows us to run test cases in different machines. We run our test cases in a local machine and it runs on a virtual machine(or a hub).</li></ul><ol><li>A Hub is a central point or a local machine that receives all the test requests and distributes them to the right nodes. The machine which actually triggers the test case known as Hub</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*ki4xptCDilqj-9Ef.png" /><figcaption><a href="https://www.javatpoint.com/selenium-grid">https://www.javatpoint.com/selenium-grid</a></figcaption></figure><h4>Installation Guide:</h4><ol><li>you have to run below command to install selenium</li></ol><pre><strong>pip install selenium</strong></pre><p><strong>2. </strong>Now depends on your browser you have to download web driver. I have given the link below for web browsers. <strong>Chrome</strong>:<a href="https://sites.google.com/a/chromium.org/chromedriver/downloads">https://sites.google.com/a/chromium.org/chromedriver/downloads</a>, <strong>Firefox</strong>:<a href="https://github.com/mozilla/geckodriver/releases">https://github.com/mozilla/geckodriver/releases</a>, <strong>Safari</strong>:<a href="https://webkit.org/blog/6900/webdriver-support-in-safari-10/">https://webkit.org/blog/6900/webdriver-support-in-safari-10/</a></p><p><strong>Getting Started and Checking Installation</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c22095ffd22d31f6036a2d9b47ca62b/href">https://medium.com/media/0c22095ffd22d31f6036a2d9b47ca62b/href</a></iframe><p><strong>Explanation:</strong></p><p><em>lines1– 4: import libraries</em></p><p><em>line 7: initialise chrome driver</em></p><p><em>line10: open python official website</em></p><p><em>line 11: validate web tittle to “Python”</em></p><p><em>lines 13–16: finding element by name “q”(search bar), clear it&#39;s value and type “Pycon” and send Enter Key.</em></p><p><em>line 18 close the driver</em></p><p><strong>suggestions are welcome!!!</strong></p><h4><strong>References:</strong></h4><p><a href="https://selenium-python.readthedocs.io/index.html">https://selenium-python.readthedocs.io/index.html</a></p><p><a href="https://www.javatpoint.com/selenium-ide">https://www.javatpoint.com/selenium-ide</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c02081a1e740" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image Classification using Tensorflow2.0 with CIFAR-10 dataset]]></title>
            <link>https://medium.com/analytics-vidhya/image-classification-using-tensorflow2-0-with-cifar-10-dataset-cc595ceb0082?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc595ceb0082</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[dataset]]></category>
            <category><![CDATA[cifar-10]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Sun, 19 Apr 2020 13:56:00 GMT</pubDate>
            <atom:updated>2020-04-19T17:51:12.558Z</atom:updated>
            <content:encoded><![CDATA[<h3>Image Classification using Tensorflow2.0 on CIFAR-10 dataset</h3><p>It is my second blog on TensorFlow 2.0 and I’ll explain image classification on the <a href="https://www.cs.toronto.edu/~kriz/cifar.html">CIFAR-10 dataset</a>. CIFAR stands for Canadian Institute For Advanced Research and 10 refers to 10 classes. It consists of 60000 32x32 color images in 10 classes, with 6000 images per class. There are 50000 training images and 10000 test images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*b1VJotYHfyt5XuM5hyAc4w.png" /></figure><p>Let’s start with importing libraries and dataset</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3575ce69cac85aaffb2cd2750b8d7494/href">https://medium.com/media/3575ce69cac85aaffb2cd2750b8d7494/href</a></iframe><ul><li>lines, 2–5, imported <em>Tensorflow, Keras, Numpy and Matplotlib</em></li><li>line 8, load the data CIFAR10 in cifar variable</li><li>line 9, store the data in two sets as the dataset is loaded in two sets by calling <em>cifar.load_data()</em></li><li>line 10, checked the shape of data and it has 50000 images with 32*32 pixel and 3 is a representation of the color.</li><li>line 17, defined a class name for each classes in a label</li></ul><p>Now, We’ll plot Images and rescale it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/158153c642174bf9b671aec59b96f284/href">https://medium.com/media/158153c642174bf9b671aec59b96f284/href</a></iframe><ul><li>lines 2–4, plot an image with color bar and it is showing 0–255 colorbar</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*iKSsqOUnquO-tMwvGGbw4A.png" /></figure><ul><li>lines 7 &amp; 8, rescaling image because TensorFlow only takes input between 0–1</li><li>line12–14 again plot image with color bar and now it is showing between 0–1</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*ZYb38vUEHXWrX4yEZVwBbA.png" /></figure><p>Now we will import libraries to build a model</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/611b025113735656149f1a9cb520ae4e/href">https://medium.com/media/611b025113735656149f1a9cb520ae4e/href</a></iframe><ul><li>lines 2–5, import libraries <em>Sequential, Flatten, Dense, BatchNormalization, Maxpooling, Activation, and Conv2D</em></li><li>line 8, define a model as <strong><em>Sequential. </em></strong>It is a linear stack of layers and we can create our model by passing a list of layer instances to the constructor or just by adding layers.</li><li>line 9 &amp; 12, define a <strong><em>Conv2D</em></strong><em> </em>layer. A convolution layer is used to extract features from the image or part of an image. It creates a convolution kernel that is involved with layer input to produce a tensor of outputs. We have passed three parameters.</li></ul><ol><li><strong>filter size</strong>(64 and 32)- It is an integer value that determines the number of output filter</li><li><strong>kernel_size</strong>(3,3)- It is the size of the filter that is run over the images. It is given as tuple of two numbers indicating the height and width</li><li><strong>activation</strong>(relu)- It is the Regularizer function that controls the type and amount of regularization method applied to the conv2d</li></ol><ul><li>line 10, Defines <strong><em>MaxPooling2D</em></strong> layer. This layer reduces the size of the data, number of parameters, the amount of computation needed. In a simple word, we can say it is similar to scaling down the size of an image.</li><li>lines 11 &amp; line 14, define a <strong><em>BatchNormalization </em></strong>layer. This layer standardized input to a layer for each mini-batch.</li><li>line 14, defined a <strong><em>Flatten</em></strong> layer. This layer converts the n-dimension array to 1dimension array.</li><li>lines 15 &amp; 16, defined a <strong><em>Dense </em></strong>layer. It is just a regular layer of neurons in a neural network that is densely connected. Each neuron receives input from all the neurons.</li></ul><blockquote><em>we need to compile our model before training because training uses the loss function optimizer.</em></blockquote><ul><li>line20, <strong><em>model.compile</em></strong><em> </em>is used to compile a model. It defines a loss function, optimizer, and metrics.</li></ul><ol><li><strong><em>Loss Function- </em></strong>It is a method of evaluating how well specific models the given data. Here we used <strong>‘<em>Sparse categorical cross-entropy’. </em></strong>Categorical cross-entropy is a loss function for categorical data and Sparse means it does use all possible classes but some of them.</li><li><strong><em>Optimizer-</em></strong> It is used to change the attributes of a neural network such as weights and learning rate. Here we used <strong><em>‘Adam’ </em></strong>optimizer. It stands for <strong><em>Adaptive Moment Estimation. </em></strong>It helps to get results faster.</li><li><strong><em>Metrics- </em></strong>It is used to evaluate machine learning algorithms. Here we used ‘<strong><em>Accuracy’. </em></strong>It is the ratio of the<em> number of correct predictions to the total number of input samples.</em></li></ol><ul><li>line 24, <strong>model.fit</strong><em> </em>is<em> </em>used to train our model. It takes train and test data to fit our model.</li></ul><ol><li><strong><em>Verbose</em></strong><em>- It has 3 parameters to pass 0,1, and 2. </em><strong>verbose = 1</strong>, which includes both progress bar and one line per epoch, <strong>verbose = 0</strong>, means silent, <strong>verbose = 2</strong>, one line per epoch i.e. epoch no./total no. of epochs</li><li><strong><em>Epochs</em></strong>- one epoch is when an entire dataset is passed forward and backward through the neural network only once.</li></ol><p>Now we will plot loss, validation loss and accuracy</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c6fc94627bc323fa59239794f63d339/href">https://medium.com/media/9c6fc94627bc323fa59239794f63d339/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*3WimMhxRFRlHqp9j8qj5ng.png" /><figcaption>graph</figcaption></figure><p>In the above image, the blue line represents training loss, orange validation loss, and green accuracy.</p><p>There are four points to be noted while seeing the graph between <strong>validation loss and training loss</strong></p><ol><li>validation loss should be similar to but slightly higher than training loss.</li><li>If training loss is much greater than validation loss then it’s <em>overfitting</em></li><li>If training loss is much less than validation loss then it’s <em>underfitting</em>.</li></ol><p>There are 3 points to be noted while seeing the graph between <strong>validation loss and validation accuracy</strong></p><ol><li>if val_loss is increasing while val_acc is decreasing then our model is not learning.</li><li>if val_loss and val_acc both are increasing the model is overfit.</li><li>if val_loss is decreasing while val_acc is increasing then the model is fine</li></ol><p>So here we can say our model is underfitting. Now, In my next blog, we’ll see how can we deal with overfitting.</p><p>All code at once.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ac0ecc355d8220045e1b50aa4785db1/href">https://medium.com/media/4ac0ecc355d8220045e1b50aa4785db1/href</a></iframe><p><em>The notebook can be found </em><a href="https://github.com/namratesh/Machine-Learning/blob/master/3.Cifar-10%20tensorflow2.0.ipynb"><em>here</em></a><em>.</em></p><p><strong>References:</strong></p><ul><li><a href="https://peltarion.com/knowledge-center/documentation/modeling-view/build-an-ai-model/blocks/2d-max-pooling-block">2D Max pooling block | Peltarion Platform</a></li><li><a href="https://keras.io/layers/convolutional/">Convolutional Layers — Keras Documentation</a></li><li><a href="https://missinglink.ai/guides/tensorflow/tensorflow-conv2d-layers-practical-guide/">TensorFlow Conv2D Layers: A Practical Guide — MissingLink.ai</a></li><li><a href="https://stats.stackexchange.com/questions/326065/cross-entropy-vs-sparse-cross-entropy-when-to-use-one-over-the-other">machine learning — Cross Entropy vs. Sparse Cross Entropy: When to use one over the other — Cross Validated</a></li><li><a href="https://forums.fast.ai/t/determining-when-you-are-overfitting-underfitting-or-just-right/7732/4">https://forums.fast.ai/t/determining-when-you-are-overfitting-underfitting-or-just-right/7732/4</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc595ceb0082" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/image-classification-using-tensorflow2-0-with-cifar-10-dataset-cc595ceb0082">Image Classification using Tensorflow2.0 with CIFAR-10 dataset</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Tensorflow 2.0 with Fashion Mnist Dataset]]></title>
            <link>https://medium.datadriveninvestor.com/introduction-to-tensorflow-2-0-with-fashion-mnist-dataset-2f243423c563?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f243423c563</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[introduction]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 09:21:16 GMT</pubDate>
            <atom:updated>2020-04-17T10:07:01.407Z</atom:updated>
            <content:encoded><![CDATA[<p>Tensorflow 2.0 final release was announced on September 30, 2019. It is Google’s open-source AI framework for machine learning and high-performance numerical computation. It supports many classification and regression algorithms and more generally, deep learning and neural networks.</p><p><strong>What’s new in Tensorflow2.0</strong></p><ul><li>Powerful experimentation</li><li>Robust model Deployment in production</li><li>No need to create a session</li><li>Low-level API supports</li><li>3 times faster training performance</li></ul><figure><img alt="https://blog.tensorflow.org/2019/09/tensorflow-20-is-now-available.html" src="https://cdn-images-1.medium.com/max/1000/0*5UhxZmuarq_zafW9.png" /></figure><p><strong>Let’s Start with Fashion Mnist Dataset</strong></p><p>Fashion-MNIST is a dataset of Zalando’s article images consisting of a training set of 60,000 examples and a test set of 10,000 examples. Each example is a 28x28 grayscale image, associated with a label from 10 classes. It is split in 10,000 as test and 50,000 as train datasets.</p><p><strong><em>Load Important Libraries</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efa89d5abe74c46efbed7a15b24512ee/href">https://medium.com/media/efa89d5abe74c46efbed7a15b24512ee/href</a></iframe><ul><li>Now load our dataset</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb26464bbe91b987ae07f746dae8dda5/href">https://medium.com/media/fb26464bbe91b987ae07f746dae8dda5/href</a></iframe><p>Load dataset gives to <strong>set () () </strong>in which we have passed a value(X_train, y_train), (X_test, y_test)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbc64a9b30af4ded5f4b2af9dab17bf8/href">https://medium.com/media/fbc64a9b30af4ded5f4b2af9dab17bf8/href</a></iframe><p>line2 is used to check the shape output will be :((60000, 28, 28), (60000,))</p><p>line 6 is used to define a class name</p><p>and finally, line 10–12 is used to plot an image with color bar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*pMX4mrAu1vfpibGLTuNyBg.png" /></figure><p>This image belongs to a shirt class and it has value 0 to 255. But TensorFlow accepts value only 0 to 255 so we need to convert it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30cd7ed13b679ed9059471cb01b592d8/href">https://medium.com/media/30cd7ed13b679ed9059471cb01b592d8/href</a></iframe><p>line 2 &amp; 3 will change the value from 0–255 to 0–1</p><p>line 6–8 will plot the same image with color bar and it has changed to 0–1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*1aHRSbwOIv9zD_iUF7Qu1Q.png" /></figure><p>Now, Time to build our model</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63360e66de3f5ffe6b1ca8626fa03983/href">https://medium.com/media/63360e66de3f5ffe6b1ca8626fa03983/href</a></iframe><p>line 2 &amp; 3 used to import library</p><p><em>line 6- </em><strong><em>model = Sequential() </em></strong>we can pass an array in a sequential model or just add another layer</p><p><a href="https://www.datadriveninvestor.com/2019/01/23/deep-learning-explained-in-7-steps/">Deep Learning Explained in 7 Steps - Updated | Data Driven Investor</a></p><p>line 7- <strong><em>model.add(Flatten(input_shape = (28,28))) </em></strong>flatten is used to change input data in 1d</p><p>line 8 used to add dense layer and line 9 used as output layer</p><p>line 14 <strong>model.compile() </strong>is used to compile the model and line 18 <strong>model.fit() </strong>to fit the model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4375d42e91a978364612a0ff4e8fe6ac/href">https://medium.com/media/4375d42e91a978364612a0ff4e8fe6ac/href</a></iframe><p>lines 1 -3 is used to check test_loss using <strong>model.evaluate(X_test, y_test)</strong></p><p>lines 8–9 is to check the accuracy and that is giving 87%</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c15a84be7d35eb9e35fa958ad03acb0/href">https://medium.com/media/8c15a84be7d35eb9e35fa958ad03acb0/href</a></iframe><p>now, we plot again with our prediction</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*5_8TzFsTsw1mTbNTihHZ5A.png" /></figure><p>All code at once-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/beefacd152e8107d3b7d5e04056cc1e3/href">https://medium.com/media/beefacd152e8107d3b7d5e04056cc1e3/href</a></iframe><p>Thanks for reading.</p><p><a href="https://github.com/namratesh/Machine-Learning/blob/master/1.Intorduction%20to%20Tensorflow2.0.ipynb"><strong>notebook</strong></a></p><p>References:</p><ul><li><a href="https://www.tensorflow.org/datasets/catalog/fashion_mnist">https://www.tensorflow.org/datasets/catalog/fashion_mnist</a></li><li><a href="https://www.tensorflow.org/tutorials/quickstart/beginner">https://www.tensorflow.org/tutorials/quickstart/beginner</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb2a0d6%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb2a0d6%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href">https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f243423c563" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/introduction-to-tensorflow-2-0-with-fashion-mnist-dataset-2f243423c563">Introduction to Tensorflow 2.0 with Fashion Mnist Dataset</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Personalized Cancer Diagnosis]]></title>
            <link>https://medium.datadriveninvestor.com/personalized-cancer-diagnosis-aea93bad0587?source=rss-e14e32836c01------2</link>
            <guid isPermaLink="false">https://medium.com/p/aea93bad0587</guid>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[sklearn]]></category>
            <category><![CDATA[case-study]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Namratesh Shrivastav]]></dc:creator>
            <pubDate>Sun, 26 Jan 2020 14:59:47 GMT</pubDate>
            <atom:updated>2020-01-27T04:32:28.565Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><a href="https://www.kaggle.com/c/msk-redefining-cancer-treatment/data"><strong><em>Personalized Medicine: Redefining Cancer Treatment</em></strong></a></blockquote><p>Machine Learning is tough and you can only get confidence by doing hands-on it. In this blog, I am using <a href="https://www.kaggle.com/c/msk-redefining-cancer-treatment/data"><strong><em>Personalized Medicine: Redefining Cancer Treatment</em></strong></a><em> dataset </em>from Kaggle to give some glimpse of Machine Learning. It was a competition organized in 2017 by NIPS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nW9vpWgPsvuoyZ5C.jpg" /><figcaption><a href="https://www.kaggle.com/c/msk-redefining-cancer-treatment/overview">https://www.kaggle.com/c/msk-redefining-cancer-treatment/overview</a></figcaption></figure><p><strong>Overview of Dataset: </strong>Dataset has 9 different classes that we have to predict. Both training and test, datasets are provided into two different files. One (training/test_variants) provides information about the genetic mutation, whereas other (training/test_text) provides the clinical evidence(text) that human experts used to classify the genetic mutations.</p><p><strong>File Descriptions:</strong></p><ul><li><strong>training_variants</strong>- a comma-separated file containing the description of the genetic mutations used for training. It has four filed: <strong>1. ID</strong>( used to link the mutation to the clinical evidence), <strong>2. Variation</strong>(amino acid change for these mutations), <strong>3. Gene (</strong>gene where genetic mutations are located, <strong>4.Class</strong>(1–9 class this genetic mutation has been classified on)</li><li><strong>training_text- </strong>a double pipe(||) delimited file that contains the clinical evidence(text) used to classify genetic mutations. <strong>1. ID (</strong>used to link the clinical evidence to the genetic mutation),<strong> 2. Text </strong>(used to classify the genetic mutation)</li><li><strong>test_variants- </strong>a comma-separated file containing the description of the genetic mutations used for training. It has three fields: <strong>1. ID</strong>( used to link the mutation to the clinical evidence), <strong>2. Variation</strong>(amino acid change for these mutations), <strong>3. Gene (</strong>gene where genetic mutations are located.</li><li><strong>test_text- </strong>a double pipe(||) delimited file that contains the clinical evidence(text) used to classify genetic mutations. <strong>1. ID (</strong>used to link the clinical evidence to the genetic mutation),<strong> 2. Text </strong>(used to classify the genetic mutation).</li></ul><p><strong>Evaluation- </strong>Submissions are evaluated on <strong><em>Multi-Class Log Loss</em></strong> between the predicted probability and the observed target.</p><p><strong>Importing libraries</strong></p><ul><li>You can find a <a href="https://github.com/namratesh/Machine-Learning/blob/master/Personalized%20cancer%20diagnosis-Copy1.ipynb"><strong>notebook here</strong></a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ISbh0MJEN7q_TrEkHSjajQ.png" /></figure><p><strong>Reading file</strong></p><ul><li>pd.read_csv is used to read file</li><li>sep is used to give the separated file</li><li>skiprows is used skip row</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*njCA5k_Bt4cadOuruXqk0A.png" /></figure><ul><li>top 5 values in training text</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*hqCMg1kre0eM0pMrqIJ-6g.png" /></figure><ul><li>top 5 values in training_variants</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*4B3x4Mv-DEs7LVEAO3CgTA.png" /></figure><ul><li>How many data points and what are in training_text?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*nQ--4cd2kKQ_rNONjVik4w.png" /></figure><ul><li>How many data points and what are in trainnig_variants?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*fCvGk9Ohw9mhS6P7-Rj2vQ.png" /></figure><ul><li>defining function for <strong>Text processing </strong>of text data</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*4WcGTe60f4IBURZNtFAqsw.png" /></figure><p><strong><em>re.sub(&#39;[^a-zA-Z0-9\n]&#39;, &#39; &#39;, total_text)</em></strong><em> is used to replace specail character with space</em></p><p><strong>re.sub(‘\s+’, ‘ ‘, total_text) </strong>is used to replace multiple space with single space</p><p><strong>total_text.lower() </strong>will convert every letter in lower</p><h4><strong>Text processing</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*GrOIHlQ1IDVCsCwXHwodjg.png" /></figure><ul><li>time.clock() is used to start and end the clock to measure the total time taken to run the snippet</li><li>apply nlp_preprocessing function on TEXT field from training_text</li><li>Merging training_text and training_variants</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*zQi9p-_QR_OBmOHsn1FV6A.png" /></figure><ul><li>checking null values in dataset</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*7O4UjdKGJZvi_j1UjMbvzw.png" /></figure><p>* <em>we have missing values in TEXT data.</em></p><ul><li>No. of missing values in TEXT data</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*6eMXRPBtzsAbIG0h8SXjsA.png" /></figure><ul><li>values that are missing</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*3tDba_bIiE1mhtlZidyYuw.png" /></figure><ul><li>filling these missing values with Gene + variation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*hHOsENeY_OEm2otb4-RWCg.png" /></figure><ul><li>checking again missing values in TEXT feature</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*UU7z_lGmo1L6olBH-1RlTw.png" /></figure><ul><li>splitting dataset in train, test, and cross-validation by 80 as training and 20 as testing and the again 80% train data into 60:20 where 60 will be as training and 20 will be as cross-validation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*vD_gAGf2wh5qJJCGvob7qQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*ZZobdHZwVhu2dGmjlWLRFw.png" /></figure><ul><li>checking data points in train, test, and cross-validation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*bvTUkD9LNbsSQoEXrqjx-Q.png" /></figure><h3>Univariate Analysis</h3><p>In this part, we are going to do univariate analysis on GENE, TEXT, and VARIANTS</p><h4><strong>Univariate Analysis of GENE</strong></h4><ul><li>No of categories in GENE feature</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*XD3ZfUg3ABum9OOB8JbsQw.png" /></figure><p><em>There are 232 unique categories of genes.</em></p><ul><li>Distribution of unique genes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*KtmAhwPJdKA3ae2iy1Q6-w.png" /></figure><ul><li>Cumulative distribution of genes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*fRhVVPRygYDcsEjT3LLXdA.png" /></figure><ul><li>One hot encoding of Gene Feature</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*9_8WCITDBSSfuyhil7LQ7A.png" /></figure><ul><li>Shape of gene feature after converting by OnehotEncoding</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5o6PZol4951dyxp_Vz3BA.png" /></figure><h4>Univariate Analysis of Variation Feature</h4><ul><li>Unique feature in Variants</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*VsB3qs3yPFRCuGVRc4UhNA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*JPoV-Fa2qarX8kbzG7NUog.png" /></figure><ul><li>distribution of unique variants value</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*Uc9VRiyzO158BWXyz03A-A.png" /></figure><ul><li>cumulative distribution of variations</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*QqULw6_OD4Z-JQGipV2cGg.png" /></figure><ul><li>one-hot encoding of Variants</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5TWDNco4pYnu72KHXyd9pA.png" /></figure><h4>Univariant Analysis of Text Feature</h4><ul><li>making a dictionary of text how many times word occur</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*snV27YveowHrxFhlga4KWA.png" /></figure><ul><li>creating 9 different types of classes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*Q5KsRk-DTLqj9dQVaPowTQ.png" /></figure><ul><li>normalizing every feature</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*2MzhLTXqpGJE5VmENkWUTw.png" /></figure><ul><li>sorting dictionary</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*wg7Xi5LOmy-untcyegKFig.png" /></figure><h4>Machine Learning Models</h4><ul><li>Defining a function which will plot confusion matrix</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*Tpb2gDOEEvAkiRDsNxIBag.png" /></figure><ul><li>Defining a function which will give a report of log loss</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*aOz8-VbWfZEMh2npyHGBIg.png" /></figure><ul><li>Stacking of Gene, Text, and Variants Feature</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*cGbNeLZKzLhp4GFUrNVMWA.png" /></figure><ul><li>Implementing First model <strong>KNN</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4g5YbsGr9AYzLGZX8b9zjA.png" /></figure><ul><li>Checking output</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*akZ-58wcB83GLeFPeD6isQ.png" /></figure><p><em>Here we have the best value of alpha is 5 where the log loss is minimum</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W8EMJcfUK2LrKQD05VV8tw.png" /></figure><ul><li>confusion matrix of KNN algorithm</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HirgZwOmTTVOZti1eW9jCA.png" /></figure><ul><li>Precision matrix after KNN algorithm</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JsqAFx7noeCxiQTS1IsB7A.png" /></figure><ul><li>Recall matrix after KNN algorithm</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X5RBhMwzn3FRVZU0CR5pTg.png" /></figure><ul><li>checking model prediction</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*trSD9X0ol_kiZJNYE7BxwQ.png" /></figure><p><em>it’s predicted right. we give class 4 and it’s also predicted 4</em></p><ul><li><strong>Logistic Regression</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NhmcWXv71tjH6qb5aEKUQw.png" /></figure><ul><li>predicting best alpha</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_hWpAxs05_QXyYdVQZNpA.png" /></figure><p><em>at 0.001 alpha has the best value.</em></p><ul><li><strong>SVM</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dU7nJLJou91yQbrR8V8G-w.png" /></figure><p><em>Here, we only change log loss to hinge loss</em></p><ul><li>Checking best c</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*ZxmQNop5WvBJtFlZK0aGLQ.png" /></figure><ul><li>checking log less at best alpha</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I3u-Sy09IA3cLL9ExoBh1A.png" /></figure><ul><li>predicting a class using SVM</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bE247j54nt9UFguHxciaag.png" /></figure><ul><li>using <strong>Mlxetend algorithm on Logistic Regression, Support Vector Machine, and Navie Bayes</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MSBmyplPhlYAn_YQf8JY-g.png" /></figure><ul><li>the output of this snippet</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*uSkFxcCjm7X1f8XSkAcnXA.png" /></figure><ul><li>Using <strong>Stacking Classifier</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6BEyVNyV2qLDk45oEZPrPA.png" /></figure><ul><li>checking prediction</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*EezY8WqYJiPIUqN4zPQUew.png" /></figure><ul><li>confusion matrix of <strong>Stacking Classifier</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9T6s0Au5oE_o122L62hPag.png" /></figure><ul><li>Precision matrix of <strong>Stacking Classifier</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EH2VzsNP_xrZEek8h8HzWg.png" /></figure><ul><li>Recall matrix of <strong>Stacking Classifier</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RYSgTaaViLjw3tOnuDX--w.png" /></figure><p>You can find <a href="https://github.com/namratesh/Machine-Learning/blob/master/Personalized%20cancer%20diagnosis-Copy1.ipynb"><strong>notebook here</strong></a></p><p>Thanks for reading</p><h4>References:</h4><ul><li><a href="http://scikit-learn.org/stable/modules/sgd.html">http://scikit-learn.org/stable/modules/sgd.html</a></li><li><a href="http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html">http://scikitlearn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html</a></li><li><a href="http://scikit-learn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html">http://scikitlearn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html</a></li><li><a href="http://rasbt.github.io/mlxtend/">http://rasbt.github.io/mlxtend/</a></li><li><a href="http://rasbt.github.io/mlxtend/user_guide/classifier/StackingClassifier/">http://rasbt.github.io/mlxtend/user_guide/classifier/StackingClassifier/</a></li><li>appliedaicoures.com</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aea93bad0587" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/personalized-cancer-diagnosis-aea93bad0587">Personalized Cancer Diagnosis</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>