We keep hearing about artificial intelligence disrupting many industries. Here at Radiostudio, we have addressed a few use cases related to agriculture and kitchen inventory in the past. So why not take a step further and explore some related industry use case for AI in food and beverages. Let's take a dig at a typical fast-food chain and see how we can leverage artificial intelligence in the food industry.     


The Scope of AI in Food & Beverages

F&B industry is probably one of the most immature sectors when it comes to harnessing data. Mostly, due to the very nature of the business where the order placed by a customer sitting at the table takes paramount priority. However, there is one thing that generates enormous data, the PoS or billing machine.

Data extracted from the billing machine can usually tell us about the revenues generated, orders placed, and the items ordered, within a period. Let's assume that we manage to extract this data. Then the next obvious questions will be this.

What Can We Do With This Data?

Before we answer this question, please spare a few minutes to read this narrative below, about a person named Lorenzo.

Here is this guy from Italy who runs a fast food restaurant serving pizzas. Meet Lorenzo.  Lorenzo is obsessed with quality and customer centricity and hence wants to adopt an approach that can help him to source the best quality raw materials just in time so that he can continue to serve his customers without loss of loyalty or business.

Lorenzo sells some of the most sought-after flavors of pizzas. The most popular of them is the Margherita Pizza.  It requires some exotic and authentic ingredients like the Mozzarella Bufala Cheese. Lorenzo wants to make sure that his raw material supply chain is functioning at an optimal level and he wishes to automate this system as per business demand.

Predicting business demand is the number one wish for any business owner. In the F&B industry, this is imperative as the business owners have to deal with perishable raw material and unreliable supply regularly.

So, if we have the historical billing data then whats stopping us from predicting the future demand? By employing the techniques of machine learning, we can do so.

Read on to know how can we fulfill Lorenzo's desire to have a technology backed, automated supply chain.

Simplifying The Problem Statement for AI In Restaurants

Let's dissect the problem statement for Lorenzo. 

We need to first simplify it as per specific objectives that directly impact his business. 

Business Objective

To serve the customers without running out of the raw material stock during the business hours, 9 AM to 9 PM.

Quality Objective

To stock up the perishable food/raw material for not more than one day, to preserve their freshness.

 We also need to add in Loranzo's business constraints.

Supply Constraints

  • Supplies will be delivered after 3 hours of placing the order
  • Supplies ordered after 5 PM will be delivered on the next day morning

Keeping in mind the objectives, we can conclude that Lorenzo wants to make sure that he is always stocked up with fresh supplies so that he never disappoints his customers. In this case, we are talking about Mozzarella cheese which is the main ingredient and is a perishable item.

However, Lorenzo also needs to keep an eye of his supply constraints. In the midst of daily juggle between managing the kitchen and customer expectations, keeping an eye on the supply constraints puts a cognitive overload on Lorenzo's mind, and this can pretty soon become a burden for him.

What Lorenzo needs is an AI-driven system that keeps a tab on his inventory and can continually predict his supply requirements. Needless to say,  the system should be intelligent such that it meets his objectives as well as constraints. 

We can imagine a system comprising of weighing scales attached to a storage container that contains the raw materials.  The system also digs out the historical sales data from the billing machine. These two data streams provide all the intelligence for Lorenzo to automate his supply ordering workflow. 

Solution Approach

In essence, we are streamlining the supply tracking and ordering workflow for restaurant owners like Lorenzo. Apart from that, we are also bringing in intelligence into the workflow for recommending optimum order quantity for the essential items.

We can define the use case steps for this system as follows.

  • 1
    The system takes the weight on the inventory at the beginning of the day 
  • 2
    The system starts monitoring the depletion of weight
  • 3
    The system predicts the threshold inventory level as per supply constraint 
  • 4
    Based on prediction, the system sends notification for placing an order within the supply constraint 
  • 5
    The system recommends the optimum order quantity to be supplied as per the quality objective 

As the kitchen staff scoops out Mozzarella Cheese from storage container for every Margherita pizza, the system springs into action.

The Technology Behind Kitchen Inventory Tracking

Looking for the tech that drives real-time tracking of kitchen storage containers? 

Lorenzo can now peacefully focus on serving his customer without having to worry about 

1. How long will the supply last? , and

2. How much quantity to order?

The Restaurant Data For Automating Supply Workflow

Let's look at a sample data-set that can make this work. Assuming that we can extract the number of pizzas sold each day for the last two years, we can frame it as a simple two column data-set, containing the date and the count of sale. 

To demonstrate this use case, we have generated this dataset as a CSV file.

We also need the real-time data of stock consumption while the restaurant is serving the customers. Based on the supply constraints that we have examined earlier, there are three workflow scenarios.

  • 1
    The stock will last almost till the end of the day - Can order after 5 PM
  • 2
    The stock will not last till the end of the day - Need to order before 5 PM 
  • 3
    The stock will be surplus at the end of the day - There is no need to order today 

Here is a snapshot of the consumption data (in weight, kgs) for all the three scenarios

Scenario 1 - Order After 5PM

Scenario 2 - Order Before 5PM

Scenario 3 - Do Not Order

As you can see, this is an hourly snapshot, which captures the weight of storage container from 11 am to 4 pm. The assumption is that every hour the system senses the weight of the Mozzarella cheese & predicts to check the possibility for one of the three scenarios. Since the supply ordering cut off time is 5 PM, the system has to decide before that time.

Just by looking at these graphs it may not be evident how to conclude on the ordering. In the next section, we will see how can we achieve this. 

Solution Implementation

