<?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 Naman Gupta on Medium]]></title>
        <description><![CDATA[Stories by Naman Gupta on Medium]]></description>
        <link>https://medium.com/@namangupta-cs?source=rss-6e0d1ae537c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wwqy72MB-fzfZ27lU3EPRQ.jpeg</url>
            <title>Stories by Naman Gupta on Medium</title>
            <link>https://medium.com/@namangupta-cs?source=rss-6e0d1ae537c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 06:59:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@namangupta-cs/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[Buy Me That Look]]></title>
            <link>https://medium.com/analytics-vidhya/buy-me-that-look-137c1e7030ec?source=rss-6e0d1ae537c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/137c1e7030ec</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[fashion]]></category>
            <dc:creator><![CDATA[Naman Gupta]]></dc:creator>
            <pubDate>Tue, 11 May 2021 15:54:45 GMT</pubDate>
            <atom:updated>2021-05-25T17:54:19.328Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*vv6yq_eSaIGkucIy-v3TIw.jpeg" /></figure><p>This blog is all about the Fashion Recommendation system. It is a unique recommendation system compared with others because here based on provided photo/picture, the system recommends similar clothes or articles worn by the model in the picture. The architecture and design components are inspired by a Paper: <a href="https://arxiv.org/pdf/2008.11638.pdf">Buy Me That Look: An Approach for Recommending Similar Fashion Products</a>.</p><h3>Agenda</h3><ol><li>Business problem</li><li>ML/DL formulation</li><li>Business Constraints</li><li>Data Acquisition and Analysis</li><li>Research section</li><li>My Approach</li><li>End Results</li><li>Future Work</li><li>References</li></ol><h3>1. Business Problem:</h3><p>The research paper states, in short, is to detect all products in an image and retrieves similar fashion clothes from the database with a product buy link.</p><p>Online business has become important in day-to-day life for everyone. Virtual stores allow people to shop from the comfort of their homes without the pressure of a salesperson. In this paper, the authors focus on the retrieval of multiple fashion items at once and propose an architecture that detects all products from an image and recommends similar kinds of products.</p><p>In stores, we can carry a piece of cloth and request the salesperson to show us similar kinds of products matching Color, design, thickness, etc; But online it is not possible and it is time-consuming while searching for similar kinds of products. So, here we can upload an image and search for similar kinds by using computer vision.</p><h3>2. ML/DL formulation</h3><p>Let’s discuss the architecture of the model in this session. Will divide this problem into various stages:</p><blockquote><strong><em>Stage 1: (Pose Estimation)</em></strong></blockquote><blockquote><em>In this stage, We will detect whether the image is a Full-Front-pose image or not. So this will be a binary classifier (Yes/No)</em></blockquote><blockquote><strong><em>Stage 2: (Localization)</em></strong></blockquote><blockquote><em>In this stage, we detect all the articles (clothes) and particular places the article is placed or located. This will be Both a classification and Regression Problem. Classification because of Article Detection and Regression because of Localization (Bounding Box Co-ordinates)</em></blockquote><blockquote><strong><em>Stage 3: (Image_embeddings)</em></strong></blockquote><blockquote><em>In this stage, we will generate the embedding ( dense vectors ) for the images as discussed below.</em></blockquote><blockquote><strong><em>Stage 4: (Getting similar Images)</em></strong></blockquote><blockquote><em>In this stage, we will use Faiss library to fetch similar clothes based on search query.</em></blockquote><h3>3. Business Constraints</h3><ul><li><strong>Scalable: </strong>Our system architecture should be scalable because every day thousands and thousands of new images are going to be added to the site.</li><li><strong>Low Latency: </strong>A customer is not going to wait for minutes or even for more than 5–10sec for a recommendation. So our architecture should be able to retrieve recommendations within a given time frame.</li><li>Real-time constraints have to be kept in mind as it is an offline recommendation system. Interpretability is important from the customer side, it can be helpful to state why a recommendation is made. When recommending a product to a user, System added a link to the product that the user watched and triggered the recommendation.</li></ul><h3>4. Data Acquisition and Analysis</h3><p>Data is scraped from Myntra. I used selenium for that. This data is not labeled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*8-qExsut5GacB42MHVtCcA.png" /></figure><p>The data has different types of clothes(upper ware, lower wear, and footwear) for ladies. As this data scrapped from Myntra we have masks or bounding boxes for article/clothes localization/detection. So, for the article detection and localization part, I have taken the data from Kaggle Competiton: <a href="https://www.kaggle.com/c/imaterialist-fashion-2019-FGVC6/data">iMaterialist (Fashion) 2019 at FGVC6</a>. This Fashion data has 45.2k files approximately with output In <a href="https://www.kaggle.com/c/data-science-bowl-2018/discussion/47699">Encoded pixel Format</a> with class_labels.</p><h3>5. Research section</h3><ol><li><strong>Main Paper: </strong><a href="https://arxiv.org/pdf/2008.11638.pdf"><strong>https://arxiv.org/pdf/2008.11638.pdf</strong></a></li></ol><p>I took the below picture from a research paper.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/0*2oBzrd8KTORW2aNN" /><figcaption>Buy me that look, Fashion recommendation system blueprint.</figcaption></figure><p>Buy me that look, Fashion recommendation system blueprint.</p><p>From the paper, the architecture is as explained below.</p><ol><li>By using a pose detection classifier, we must detect full shot images, and based on FFS, we must find front-facing images.</li><li>Front-facing images are passed to a CNN network with active learning detects the fashion objects in the image and does localization.</li><li>Image embeddings are created for all images available in the catalog and stored in the database. Triplet-Net-Based Embedding Learning is used to generate the test data. we can also use a simple CNN-based autoencoder.</li><li>A query image is passed, and similar images are retrieved from the database. Here they have used cosine similarity to get similar metrics from the database.</li></ol><p><strong>2. Pose detection: </strong><a href="https://nanonets.com/blog/human-pose-estimation-2d-guide/"><strong>https://nanonets.com/blog/human-pose-estimation-2d-guide/</strong></a></p><p>In this blog, various approaches are used for posing detection problems. By using these pre-trained models, we can save a lot of time. Choosing the architecture that works best on the dataset then later fine-tune or modify the architecture to get the best results.</p><p><strong>3. Localization / article detection: </strong><a href="https://valohai.com/blog/clothes-detection-for-fashion-recommendation/"><strong>https://valohai.com/blog/clothes-detection-for-fashion-recommendation/</strong></a></p><p>In this blog, users have explained about different labeled datasets for fashion object detection. This pre-trained dataset can be used on top of our data to increase the accuracy of the model. The blog has a detailed explanation of how to use object detection API for Tensorflow with good snippets of code which will help try the above models first as a black box and then later choose the architecture that gives the best results on our datasets.</p><p>object detection API for Tensorflow came several pre-implemented architectures with pre-trained weights on the COCO (Common Objects in Context) dataset, such as</p><blockquote><em>SSD (Single-Shot Multi-box Detector) with Mobile Nets</em></blockquote><blockquote><em>SSD with Inception V2.</em></blockquote><blockquote><em>R-FCN (Region-based Fully Convolutional Networks) with Resnet 101.</em></blockquote><blockquote><em>Faster RCNN (Region-based Convolutional Neural Networks) with Resnet 101.</em></blockquote><blockquote><em>Faster RCNN with Inception Resnet v2</em></blockquote><p><strong>4. Triplet Loss: </strong><a href="https://towardsdatascience.com/image-similarity-using-trip%20let-loss-3744c0f67973"><strong>https://towardsdatascience.com/image-similarity-using-trip%20let-loss-3744c0f67973</strong></a></p><p>This blog has a good explanation of how to use Triplet loss for image similarity problems. So, my understanding of Triplet Loss architecture helps us to learn distributed embedding by the notion of similarity and dissimilarity. It’s a kind of neural network architecture where multiple parallel networks are trained that share weights among each other. During prediction time, input data is passed through one network to compute distributed embeddings representation of input data.</p><p>Loss function: The cost function for Triplet Loss is as follows:</p><p>L(a, p, n) = max(0, D(a, p) — D(a, n) + margin)</p><p>where D(x, y): the distance between the learned vector representation of x and y. As a distance metric L2 distance or (1 — cosine similarity) can be used. The objective of this function is to keep the distance between the anchor and positive smaller than the distance between the anchor and negative.</p><h3>6. My Approach</h3><p>Here I will be explaining my implementation of the business problem.</p><p><strong>Module_1:</strong></p><p>In Module1, for pose detection, I tried using HRNet and TensorFlow lite models. Both model outputs are almost similar. So, I picked up HRNet. From the below snippet it is clear that both models have similar results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*JjXQ4Js7wk7CqQDf_vQQzA.png" /></figure><p>So, here I have used the HRNet from my research section to find all full poses and front posing images from my corpus.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ab31224c30a7c752028af5e7dcdeba2/href">https://medium.com/media/3ab31224c30a7c752028af5e7dcdeba2/href</a></iframe><p><strong>Results:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1aae4e8d62359052056985723a713482/href">https://medium.com/media/1aae4e8d62359052056985723a713482/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*WDCKSYapbi2tHgyM3hNTwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*WDCKSYapbi2tHgyM3hNTwg.png" /><figcaption>Result of Module 1</figcaption></figure><p>If the Image is found to be full pose then this image is sent to module 2</p><p><strong>Module_2:</strong></p><p>In module 2, we have to detect all the articles and localize them. For that, I have used the MaskRcnn model. I took data from the Kaggle competition “iMaterialist (Fashion) 2019 at FGVC6”. After the localization, we have to crop the images and pass them to Module 3 for generating embedding.</p><p><strong>How does MaskRCNN works?</strong></p><p>Mask R-CNN (regional convolutional neural network) is a two-stage framework: the first stage scans the image and generates proposals (areas likely to contain an object). And the second stage classifies the proposals and generates bounding boxes and masks. Mask R-CNN paper is an extension of its predecessor, Faster R-CNN, by the same authors. Faster R-CNN is a popular framework for object detection, and Mask R-CNN extends it with instance segmentation, among other things.</p><p>This tutorial requires TensorFlow version 1.15.3 and Keras 2.2.4. It does not work with TensorFlow 2.0+ or Keras 2.2.5+ because a third-party library has not been updated at the time of writing.</p><p>!pip install — no-deps tensorflow==1.15.3</p><p>!pip install — no-deps keras==2.2.4</p><p>Mask R-CNN is basically an extension of Faster R-CNN. Faster R-CNN is widely used for object detection tasks. The Mask R-CNN framework is built on top of Faster R-CNN. So, for a given image, Mask R-CNN, in addition to the class label and bounding box coordinates for each object, will also return the object mask.</p><ol><li>Faster R-CNN first uses a ConvNet to extract feature maps from the images</li><li>These feature maps are then passed through a Region Proposal Network (RPN) which returns the candidate bounding boxes</li><li>We then apply an RoI ( Region of Interest ) pooling layer on these candidate bounding boxes to bring all the candidates to the same size</li><li>And finally, the proposals are passed to a fully connected layer to classify and output the bounding boxes for objects</li></ol><p>Similar to the ConvNet that we use in Faster R-CNN to extract feature maps from the image, we use the ResNet 101 architecture to extract features from the images in Mask R-CNN. So, the first step is to take an image and extract features using the ResNet 101 architecture. These features act as an input for the next layer.</p><p>Now, we take the feature maps obtained in the previous step and apply a region proposal network (RPM). This basically predicts if an object is present in that region (or not). In this step, we get those regions or feature maps that the model predicts contain some objects.</p><p>The regions obtained from the RPN might be of different shapes, right? Hence, we apply a pooling layer and convert all the regions to the same shape. Next, these regions are passed through a fully connected network so that the class label and bounding boxes are predicted.</p><p>Till this point, the steps are almost like how Faster R-CNN works. Now comes the difference between the two frameworks. In addition to this, Mask R-CNN also generates the segmentation mask.</p><p>For that, we first compute the region of interest so that the computation time can be reduced. For all the predicted regions, we compute the Intersection over Union (IoU) with the ground truth boxes. We can computer IoU like this:</p><p>IoU = Area of the intersection / Area of the union</p><p>Now, only if the IoU is greater than or equal to 0.7+, we consider that as a region of interest. Otherwise, we neglect that region. We do this for all the regions and then select only a set of regions for which the IoU is greater than 0.7+.</p><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*TZNRuqjk4N4PdpnNcGiESA.png" /><figcaption>Localization / articel detection</figcaption></figure><p><strong>Module_3:</strong></p><p>In Module 3, I tried with DenseNet121, ResNet50, ResNet101, MobileNet, and InceptionV3. Out of all these. DenseNet121 gave good results.</p><p>DenseNet121 is low sparsity compared with others. I choose Densenet121.</p><p>DenseNet generated 1024 dimensional embedding with low sparsity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96cb62602e70dc055e7018692c3b8318/href">https://medium.com/media/96cb62602e70dc055e7018692c3b8318/href</a></iframe><p>As we saw that we have 8 categories of data, I have divided them into 3 super categories for indexing as below.</p><p><strong>Upper_wear</strong>: women_shirts_tops_tess<br><strong>Lower_wear</strong>: women jeans juggings, women skirts, women trousers<br><strong>Foot_wear</strong>: women casual shoes, flats, heels</p><p><strong>Module_4:</strong></p><p>In Module 4, I have used FAISS (Facebook AI Similarity Search) library to retrieve similar articles.</p><p>Faiss works only with float32 type ndarray. So, first, we have converted our embedding into ndarray type float32.</p><p>Created 3 indexes with faiss for upper ware, lower ware, and footwear.</p><p><a href="https://github.com/facebookresearch/faiss/wiki/Faiss-indexes">Faiss indexes</a></p><p>From the Facebook Github page provided above, IndexFlatL2 is a brute-force one compared with others that use Euclidean distance to calculate the nearest distance. So, I used it. Also to reduce the space complexity used an <strong>IndexIVFPQ</strong> quantizer. We can use cosine as well, but we have to normalize the vector before using cosine. Normally cosine distance is used in text similarities.</p><p>The index takes only one parameter, which is nothing but a vector with any shape but if we are passing multiple vectors make sure all vectors are in the same shape.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbc13d65d68076e8aac57cfaad53c88f/href">https://medium.com/media/cbc13d65d68076e8aac57cfaad53c88f/href</a></iframe><p>We have a search method with Faiss which depends upon index values to retrieve similar articles. In the search method also we have to pass the vector with the shape that matches with the indexing vector.</p><p>As the generate embedding in module 3 returns a list with length 2014, not in the same shape ( row vector ) and type ( float 32 ndarray). we have to convert it first before searching.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/792ce26382e0771989f579e5159b5a24/href">https://medium.com/media/792ce26382e0771989f579e5159b5a24/href</a></iframe><h3>7. End Results</h3><p>So we have an out final solution. Model is able to detect and retrieve fashion objects from the given image. So there are a few wrong object detection and wrong retrieval but this is because the model is trained for fewer epochs. Some wrong retrievals are because whole images are embedded and not the objects. Also, the database size is also very small. But overall, we have a first-cut solution that can be further expanded and optimized. please check out in Github link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*-hDA_w7xPK91-FPgQiAT-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*yqnUER4m1UE-W8DyoBHCGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*ZfYP63JaOVD6ho4DbftF3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*p5NyVGbYzSd0Vu12whuqwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*IYtEKf3xjzPu6X_MUL312w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*wTJHELI8-8v_Ojy6tuXHSg.png" /></figure><h3>8. Future Work</h3><ol><li>Reduce the latency of the end-to-end application.</li><li>For embeddings try different approaches like build your own model with some good score.</li><li>Collect more data for object detection and use the latest segmentation approach other than MASK RCNN.</li><li>Train the Triplet-net Based Embedding layer network for getting similar images as per the research paper.</li><li>Deploy a model into production for real-time recommendation</li></ol><h3>9.References</h3><ol><li><a href="https://arxiv.org/pdf/2008.11638.pdf">https://arxiv.org/pdf/2008.11638.pdf</a></li><li><a href="https://www.tensorflow.org/lite/examples/pose_estimation/overview">https://www.tensorflow.org/lite/examples/pose_estimation/overview</a></li><li><a href="https://programmer.group/analysis-of-official-post-energy-model-of-tensorflow.html">https://programmer.group/analysis-of-official-post-energy-model-of-tensorflow.html</a></li><li><a href="https://github.com/matterport/Mask_RCNN">https://github.com/matterport/Mask_RCNN</a></li><li><a href="https://towardsdatascience.com/mask-rcnn-implementation-on-a-custom-dataset-fd9a878123d4">https://towardsdatascience.com/mask-rcnn-implementation-on-a-custom-dataset-fd9a878123d4</a></li><li><a href="https://www.tensorflow.org/api_docs/python/tf/keras/applications">https://www.tensorflow.org/api_docs/python/tf/keras/applications</a></li><li><a href="https://github.com/facebookresearch/faiss/wiki">https://github.com/facebookresearch/faiss/wiki</a></li><li><a href="https://www.appliedaicourse.com/">https://www.appliedaicourse.com/</a></li></ol><p>If you have any queries, feel free to comment down or you can also contact me on <a href="https://www.linkedin.com/in/naman-gupta-ds/">Linkedin</a>. You can find my complete project <a href="https://github.com/NamanGuptacs/buy-me-that-look/tree/master">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=137c1e7030ec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/buy-me-that-look-137c1e7030ec">Buy Me That Look</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 Traffic Time Series Forecasting Part-2]]></title>
            <link>https://medium.com/analytics-vidhya/web-traffic-time-series-forecasting-part-2-400b3e0e539b?source=rss-6e0d1ae537c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/400b3e0e539b</guid>
            <category><![CDATA[time-series-forecasting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Naman Gupta]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 18:51:52 GMT</pubDate>
            <atom:updated>2021-02-04T16:49:14.004Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the 2nd part of our series, the series includes-</p><ol><li><a href="https://namangupta-cs.medium.com/web-traffic-time-series-forecasting-part-1-a819b65013ec">Introduction and Exploratory Data Analysis</a></li><li><a href="https://namangupta-cs.medium.com/web-traffic-time-series-forecasting-part-2-400b3e0e539b">Feature Engineering, Modelling and Deployment</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*4htzB81y86AG53PjcSzFjw.png" /></figure><p>In the previous blog, we saw a detailed analysis of the data. Now, it’s time to start some feature engineering and building models.</p><h3>Table of Content-</h3><ol><li>Baseline Model</li><li>Feature Engineering</li><li>Modeling</li><li>Deployment</li><li>Future Work</li><li>References</li></ol><h3>1. Baseline Model-</h3><p>First, we will make predictions only based on the medians of the data and we will use it as our baseline model.</p><p>Now, we will use the median of data to make predictions, for each page we have taken the median for each weekday and used it to make predictions for the next 62 days accordingly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e28b740e9e03c5f0c479c93a33efb0fa/href">https://medium.com/media/e28b740e9e03c5f0c479c93a33efb0fa/href</a></iframe><p>We have calculated medians for each page for each weekday, now we will make predictions for Kaggle and make a CSV file based on the format for sample_submission file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/603a57d2a741d7f986c5368eb36a8368/href">https://medium.com/media/603a57d2a741d7f986c5368eb36a8368/href</a></iframe><p>After making a submission on Kaggle for the above predictions, here are our results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*mexB3Rzgtr7R82h2FvzYKg.png" /></figure><p>For this submission, we are currently in 310th position out of 1095 total teams</p><h3>2. Feature Engineering-</h3><p>Let&#39;s start with some feature engineering !. We will create features for the last 15 days of data and through feature engineering techniques we will try to use the rest of them to create features for the last 15 days. As we saw that there was a high correlation for 7 days lag, so the first feature we are creating is the week-day feature. Other than this, we will create 3 features which have total visitors on the previous 3 days, threedays1 will have traffic for (d-1)+(d-2)+(d-3) days, threedays2 will have traffic for (d-4)+(d-5)+(d-6), similar for threedays3. Another feature will be weekday which contains as the name suggests a day of the week.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f6d4279690a3e15546fba0bafdbaa25/href">https://medium.com/media/3f6d4279690a3e15546fba0bafdbaa25/href</a></iframe><p>As we know that language, type of access and type of client do have an impact on traffic, so using these as features can be useful.</p><p>lang_feat — It will contain the language feature.</p><p>agent_feat — we are adding 1 for spider data and 0 for non-spider data.</p><p>access_feat — we are adding 0 for all-access, 1 for desktop, and 2 for mobile.</p><p>As we are creating data for the last 15 days, so for each page above features will be repeated 15 times.</p><p>Now, we will create features based on Fourier transformation. As we saw during analysis that there were some unnecessary peaks at the start, so, after removing some initial values, will take the top 3 peaks and use them as features.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/827751c5a70e54257ae2b4f5f7df9cec/href">https://medium.com/media/827751c5a70e54257ae2b4f5f7df9cec/href</a></iframe><p>Have created all the features that we have discussed till now, will use these to train the model.</p><h3>Summary and key takeaways from our work till now</h3><p>First, we loaded the required libraries and files. Handling Missing values :</p><p>We used linear interpolation for filling missing values that were not missing for many consecutive days. For filling consecutive missing values, we used the data from 180 days later.</p><h4><strong>Data Analysis:</strong></h4><ul><li>Saw that most of the traffic was on English language pages.</li><li>There was very little traffic by bots as compared to actual humans.</li><li>May has the most number of visitors.</li><li>Weekdays and weekends don’t actually make much difference.</li><li>The last three months of the year have more number of visitors on average than other months of the year.</li><li>On average, the English language has the most number of visitors.</li></ul><h4>Feature Engineering :</h4><p>Used rolling window technique to generate features, from every time series we used 15 days of data. These are the features that we generated- Day of the week</p><ul><li>Number of visitors on d-7 days</li><li>Total visitors on the last 3 buckets of 3 days.</li><li>Language of the page</li><li>The client of the page (All-access, mobile, desktop)</li><li>Spider or actual human traffic</li><li>Top three peaks from Fourier transformed data.</li></ul><p><strong>Making data model ready-</strong></p><p>Now, will start to build a model based on the features that have created. First, will convert all the categorical features into one-hot encoded features and normalize all continuous feature.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/353198562f7af6e29e0bb222b8f6070e/href">https://medium.com/media/353198562f7af6e29e0bb222b8f6070e/href</a></iframe><p>Now, will split our data into train and test. We will split our data into 75 and 25.</p><p>As have already discussed that for evaluating our model, we will be using SMAPE, as there is no inbuilt function for that in python we have to implement that and we will use custom metrics for evaluating our model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36c380ff095763a82b9ef8c274564cb9/href">https://medium.com/media/36c380ff095763a82b9ef8c274564cb9/href</a></iframe><p>Let’s start with model building.</p><h3>3. Modelling-</h3><p><strong>Linear Regression-</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/007950a5a27ffc3467e7a2b62d8fcfed/href">https://medium.com/media/007950a5a27ffc3467e7a2b62d8fcfed/href</a></iframe><p>These are not good results, should try a more powerful algorithm and see how these perform.</p><p><strong>Decision Tree-</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86e908c4accd64af14d4513ae73bc96d/href">https://medium.com/media/86e908c4accd64af14d4513ae73bc96d/href</a></iframe><p>Results are good in comparison to Linear Regression but overall these do not seem capable of getting us in a good position on the leaderboard.</p><p><strong>Random Forest-</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/232a1015d50c4b829134fb4f23d397e2/href">https://medium.com/media/232a1015d50c4b829134fb4f23d397e2/href</a></iframe><p>These results are far better than the Decision tree but keep in mind that we are using certain features for this prediction that we don’t have future data and we have to make prediction sequentially in order to make predictions and use these predictions as a feature for future predictions, the errors in our predictions will increase exponentially as we will try to predict for farther dates. So, we have to get a much better score here from the score that we expecting on the leaderboard because the leaderboard score will greater than this.</p><p><strong>XgBoost-</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2eaa4bc034f2a7df0b5844a07654d9d/href">https://medium.com/media/c2eaa4bc034f2a7df0b5844a07654d9d/href</a></iframe><p>The score is even more than the random forest and Decision tree algorithms</p><h3>Summary of performance of all the models</h3><p>Liner Regression- 0.79</p><p>Decision Tree- 0.40</p><p>Random Forest- 0.37</p><p>XgBoost — 0.43</p><p>The best performing model here is Random Forest, so we will use it for predictions for Kaggle, and let&#39;s hope this can perform well on the leaderboard as well.</p><h3>Predictions for Kaggle</h3><p>Will create all the features for predictions that we created during feature engineering. Now, will combine all the features and start making predictions for Kaggle. Tried submitting with Xgboost algorithm, in spite of the maximum score then Random forest, xgb performed well than a Random forest in Kaggle.</p><p>Here are the results-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*qwGxMpBfHAVXzfFYjyUltA.png" /></figure><p>This is exactly what I was fearing, error indeed increased exponentially as we predicted for farther dates, this score is worse than our median submission. Now, we have to think of something else.</p><p><strong>Deep Learning to the rescue-</strong></p><p>Now, will try LSTM as well. Like before, will not use any feature that uses predicted data as it will create problems.</p><p>As we have more than 145k time series, we are using only 50% of the data to train the model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d62bf9b332e127f99d63aa36a044da7/href">https://medium.com/media/8d62bf9b332e127f99d63aa36a044da7/href</a></iframe><p>For evaluating our model, will use Mean Absolute Error(MAE) on log1p of data. This is pretty similar to SMAPE on original data. After final predictions will use expm1 on data to convert it back to its original form.</p><p>Along with the time series, will use the three features as well that can extract from the page name</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad15ae7ba2d4be798b93f090eb64e10a/href">https://medium.com/media/ad15ae7ba2d4be798b93f090eb64e10a/href</a></iframe><p>Above code creates all the features that we need for our model, now we will label encode all the categorical features, reshape them in proper shapes to feed them to the model, and split data into train and test.</p><p>Our data is ready and we can start building our model architecture. Model will have 4 input layers(one for each feature), time-series data will go through LSTM layer and all the label encoded features will go through an embedding layer, and then we will flatten the output so that we can concatenate all these layers. After that, we will use a dense layer and an output layer.</p><p>The architecture looks like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ee6deae0270d571d552de612e5b5055/href">https://medium.com/media/5ee6deae0270d571d552de612e5b5055/href</a></iframe><p>Now, let’s take a look at the architectural graph of our model-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4a0SEC4ZNay1NyxSEX35TA.png" /></figure><p>As we have already discussed that MAE on log1p of data is somewhat similar to SMAPE, so we should get a pretty good score on the leaderboard also.</p><p>After making predictions and submitting the file on Kaggle, here are our results-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*F_2LVS7ELf3sG_pWSG_RHw.png" /></figure><p>The score is good and it takes us in the top 10% on the leaderboard and 92/1095 position.</p><p>Tried to add a Conv1d layer to improve the accuracy but seems that Kaggle score increased. Also added some more layers of LSTM but still, the score was increased. It might possible due to overfitting of the model to overcome this added the dropout layer but it will not affect much on score still the score was not decreased further.</p><h3>Comparative study of all the models that tried</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*k7HJXRtX3xWlD77Vzps_AA.png" /></figure><p>Tree-based model was unable to perform well, their scores were worse than the median model but LSTM proved to be a good choice maybe the reason is that they are specialized in seq-seq prediction.</p><h3>4. Deployment-</h3><p>What good a model is if it doesn’t reach customers. Most of the case study blogs skip this part but, will leave no stone unturned. Will be using flask for deployment and Heroku for service.</p><p>In the modeling section, we were training models in such a way that they will predict for the next 64 days but here we need prediction just for one specified date. So, I have trained LSTM in such a way that it takes data for the last 5 days as input instead of 200 days and predicts for the next day. The code would be pretty similar but in case you still want to see my code you can check my GitHub repository. Now, we have to build a pipeline for the preprocessing, feature engineering, and prediction. We can’t ask users to enter the traffic for the last 5 days and the page name itself to make a prediction. So, we would be taking index and date as input, the index will correspond to a particular page name as mentioned in the dataset, and according to the date for which he wants to make prediction data will be fetched from the CSV file. Heroku gives us a limit of 500 MB and the Tensorflow module alone will take more than 300 MB so we can’t use our complete dataset for that. So, instead of 145k pages, we will be using 10k pages only for model deployment.</p><p>Let’s get started with the pipeline!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ac370db2e8a22e44ee5180ac803c7ef/href">https://medium.com/media/9ac370db2e8a22e44ee5180ac803c7ef/href</a></iframe><p>The output will look like this-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*NlarDXX2WVvynfCjAGLE7A.png" /></figure><p>Ok, so now we are done with the pipeline and now it’s time to use Flask to deploy and we also have to build HTML pages( I will keep it very simple).</p><p>Now, let&#39;s proceed to Heroku. So, Heroku is free and pretty easy to use, we will use Github to deploy our model on Heroku. So basically there are two extra files that we have to create <em>Procfile</em>(without any extension) and <em>Requirements.txt</em></p><p>Procfile contains the name of the file that needs to be run first and requirements.txt contains names of all the modules that need to be installed. Now, we just have to choose ‘connect to GitHub’ on Heroku and search our GitHub repository and click deploy. If all the code is correct, the model will be deployed and a link will be generated for your app.</p><p>After doing all the above steps, <a href="https://web-traffic-forecasting.herokuapp.com/">here</a> is our app. It may take some time to open the link, have patience.</p><h3>5. Future Work-</h3><ol><li>Attention mechanism-based models can be tried in order to use information from the distant past to improve the results.</li><li>Different types of smoothing and transformation of data can be tried in order to improve the results.</li><li>As we discussed in Existing approaches, there are few simple statistics based method which proved pretty good, these methods can be used to provide extra features to the models to improve the results.</li></ol><h3>6.References-</h3><ol><li><a href="https://www.kaggle.com/c/web-traffic-time-series-forecasting/discussion/43795">https://www.kaggle.com/c/web-traffic-time-series-forecasting/discussion/43795</a></li></ol><p>2. <a href="https://towardsdatascience.com/web-traffic-forecasting-f6152ca240cb">https://towardsdatascience.com/web-traffic-forecasting-f6152ca240cb</a></p><p>3. <a href="https://cs.adelaide.edu.au/~zbyszek/Papers/p51.pdf">https://cs.adelaide.edu.au/~zbyszek/Papers/p51.pdf</a></p><p>4. <a href="https://blog.octo.com/en/time-series-features-extraction-using-fourier-and-wavelet-transforms-on-ecg-data/">https://blog.octo.com/en/time-series-features-extraction-using-fourier-and-wavelet-transforms-on-ecg-data/</a></p><p>5. <a href="https://www.youtube.com/watch?v=mrExsjcvF4o&amp;t=830s">https://www.youtube.com/watch?v=mrExsjcvF4o&amp;t=830s</a></p><p>6. <a href="https://www.appliedaicourse.com/course/11/Applied-Machine-learning-course">https://www.appliedaicourse.com/course/11/Applied-Machine-learning-course</a></p><p>If you have any queries, feel free to comment down or you can also contact me on <a href="https://www.linkedin.com/in/naman-gupta-ds/">Linkedin</a>. You can find my complete project <a href="https://github.com/NamanGuptacs/web-traffic-time-series-forecasting">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=400b3e0e539b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/web-traffic-time-series-forecasting-part-2-400b3e0e539b">Web Traffic Time Series Forecasting Part-2</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 Traffic Time Series Forecasting Part-1]]></title>
            <link>https://medium.com/analytics-vidhya/web-traffic-time-series-forecasting-part-1-a819b65013ec?source=rss-6e0d1ae537c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a819b65013ec</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[time-series-forecasting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <dc:creator><![CDATA[Naman Gupta]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 17:01:12 GMT</pubDate>
            <atom:updated>2021-02-04T16:49:01.480Z</atom:updated>
            <content:encoded><![CDATA[<p>We will be creating an end-to-end case study. I have divided this blog into a series of two blogs.</p><ol><li><a href="https://namangupta-cs.medium.com/web-traffic-time-series-forecasting-part-1-a819b65013ec">Introduction and Exploratory Data Analysis</a></li><li><a href="https://namangupta-cs.medium.com/web-traffic-time-series-forecasting-part-2-400b3e0e539b">Feature Engineering, Modelling and Deployment</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*4htzB81y86AG53PjcSzFjw.png" /></figure><p>Table of Content-</p><ol><li>Problem Statement</li><li>Real-world objective/constraint</li><li>Data source and overview</li><li>Performance Metrics</li><li>Existing Solution</li><li>First cut Approach</li><li>Exploratory Data Analysis</li><li>References</li></ol><h3>1. Problem statement-</h3><p>This is a Kaggle competition problem which was held nearly 4 years ago. In this case study, we will be focusing on a time series problem. Let’s quickly define the Time-series. Time series is a set of observations recorded over regular intervals of time. Time series can be beneficial in many fields like stock market prediction, weather forecasting. Time series can come in handy in many problems like analysis, classification, and most important forecasting, in this case, a study we will be focusing on analysis and forecasting.</p><p>This case study focuses on predicting future values for multiple time series problems. Each time series contains daily traffic on the Wikipedia page for a total of 803 days from 2015–07–01 to 2017–09–10. We have a total of 145k time series which means we have data for 145k pages, our goal is to analyze this data, build a model on it and predict future traffic on each of the pages for 62 days from 2017–09–13 to 2017–11–13(well, it is not actually future but when this competition was held, it was!)</p><h3>2. Real-world objective/constraint-</h3><p>Minimize the difference between actual and predicted values.</p><p>There are no particular latency requirements, but we should try that it shouldn’t take hours to predict for a particular date. Up to 20–30 seconds should be acceptable.</p><h3>3. Data Overview-</h3><p>The training dataset has a total of 145k time series for Wikipedia pages and it contains daily traffic on those pages from July 2015 to September 2017. We have to predict daily traffic on each of the pages from 13th September 2017 to 13th November 2017. We have given three files in total- train.csv,key.csv,sample_submission.csv.</p><p>Train.csv contains about 145k rows each of which represents a different Wikipedia page and it has 804 columns, except the first column each column represents a date and it has daily traffic on that particular Wikipedia page. The first column contains the name of the page which includes the language of the Wikipedia page(for example, for English en.wilipedia.org, for Spanish es.wikipedia.org,zh,wikipedia.org for Chinese), type of access(desktop,all-access, agent(spider). For example one name is- ‘AKB48_zh.wikipedia .org_all-access_spider’.</p><p>The second file is ‘key.csv’ which has a number of rows equal to the number of predictions we have to make. There are two columns in this file- ‘page name’ and ‘id’. For each page name that is present in the ‘train.csv’ file, we have 62 rows present in the key.csv file, these 62 rows correspond to 62 days of predictions for each page. For each page name, there is a corresponding id.</p><h3>4. Performance Metrics-</h3><p>We will be using SMAPE(Symmetric Mean Absolute Percentage Error) as our performance metrics. This is often used in forecasting problems. This has a range of [0,200]. As this is not inbuilt metrics in python, we will be implementing it from scratch and will use a custom metric to evaluate our models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/0*nj9Hq7GT578eUPeU" /></figure><h3>5. Existing solutions-</h3><ol><li><a href="https://www.kaggle.com/c/web-traffic-time-series-forecasting/discussion/43795"><strong>Winner’s solution</strong></a>-</li></ol><p>In this solution, all values have been transformed to log1p, this will help to make every time series similar i.e. smaller values and larger values will be similar and the distribution will be more towards normal.</p><p>A new feature is generated called ‘page popularity’, this is the median of time series values, this feature will help in understanding the scale of time series. For example, one time series can have values between 5–20 and others can have values between 50–100. This solution used an attention mechanism based RNN. Used RNN seq2seq model for prediction. Model has two main parts Encoder and Decoder use cuDNN GRU in the encoder rather than the usual Tensorflow RNN cell.</p><p>2.<a href="https://www.kaggle.com/safavieh/median-estimation-by-fibonacci-et-al-lb-44-9/execution"><strong> Statistics based solution</strong></a>-</p><p>In this solution, a median of different window sizes was used to make predictions. Window size is decided by Fibonacci series starting from 6,12 and then 18,30,48,78 and so on. To make predictions, the median of the last 6days, 12 days, 18 days,…… is taken, and then the median of all these values is taken. If we don’t have enough data then the median of all available data is taken. This solution is simple but performed quite well.</p><h3>6. First cut Approach-</h3><p>We will try to focus on the feature engineering part as we will be solving this case study with machine learning models first and then we will try deep learning models that are powerful enough to learn features on their own but we might need to provide features explicitly for machine learning models. I will try to generate features that can capture weekly, quarterly and yearly patterns. We will start with a basic median based model as our baseline model. After that, we will try models like xgboost, gbdt as they have proved themselves to be a good option in any condition.</p><p>Feature engineering-</p><p>We have a total of 26 months of training data and we have to predict for the next 62 days. We will generate features for the last 15 days. Rolling window features will be generated. Other feature engineering techniques that will be tried are as follows-</p><p>(i) Median of (t-4 months,t-8 months,t-12 months,t-16 months) where each of these values itself is median of 2 days before and after values. This feature will help us to capture quarterly trends.</p><p>(ii) Median of last 5 days</p><p>(iii) Median of the last 5 same weekdays, this feature will help us to capture a weekly trend.</p><p>(iv) To capture yearly trend, we will take median of t-363,t-364,t-365,t-366,t-367</p><p>(v) Fourier transformation will also be used.</p><p>(vi) Taking the median of Fibonacci series window size can be good for our model, this will also be tested.</p><p>The all above features will be generated after going through the basic time series models first. Different methods will also be applied to make the time series more stationary. Detailed EDA will also be done and feature engineering will be changed accordingly. Preprocessing like missing values imputation will be performed.</p><h3>7. Exploratory Data Analysis-</h3><p>First, we will fill in all the missing values(if any). so, let’s check if there is any missing value in the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/0*1gXiGjus1h2JDeB1" /></figure><p>Above image shows a count of missing values for a few dates only but we can get an idea from it that there are a lot of missing values in the data. For some pages, data is present only for the last few months, the rest of the data is null. This can be because of the fact that this wiki page was created later, so data is present only for days after the page was created. So now we have two situation- one where the data is actually missing and the other where the page was not even created, now we know that when the data is actually missing it would be missing for few days for some of the dates but when the page was not even created we would not have data for that page right from the beginning and suddenly we will have all the data for that page.</p><p>To fill the missing values for data for the first situation we will use <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.interpolate.html">linear interpolation</a>, for situation two missing values we will fill them with 0</p><p>As we have more than 145k time series, analyzing all of them individually is just impossible, we have to find out some way on which we can divide these time series and then combine each group to analyze. Remember, the name of the pages contains the language of the page, we can use it to combine different types of pages and then analyze them. So, let’s get started with it!</p><p><strong>Is traffic affected by Page language?</strong></p><p>Look for the different languages present on the Wikipedia page which might affect the dataset by using simple regular expressions. There are some non-Wikipedia pages, these are Wikimedia pages, so give them the code ‘na’ since haven’t determined their language. Many of these will be things like images that do not really have a language.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/edbf5e195c2831f634ef9722589ed9c0/href">https://medium.com/media/edbf5e195c2831f634ef9722589ed9c0/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*gkclodSOVluCW6-VkwpBkg.png" /><figcaption>Count of languages present</figcaption></figure><p>There are 7 languages plus the media pages. The languages used here are: English, Japanese, German, French, Chinese, Russian, and Spanish.</p><p>Create data frames for the different types of entries. After that calculate the sum of all views. The data comes from several different sources, the sum will likely be double-counting some of the views.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36582e7071c573de6b57ef814f634f45/href">https://medium.com/media/36582e7071c573de6b57ef814f634f45/href</a></iframe><p>Now, let’s see what we get</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/0*sjU6zFbwuRyH6vIe" /></figure><p>Conclusion:</p><p>English shows a much higher number of views per page. There is a lot more structure here than expected. The English and Russian plots show very large spikes around day 400 (around August 2016), with several more spikes in the English data later in 2016. My guess is that this is the effect of both the Summer Olympics in August and the election in the US.</p><p>There’s also a strange feature in the English data around day 200.</p><p>The Spanish data is very interesting too. There is a clear periodic structure there, with an approx 1-week fast period and what looks like a significant dip around every 6 months or so.</p><p><strong>Periodic Structure and FFTs</strong></p><p>Since it looks like there is some periodic structure here, plot each of these separately so that the scale is more visible. Along with the individual plots, I will also look at the magnitude of the Fast Fourier Transform (FFT). Peaks in the FFT show us the strongest frequencies in the periodic signal.</p><p><strong>Plot for English Wikipedia-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/0*0GIRDScXqiseNYQu" /></figure><p>For the first few months, there were only 1 or 2 spikes in the data but after July 2016 there was a rapid hike and after that, traffic has gone down by a large margin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/0*NdsEV-wb1uN9hplq" /></figure><p>Small peaks were there in the end quarter</p><p><strong>Plot for Japanese Wikipedia-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/0*61OGbZ7dqg6s9354" /></figure><p>Japanese Wikipedia shows some large spikes during January 2016 and we can see that traffic has gone down by a very large margin during September 2015.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/0*tkBB8qZOoeHsFkbX" /></figure><p>It is very similar to the plots we saw initially, peaks at 120 and 230 days.</p><p><strong>Plot for German Wikipedia-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/0*esKPkG0mt4gH5jFU" /></figure><p>German Wikipedia has the most number of spikes among all the languages. We can see that this makes the ‘M’ shaped like structure, goes upward then downward and again upward then again downward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*KOZLjAc5RdxhIwrZ" /></figure><p>As expected there are peaks at 120 and 230 but surprisingly at around 340 days, there is a peak.</p><p><strong>Plot for Wikimedia-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*eiA05Vj68-LBV5B2" /></figure><p>This plot is for media pages like images. We can see that till April 2016, data doesn’t show any spikes and after that, it has regular spikes and there are also some very large spikes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/0*SadNv8cSxH2IGNb0" /></figure><p>Regular peaks are there in the data but no large peaks like in the previous graphs.</p><p><strong>Plot for French Wikipedia-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/0*PrBJJDFxU0lnKIRO" /></figure><p>French Wikipedia shows an upward trend. Spikes can also be seen regularly but there is a large spike around March 2016.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/0*gCeHJ2IwJJvHg73e" /></figure><p>This is also very similar to the previous plot, peaks at 120,230 and 340 days. End of every quarter there were hikes.</p><p><strong>Plot for Chinese Wikipedia-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/0*fohVEKKZQGBueVPy" /></figure><p>Like other languages this one also has an upward trend during the first few months, we can see a very large spike during January 2016</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/0*wABnAdFtHV9nJabD" /></figure><p>Very similar to the previous language plot except that it has a comparatively smaller peak at 340 days</p><p><strong>Plot for Russian Wikipedia-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/0*eqEiffTGRQwF4Qea" /></figure><p>Russian Wikipedia does not show a large upward or downward trend but there is a very large spike during Q3 2016. Other than that it has few spikes here and there but not as much as other languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/0*F3di84aPT7AEH7DI" /></figure><p>This has a peak at 120 days but no major peak is seen at 230 days.</p><p><strong>Plot for Spanish Wikipedia-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/0*8I5cSe20RG_HxFvI" /></figure><p>We can see the nice weekly pattern in the data, regular spikes are thereafter 7 days, and one interesting observation from this plot is that traffic usually goes up during late Q3 or early Q4 and in November 2016, it has a very large spike.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/0*nmHIQhjrzvsc8xP8" /></figure><p>This plot shows peaks at 120 and 230 days which shows quarterly periodicity. Small peaks can be seen regularly, this can be because of the fact that 7 days lag shows a high correlation.</p><p>Conclusion:</p><p>After seeing both the plots there is Spanish data has the strongest periodic features, most of the other languages show some periodicity as well. For some reason, the Russian and media data do not seem to show much. Plotted red lines where a period of 1, 1/2, and 1/3 week would appear. See that the periodic features are mainly at 1 and 1/2 weeks. This is not surprising since browsing habits may differ on weekdays compared to weekends, leading to peaks in the FFTs at frequencies of n/(1 week) for integer n. It shows that page views are not at all smooth. There is some regular variation from day to day, but there are also large effects that can happen quite suddenly. A model likely will not be able to predict the sudden spikes unless it can be fed more information required about what is going on currently.</p><h3>Each article name has the following format: ‘name_project_access_agent’. That would be a good idea to separate out all these 4 features to get a better understanding of the data.</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82d03813528ed6b8ac63126c3337cabc/href">https://medium.com/media/82d03813528ed6b8ac63126c3337cabc/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*nGvCZbc8QnrBO3UnU3eKLg.png" /></figure><p>As we can see there are 9, 3, and 2 unique values for project, access, and agent respectively. looking at these values</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec32aaf5cd1bfc72c99ab540d986429c/href">https://medium.com/media/ec32aaf5cd1bfc72c99ab540d986429c/href</a></iframe><p>Plot the project-wise monthly mean hits</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17d802a9e58c5da6689d8dd6f83e3bcd/href">https://medium.com/media/17d802a9e58c5da6689d8dd6f83e3bcd/href</a></iframe><p>Now, Let’s see the plot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*VptIrjlviqzFoTPKuo-0Ug.png" /></figure><p>Conclusion:</p><p>English Wikipedia project hitting more than any other project. Also, Russian Wikipedia is having the same hike near august 2016 as English Wikipedia.</p><p>Now with English projects in graphs, it is hard to visualize other projects. Separated out English project and find some patterns if possible.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93160218e0df7c32d0ba7224c5e5f525/href">https://medium.com/media/93160218e0df7c32d0ba7224c5e5f525/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*F0mSCYRbwseEtL8AAWmVsQ.png" /></figure><p>Conclusion:</p><p>It clearly shows that media pages are rarely visited by users but here some hikes are showing in the Russian page in the 2016 year in June month.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a03fb19ea1232a36e92dfd2beeec8e6/href">https://medium.com/media/3a03fb19ea1232a36e92dfd2beeec8e6/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*f0fDBzMazkqWo4gtCw8JxA.png" /></figure><p>Conclusion:</p><p>All the pages are accessed but the desktop more rigorously than the mobile users. People prefer to access through the desktop.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63488f01313a961ef53d80788f6c6fd6/href">https://medium.com/media/63488f01313a961ef53d80788f6c6fd6/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*5gGbzTD_-6SdYFeird9jrA.png" /></figure><p>Conclusion:</p><p>We could not get the data pattern from the above graph. With just two values for agent why not get them plotted in two separate graphs and see how they behave.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1035aed98a86236145c7ad7e270f977/href">https://medium.com/media/b1035aed98a86236145c7ad7e270f977/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*jGodPu5m2cj2gg_oUh1vWw.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca3c980e62f6cd970ea2e9c4c0e14377/href">https://medium.com/media/ca3c980e62f6cd970ea2e9c4c0e14377/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*LJAp6ZQMUIZEW-cwd-LL8g.png" /></figure><p>Conclusion:</p><p>All-access and all-agents value for access and agents are a summation of values for respective attributes. So each value other than all-access contributes in trend for all-access and all values other than all-agents contribute to the trend of all-agents.</p><p>We have seen every kind of pattern that our data exhibit. Now, we will try to answer some questions based on our data which can prove helpful at later stages of our project.</p><h3>Which month has more visits on average?</h3><p>From here onwards every question that we will try to answer, their average will be based on Median and not on mean.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3699082c3b0bbcb8f06a2deaaddfcfdb/href">https://medium.com/media/3699082c3b0bbcb8f06a2deaaddfcfdb/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EwhA8R-Lnae4-gR7XpJapg.png" /></figure><p>So, index 4 is for May which shows on average May has the most number of visits. In comparison to July which has the least number of average visitors, May shows a significant 25 % growth.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3391dd98d77890320da143a3450d9f68/href">https://medium.com/media/3391dd98d77890320da143a3450d9f68/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*2y09TomRRQ4IMegDTdtLTw.png" /></figure><p>We can see that on average Sunday has the most number of visitors but all of them are pretty close and don’t have much difference.</p><h3>Does the holiday season affect the number of average visitors?</h3><p>As last 3 month of the year has the most number of festivals all over the world. Let&#39;s check if it affects the average number of visitors.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9d38f9b6250d4c6cc4a11b848135d8d/href">https://medium.com/media/c9d38f9b6250d4c6cc4a11b848135d8d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*F7H3T4jEsWZlwDE15qiuSw.png" /></figure><p>There is some difference here. There is actually a 7.3 % dip in the average number of visitors during the holiday season.</p><p>Conclusion- That it actually make difference, during the holiday season, Wikipedia pages have less traffic in comparison to other months of the year.</p><p>This is the end of our EDA, we have analyzed our data in depth which will be useful at later stages of our case study. With this, we conclude this part of the series.</p><h3>8.References-</h3><ol><li><a href="https://www.kaggle.com/c/web-traffic-time-series-forecasting/discussion/43795">https://www.kaggle.com/c/web-traffic-time-series-forecasting/discussion/43795</a></li></ol><p>2. <a href="https://towardsdatascience.com/web-traffic-forecasting-f6152ca240cb">https://towardsdatascience.com/web-traffic-forecasting-f6152ca240cb</a></p><p>3. <a href="https://cs.adelaide.edu.au/~zbyszek/Papers/p51.pdf">https://cs.adelaide.edu.au/~zbyszek/Papers/p51.pdf</a></p><p>4. <a href="https://blog.octo.com/en/time-series-features-extraction-using-fourier-and-wavelet-transforms-on-ecg-data/">https://blog.octo.com/en/time-series-features-extraction-using-fourier-and-wavelet-transforms-on-ecg-data/</a></p><p>5. <a href="https://www.youtube.com/watch?v=mrExsjcvF4o&amp;t=830s">https://www.youtube.com/watch?v=mrExsjcvF4o&amp;t=830s</a></p><p>6. <a href="https://www.appliedaicourse.com/course/11/Applied-Machine-learning-course">https://www.appliedaicourse.com/course/11/Applied-Machine-learning-course</a></p><p>If you have any queries, feel free to comment down or you can also contact me on <a href="https://www.linkedin.com/in/naman-gupta-ds/">Linkedin</a>. You can find my complete project <a href="https://github.com/NamanGuptacs/web-traffic-time-series-forecasting">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a819b65013ec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/web-traffic-time-series-forecasting-part-1-a819b65013ec">Web Traffic Time Series Forecasting Part-1</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>
    </channel>
</rss>