May 18, 2023

FOOD DELIVERY TIME PREDICTION

Predicting the delivery time of food is a critical aspect of the restaurant and food delivery industry. It involves accurately forecasting the time it will take for an ordered meal to be delivered to the customer, taking into account various factors such as food preparation, distance, and traffic conditions.

This forecasting task presents unique challenges due to the dynamic nature of the restaurant industry, where many external factors can influence delivery time, such as order volume, unexpected delays, or weather conditions.

To achieve accurate predictions, it is necessary to collect and analyze relevant data, such as food preparation schedules, historical travel times, location data, and weather data. By using advanced modeling techniques such as linear regression, time series methods, or machine learning algorithms, predictive models can be created to estimate delivery time with a certain level of accuracy.

Predicting food delivery time offers several benefits for restaurants and delivery services. It enhances the customer experience by providing more accurate estimations, reducing wait times and frustration. Additionally, it helps establishments optimize their operations by adjusting food preparation and delivery logistics planning to improve efficiency and minimize delays.

In summary, predicting food delivery time is a growing field that aims to enhance efficiency and customer satisfaction in the restaurant and food delivery industry. By leveraging data and appropriate modeling techniques, reliable estimates of delivery time can be obtained, contributing to an overall better experience for customers and businesses in the sector.

To predict the time of food delivery in real time, we need to compute the distance from the point of food preparation to the point of food consumption and find relationships between the time taken by delivery partners to deliver food in the past for the same distance.

1- I will start this task by importing the necessary Python libraries and the dataset:

2- Let's explore our dataset:

The dataset does not have any null values.

3- We create new feature:

With the latitude and longitude points of the restaurant and the delivery location, we can calculate the distance between these two locations using the Haversine formula.

a new feature has been added to the dataset as distance. Let's look at the dataset again:

4-Visualisation:

we will examine the relationship between the distance and the time needed to deliver the food:

Most delivery partners deliver food within 25 to 30 minutes, so there is a consistent relationship between the time taken and the distance traveled to deliver the food.

Is there a relationship between the time it takes to deliver the food and the age of the delivery partner?

Younger delivery partners take less time to deliver food than older partners, suggesting a linear relationship between time to deliver food and delivery partner age.

Is there a relationship between the time it takes to deliver the food and the delivery partner's ratings?

Delivery partners with higher ratings take less time to deliver food compared to partners with lower ratings, resulting in an inverse linear relationship between the time to deliver food and delivery partner ratings.

Now let’s have a look if the type of food ordered by the customer and the type of vehicle used by the delivery partner affects the delivery time or not:

The difference between the time taken by delivery partners depending on the vehicle they drive and the type of food they deliver is not very significant.

We focus on the characteristics that contribute the most to food delivery time, which are: Age of delivery partner, Rating of delivery partner and Distance from the restaurant to the delivery location

5- Using LSTM neural network Model:

We choose to Train the LSTM neural network model for the food delivery time prediction task:

Now let’s test the performance of our model by giving inputs to predict the food delivery time:

Then for a 25 years old deliveryman who travels a Distance of 4 kilometers and who has the note 6 as ratings put 17 min to deliver his order.