From the end user's point of view, the crux of the solution boils down to 

  • 1
    Sending Notification : Predicting whether the supply will last for the entire day, and notifying if it does not.
  • 2
    Suggesting Recommendation : Finding the recommended order quantity for the supply such that it lasts a day.

Before we go any further, we need to perform yet another simplification of the problem.

The quality objective and supply constraints defined earlier are only applicable to perishable, high-value raw material. Since we are talking about Margarita pizza, Mozzarella cheese is the only thing that needs to go through this automated AI based workflow. Also, given the fact that the pizzas are sold in standard sizes, we can easily derive the order quantity of Mozzarella cheese if we know how many pizzas are going to be sold during a given day.

With this knowledge and considering the use case, we are ready to dive into the solution.

Sending Notification For Automated Ordering  

For notification, we need to figure out a way to measure the rate of depletion of Mozzarella cheese.

We can employ a simple linear regression model to predict the remaining quantity of Mozzarella cheese at 9 PM which is the closing time for the restaurant.

For this, we have to start tracking the consumption data as per the graphs shown above and keep plotting the linear regressing model of the left over quantity (in kgs) during the day. Based on the three possible outcome scenarios of the workflow, the regression lines might appear somewhat like this.

Scenario 1 - Order After 5PM

Scenario 2 - Order Before 5PM

Scenario 3 - Do Not Order

The red dot that you see is the prediction at 9 PM based on the regression line. This tells us how much of the Mozzarella cheese will be left at the restaurant closing time. Now it is easy to decide when to send the notification for placing orders.

Suggesting Recommended Order Quantity

For forecasting the order quantity, we have chosen the ARIMA model. Since our data-set is a form of time series data containing the dates and the pizza sales number, ARIMA model is a good fit for such data.

An ARIMA model predicts future values of a time series data by a linear combination of its past values, based on three parameters p, q, and d. Each of them represents one of the three components of the model, namely the AR (Auto-Regressive), I (Integrated) and MA (Moving Average).

By combining the three parameters, the ARIMA model can be tuned to extrapolate future points of the time series.

In this case, we will use it to extrapolate the sales figure of Margarita pizza for the next day. So from that, we can easily derive the amount of Mozzarella cheese to be ordered.

If we run the entire sales data through the ARIMA model, here is how the forecast looks like.


This is the ARIMA generated sales forecast from the beginning. If you compare it with the actual historical sales data plotted earlier, you might notice that the predictions get better towards the end , where the historical time series data builds up.  

Use Case Demonstration

It's time to do a quick demo. If you want to explore the technical solution, then head over to the GitHub repository. 

Demo Artifacts Available under GitHub


Read the README file to setup, understand and run the demonstration code

Source Code

Check out the source file that implement this use case and validate the results

Data Files

Make use of the sample data files representing the scenario based weight data and historical sales data=set used in this demonstration

The code simulates the typical workflow as per the use case steps described earlier, except that the weight data of inventory is pre-populated through data files. Also, since we have three workflow scenarios, there are three variants of the weight data file. Here is the output that we get when we run the code for the three scenarios through an IPython console.

Scenario 1 - Order After 5PM

Scenario 2 - Order Before 5 PM

The outcome of scenario 1 and 2 is the same. The only difference is the notification time, which varies based on the rate of stock depletion during the day. The recommended order quantity for Mozzarella Cheese is shown as 12.14 Kgs. This value is derived from the forecasted sale quantity of Margherita Pizza, assuming that one pizza takes in 50 Gms of Mozzarella Cheese.

Does This Really Work?

That's the million dollar question.

There are proven ways to find the accuracy of the ARIMA model. By varying the three parameters of the model, namely the p (lag order), d (degree of differencing) and q (order of moving average), we can calculate the MSE (Mean Square Error) of the model. Combining this with the AIC (Akaike Information Criteria) value, which is a measure of the accuracy of the model, we can find out the best fit model.

By executing the model with all the permutations of p,d & q, it was observed that the lowest MSE was 30.23 for the ARIMA model (6,2,0) with AIC value 5456.69 and highest MSE was 43.86 for the ARIMA model (1,2,0) with AIC value 5774.75.

ARIMA Model with Maximum AIC Value

ARIMA Model with Minimum AIC Value

You can check out the README file to understand how to run the model test programs to generate the above metrics.   

Indeed, this is quite a simplistic assumption. Unless it is tested through the iterative process of cross-validation, we cannot deploy it for a real-world application. We must also note that there are seasonal variations in restaurant sales which have to be addressed. ARIMA has one more variant called the seasonal ARIMA, which takes more parameters to induce the seasonal effects. So if we have to make this use case to the next level, then Seasonal ARIMA would be the logical choice.

Extending Beyond Restaurant Inventory

Well, if you have followed this post this far then, you can undoubtedly frame up this problem as a generic inventory management use case. Most brick and mortar businesses have to maintain some inventory to run their businesses effectively. So this approach can help them automate their inventory ordering and monitoring workflows.

Let us know what you think about this idea. We would love to get some feedback from real businesses that might want to leverage AI and ML to manage their inventory chores to boost productivity and reduce wastage.

Code Contributions

The technical demo & source code for this blog post are contributed by Aavritti Soni & Annukriti Soni

About the author 

Shyam Purkayastha

Shyam is the Creator-in-Chief at RadioStudio. He is a technology buff and is passionate about bringing forth emerging technologies to showcase their true potential to the world. Shyam guides the team at RadioStudio, a bunch of technoholiks, to imagine, conceptualize and build ideas around emerging trends in information and communication technologies.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
TechForCXO Weekly Newsletter
TechForCXO Weekly Newsletter

TechForCXO - Our Newsletter Delivering Technology Use Case Insights Every Two Weeks