<?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 Vaibhav Agarwal on Medium]]></title>
        <description><![CDATA[Stories by Vaibhav Agarwal on Medium]]></description>
        <link>https://medium.com/@vaibhav2106?source=rss-2182f3e6ac11------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fZu64NgMPqqoB_XVOqy2tQ.jpeg</url>
            <title>Stories by Vaibhav Agarwal on Medium</title>
            <link>https://medium.com/@vaibhav2106?source=rss-2182f3e6ac11------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:37:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vaibhav2106/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[How ML Powers — When is my order coming? — Part II]]></title>
            <link>https://medium.com/swiggy-bytes/how-ml-powers-when-is-my-order-coming-part-ii-eae83575e3a9?source=rss-2182f3e6ac11------2</link>
            <guid isPermaLink="false">https://medium.com/p/eae83575e3a9</guid>
            <category><![CDATA[estimated-time-of-arrival]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[hyperlocal-delivery]]></category>
            <category><![CDATA[swiggy-data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Vaibhav Agarwal]]></dc:creator>
            <pubDate>Fri, 26 May 2023 06:27:08 GMT</pubDate>
            <atom:updated>2023-05-26T06:27:08.292Z</atom:updated>
            <content:encoded><![CDATA[<h3>How ML Powers — When is my order coming? — Part II</h3><p>In a previous <a href="https://bytes.swiggy.com/how-ml-powers-when-is-my-order-coming-part-i-4ef24eae70da">blog</a> , we examined Swiggy’s machine learning-powered ETA model that uses real-time signals from the assignment strategy, restaurant stress, and delivery executive location pings to provide accurate and smooth post-order time estimates to its customers. The ETA model architecture combines four different models for the corresponding four different legs in the order journey: O2A (Ordered to Assignment), FM (First Mile), WT (Wait time), and LM (Last Mile). Each model is designed to use different inputs that impact an order’s progress at different stages to provide accurate predictions. The model also incorporates other real-time features, such as system and restaurant stress, to enhance predictions further.</p><p>In this blog post, we’ll explore the LM Stage of the ETA architecture, evaluation metrics used by the models, as well as the shift from Gradient Boosting Trees to Neural Networks in our modeling approach. Finally, we’ll discuss some potential future improvements, including the use of sequence model architectures and Graph Neural Networks, to make Swiggy’s ETA predictions even more precise and accurate. So, let’s dig in!</p><h3><strong>ETA LM Model</strong></h3><p>The LM Stage of the model is activated when the order is picked up from the restaurant. The diagram below shows the features used by the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M6S3QkkfLe47516DpNBEbQ.png" /><figcaption>ETA LM Stage — Feature Block Diagram</figcaption></figure><p>Real-time DE ping features are classified into time windows and examined for outlier pings that could result in inaccuracies before speed and distance features are computed.</p><p>To determine the current speed of the DE, the distance traveled is computed by adding up the haversine distance between successive pings in the time window. This distance is then divided by the time difference between the first and last ping timestamps.</p><p>To estimate the remaining distance to the customer, the haversine distance between the most recent DE coordinates and the customer’s drop location is calculated. Similarly, the haversine distance between the latest DE coordinates and the restaurant’s location is computed to estimate the distance traveled so far. In addition, the cumulative distance feature is calculated by summing up the haversine distance between successive pings throughout the entire last mile journey. This provides a more accurate estimate of the distance traveled by the DE than the haversine equivalent. Finally, the global speed of the DE is determined by dividing the cumulative distance feature by the time difference between the first and last ping timestamps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNVnvhjmF9ydSwLnzvmM7A.png" /><figcaption>Real Time Traffic levels derived by speed features is an important feature to the ETA LM Model</figcaption></figure><p>These features complement the initial travel time prediction and help to assess the real-time traffic situation on the road, enabling adjustments to the predictions. The real-time features take into account on-ground issues such as road closures, diversions, and the notorious Silk Board junction in Bangalore.</p><h3><strong>Evaluation Metrics</strong></h3><p>The primary metric for evaluating ETA accuracy is the Mean Absolute Error (MAE) of the prediction, which is considered accurate if it falls below a predefined threshold. This metric reflects the overall effectiveness of the model at different stages of the order and the order journey. However, sudden jumps in delivery time estimates can cause customer anxiety and erode trust in Swiggy’s ETA estimates. Therefore, we also introduce an additional metric, the Percentage of Orders with Inaccurate Bumps, to measure the percentage of orders where an inaccurate sudden jump (in both positive and negative directions) in ETA predictions was observed. An ETA prediction is considered inaccurate if its MAE exceeds a specified threshold.</p><p>However, the Percentage of Orders with Inaccurate Bumps metric only penalizes cases where an inaccurate jump occurred. In some situations, ETA may need to adjust based on new information, such as batching, a stationary DE, or higher than usual restaurant stress. In these cases, sudden jumps may be necessary for the ETA to recalibrate accurately. Therefore, we must ensure that our metrics do not penalize these necessary adjustments, and we should take these factors into account when analyzing our ETA model’s performance.</p><h3><strong>Modelling Approach</strong></h3><p>The initial modeling approach adopted was a <strong>Gradient boosting trees (GBT) </strong>algorithm with absolute loss function. The models were a big improvement in comparison to the legacy ETA framework with the Accuracy improving by ~62% and the number of inaccurate bumps decreasing by ~27%. However, even with the gains mentioned above, there were a few drawbacks of the GBT architecture. The GBT algorithm’s predictions can be considered less dynamic in nature compared to other machine learning algorithms. This is because GBT models are typically trained using decision trees, which are static models that do not adapt to changes in the data over time. Once a decision tree is built, it cannot be easily modified to incorporate new data or adjust to changing conditions. Therefore, the predictions made by GBT models may not always be as dynamic or adaptive as those made by other machine learning models, such as neural networks or recurrent neural networks. Hence, we decided to shift to a Neural Network based framework to solve the above issues.</p><p><strong>Neural Networks:</strong> Each of the four ETA models has four hidden layers, with each layer comprising neurons that utilize a Leaky ReLU activation function. The models were trained for 50 epochs using the ADAM optimizer. The input hidden layer architecture for each of the four ETA models are as follows:</p><p>ETA OR (Ordered Stage): 4 layers (32, 32, 16, 16)</p><p>ETA FM (Assigned Stage): 4 layers (24, 24, 12, 12)</p><p>ETA WT (Arrived Stage): 4 layers (16, 16, 16, 16)</p><p>ETA LM (Pickedup Stage): 4 layers (8, 8, 8, 8)</p><p>The shift from Gradient Boosting Trees (GBT) to Neural Networks resulted in a significant improvement in accuracy, with an increase of approximately 15%. Additionally, there was a reduction of approximately 12% in the percentage of orders with inaccurate bumps, while simultaneously addressing the issues associated with the GBT architecture. By utilising neural networks, we were able to improve the precision and accuracy of ETA predictions, leading to enhanced customer satisfaction and trust in Swiggy’s ETA estimates.</p><h3><strong>Model Performance</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJAGpnd2SahFV1kjpZwfrA.png" /><figcaption>ETA accuracy improvement: GBT model achieved a remarkable 62% boost compared to Legacy architecture, with an additional 15% gain through Neural Networks.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJVwBPPcgbdVUDHiwDsiWg.png" /><figcaption>Reduced percentage of orders with inaccurate bumps: GBT model decreased by 27% compared to Legacy architecture, with an additional 12% reduction via Neural Networks.</figcaption></figure><p>As a result of improved accuracy and reliability metrics in our tracking screen predictions, as shown in the graphs above, we witnessed a notable decline in customer-care agent interactions and order cancellations.</p><h3><strong>Future Improvements</strong></h3><p>The revamped ETA model architecture has significantly improved the accuracy and reduced the percentage of inaccurate bumps. However, there is still room for further improvement. In the future, the team plans to explore sequence model architectures such as RNN and LSTM, as the order journey is essentially a sequence of events. Additionally, we will investigate the use of Graph Neural Networks (GNN) to enhance the last mile (LM) stage of the order.</p><p>We are also exploring other improvements, such as incorporating intelligent features based on Point of Interests (POIs) and DE rejection probability to address long-tail events. By incorporating these enhancements, we aim to make our ETA predictions even more precise and accurate, which will ultimately lead to improved customer satisfaction and trust in Swiggy’s ETA estimates.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eae83575e3a9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swiggy-bytes/how-ml-powers-when-is-my-order-coming-part-ii-eae83575e3a9">How ML Powers — When is my order coming? — Part II</a> was originally published in <a href="https://medium.com/swiggy-bytes">Swiggy Bytes — Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How ML powers — When is my Order coming? — Part I]]></title>
            <link>https://medium.com/swiggy-bytes/how-ml-powers-when-is-my-order-coming-part-i-4ef24eae70da?source=rss-2182f3e6ac11------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ef24eae70da</guid>
            <category><![CDATA[hyperlocal-marketplace]]></category>
            <category><![CDATA[swiggy-data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[estimated-time-of-arrival]]></category>
            <dc:creator><![CDATA[Vaibhav Agarwal]]></dc:creator>
            <pubDate>Mon, 22 May 2023 06:56:24 GMT</pubDate>
            <atom:updated>2023-05-22T06:56:24.527Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Where is my order? — Part I</strong></h3><p><strong>With the blessings of technological advancements, we are able to predict Estimated Time of Arrival (aka ETA) of on-demand deliveries.</strong></p><p>As soon as we place an order on Swiggy, our eyes are glued to the tracking screen to see how far away our food is in realtime. Seeing the food getting prepared and being a short time away has a feeling of excitement. However, this is not the case when the food gets delayed and is a fair time away. We usually reach out to the customer care executives to find out the whereabouts of our order. This results in a not so great customer experience and also increases the operation costs borne. Consumer research suggests that customers usually anchor themselves to the <strong>Estimated Time of Arrival (aka </strong>ETA) shown on the tracking screen when they perceive whether the order is delayed or on time. Hence, the ETA shown on the tracking screen becomes an important input for customers to evaluate our delivery experience and also shapes how often the customer decides to reach out to us via chat or call and/or decides to cancel the order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KwDTa1fThtl-2t9Dusnygg.png" /><figcaption>The revamped Swiggy Track Screen powered by ML based predictions</figcaption></figure><p>In this blog, we are going to discuss the data science models and their architectures that powers the ETA model for food delivery in Swiggy in the backend.</p><p>The Data Science team at Swiggy built an ML powered ETA service that works with real-time on-ground signals from assignment strategy, restaurant stress, delivery executive location pings and provides the most accurate &amp; smooth post-order time estimates to our customers.</p><h3>ETA Model Architecture</h3><p>The ETA architecture is a combination of 4 different models for the corresponding four different legs in the order journey with the predictions being refreshed at fixed time intervals, allowing the model to consume all the latest information available. The four order legs are- <strong>O2A (Ordered to Assignment), FM (First Mile) , WT (Wait time) &amp; LM (Last mile)</strong>. The diagram below depicts a summary of a typical order’s journey at Swiggy. You can learn more about the order journey via this <a href="https://bytes.swiggy.com/the-swiggy-delivery-challenge-part-one-6a2abb4f82f6">blog</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7kNPFivN2PY4UJ6jrLZrQ.gif" /><figcaption>Summary of a typical order’s journey at Swiggy</figcaption></figure><p>The tracking screen ETA model is built on top of the Service Level Agreement (SLA) promise prediction shown to the customer at cart and improves on that by incorporating real time signals as the order progresses through its journey. These are additional real-time signals beyond what is considered for cart predictions. A order at any point of time can be in any one of the following stages:</p><ol><li><strong>Ordered Stage (ETA OR):</strong> Time period since the order is placed on Swiggy till it is assigned to a Delivery Executive (DE).</li><li><strong>Assigned Stage (ETA FM):</strong> Time period between assignment of an order and the DE’s arrival at the restaurant or the First Mile (FM) time.</li><li><strong>Arrived / Wait Stage (ETA WT):</strong> DE’s Wait Time (WT) at the restaurant to pick up the order.</li><li><strong>PickedUp Stage (ETA LM):</strong> Picked Up to Delivered time or the Last Mile time.</li></ol><p>The choice to go with 4 different models for tracking screen ETA stems from the fact that the model feature space varies for the different stages of an order. The underlying hypothesis behind the same is that different inputs impact an order’s progress at different stages — for example, when a DE is not assigned to an order, model makes use of network and assignment features to provide an accurate prediction , whereas when the order is picked up, the model uses DE’s pings and the corresponding speed/distance features derived from it. Hence, to improve the overall accuracy of the ETA these features need to be used in isolation in four different models.</p><h3><strong>ETA Ordered Stage</strong></h3><p>The ETA Ordered Stage model is called when the order is received by Swiggy till it is assigned to a DE. The block diagram below explains the features consumed by the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BaPUuuYdIria7kEHmjSmQw.png" /><figcaption>ETA Ordered Stage — Feature Block Diagram</figcaption></figure><p>The ETA OR model is built on top of the SLA prediction provided to the customer at cart where a selection of restaurant and item has been made by the customer and a final cart page is created with billing information. The model consumes food preparation &amp; travel time predictions made at cart along with network features like number of DEs available, their average distance from the restaurant to come up with an accurate prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZCxM6LfAEXWapLVRK2sl2Q.png" /><figcaption>The hyperlocal distribution of DEs around the restaurant plays a pivotal in ETA predictions</figcaption></figure><p>If the number of Delivery Executives (DEs) in the vicinity of the restaurant are high as above, the model would adjust accordingly and provide a lower prediction value as compared to if there was a scarcity of it.</p><p>The model also utilizes other realtime features like system &amp; restaurant stress, time elapsed to enhance the predictions further. Rare cases like rain &amp; possibility of rejections by delivery executives are also provided as inputs to the model to deal with long tail cases.</p><h3>ETA Assigned Stage</h3><p>The ETA Assigned Stage model is called during the time period from DE’s assignment of the order to the DE’s arrival at the restaurant. The model uses real-time DE pings and features built on top of it to come up with an accurate ETA estimate. The block diagram below explains the features consumed by the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vMUgoEQ0fsiKja8gxkgA4g.png" /><figcaption>ETA Assigned Stage — Feature Block Diagram</figcaption></figure><p>The ETA assigned stage model is the next stage of the ETA after the ordered stage. Similar to the ordered stage, it is built on top of the SLA prediction provided at cart. However, since a DE is assigned to the order at this stage, all travel time predictions have a DE component to it making them more accurate. Information on how familiar the DE is with the restaurant and customer locations, his/her mode of transportation (bike/bicycle/others) and historic trends are used to improve on the existing predictions. These leg-wise predictions along with features engineered using realtime DE pings like current speed, global speed, distance traveled combine to provide an accurate prediction. More details about the ping features are discussed in the second part of the blog where we discuss the LM stage in detail. The model also inputs realtime features like RX confirm flag, stress at the restaurant to enhance the predictions further.</p><p>There might be cases wherein you see an ETA of 37 mins changing into 25 mins post the assignment of a DE. These cases are generally when the assignment of DE happens earlier than previously expected (example- a DE just logged in for their shift).</p><h3>ETA WT Model</h3><p>The WT Stage of the model is called when the DE’s waiting at the restaurant to pick up the order. The block diagram below explains the features consumed by the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IZESdlTDfVHs4Y180H14KQ.png" /><figcaption>ETA Arrived Stage — Feature Block Diagram</figcaption></figure><p>The predictions from ETA WT are built on the leg-wise predictions of WT &amp; LM. Real time features like restaurant stress, live order count at the restaurant and item count is also used by the model. Features like time elapsed since food preparation started and time elapsed in the wait leg are introduced in order to make the predictions more complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*epoRQ7WeQK606NHcBojd8A.png" /><figcaption>Difference in stress levels between weekend dinner slots and weekday snack slots at a restaurant is an important factor for ETA predictions</figcaption></figure><p>The model also takes into account stress at the restaurant which is of paramount importance. During weekend dinner slots, the restaurants are at a higher than usual stress and even a small new order might take high preparation times due to kitchen stress. In comparison, weekday snacks slots are generally stress free as depicted in the illustration above. The model understands these patterns and provides an accurate prediction taking all the ground realities into account.</p><p>In this blog we discussed how we built a machine learning-powered ETA service — combination of four different models corresponding to different legs in the order journey, which refresh their predictions at fixed time intervals. The service is built on top of the Service Level Agreement (SLA) promise prediction shown to customers at the cart and improves on that by incorporating real-time signals as the order progresses through its journey. We discussed three of the four stages of the model in detail. We will return with a follow-up blog post that delves into the last stage of the ETA architecture along with the evaluation metrics and impact of the solution, as the blog is incomplete without discussing these crucial aspects. We will also discuss the future improvements that are planned to enhance the accuracy of ETA estimates even further.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ef24eae70da" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swiggy-bytes/how-ml-powers-when-is-my-order-coming-part-i-4ef24eae70da">How ML powers — When is my Order coming? — Part I</a> was originally published in <a href="https://medium.com/swiggy-bytes">Swiggy Bytes — Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>