Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Order to Delivery (OTD) Time Forecasting

Order to Delivery (OTD) Time Forecasting

  • Ease of e-commerce over the last decade, along with the recent COVID-19 pandemic, has seen a marked shift in consumer behavior and expectations when it comes to purchase - and more importantly, the delivery of goods. This has caused a paradigm shift in functioning of the supply chain. Along with delivery speed, consumers feel that the transparency around delivery time and shipment status are an equally important aspect of the fulfilment process. This has direct implications in customer churn/retention. More than half of consumers are less likely to shop with a retailer if the item is not delivered within 2 days of date promised. (source)

Order to Delivery Time Forecasting as a Supply Chain Optimization Usecase:

OTD forecasting is a key aspect of supply chain optimization as it helps to ensure that customers receive their products in a timely manner, it enables companies to make informed decisions about inventory, logistics and production which in turn helps to improve the overall efficiency of the supply chain.

AI Project Cycle AI_Project_Cycle.png

Context: Understanding the Problem Statement --------Problem Scoping (AI Project Cycle - Step 1)

An ML based predictive solution for providing delivery time forecasting

  • An ML based predictive solution for providing delivery time forecasting can provide great insights to e-commerce platforms. From a customer-facing point of view these insights would help e-commerce platforms to give more accurate delivery forecasts to customers and decrease customer churn. In addition, the ML based predictive solution will also allow e-commerce platforms to take pre-emptive actions to mitigate delays, costs, and loss of revenue.

  • For the individual components of the ensemble model, we will use XGB, RF and SVM. These components will then be fed to a Voting Model, which is an ensemble model that combines the individual predictions to provide a final, consensus prediction. The final consensus prediction can be (1) a prediction for a wait time for a package and (2) if a delay will occur.

e2e-flow_stock

Import the useful Packages & Libraries

To know more about math click here

To know more about pandas click here

To know more about Sklearn’ Preprocessing package click here

To know more about time click here

To know more about numpy click here

Dataset: Data Acquisition (AI Project Cycle - Step 2)

Dataset downloading steps

DataSet: https://www.kaggle.com/datasets/olistbr/brazilian-ecommerce

“brazilian-ecommerce.zip” will get downloaded in the current data folder folderd
In the data folder execute the following command to unzip (Note: You may need to install unzip using: sudo apt-get install unzip) unzip brazilian-ecommerce.zip

Source - Before we delve into the proposed architecture of the solution pipeline, it is critical to understand the dataset and its schema. The dataset consists of real-world delivery details sourced from a Brazilian E-commerce Company which was scrubbed and anonymized. It can be found here.

It consists of multiple tables which include relevant information about the customer, seller, order, location etc. The individual tables are interconnected as shown in the following schema. Relevant features will be extracted/designed from this data and then be used to train our supervised ML model.

dataset-schema

Load/Read the Dataset

View the data

From a business perspective, we need to tackle two main challenges to ensure transparency for the customer:

  1. Extracting insights/estimates into forecasted delivery

  2. Increasing the accuracy of those insights and estimates

We can achieve the first objective by implementing multiple pipelines with separate objectives and the second one by utilizing techniques such as ensemble modeling to increase the accuracy of stand-alone ML components.

**A schematic of the proposed reference architecture is shown in the following figure. We start off with Data Ingestion from the multiple tables of the dataset, followed by merging and preprocessing for feature extraction. We can use the features to extract delivery insights in the form of predicted wait time as well as likelihood of delivery delay.

The former is a regression problem and the latter is a classification problem.

Data Preprocessing ------ Data Exploration(AI Project Cycle - Step 3)

View the information of data

Merge/Clean Data

To know more about how pandas dataframe merge function works click here

Find the total number of missing values feature wise

Scaling the data

Splitting dataset into separate training and test set