A Machine Learning Approach To Waiting Time Prediction in Queueing Scenarios

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

2019 Second International Conference on Artificial Intelligence for Industries (AI4I)

A Machine Learning Approach to Waiting Time


Prediction in Queueing Scenarios
Athanasios I. Kyritsis and Michel Deriaz
Information Science Institute, GSEM/CUI
University of Geneva
Geneva, Switzerland
Email: {athanasios.kyritsis, michel.deriaz}@unige.ch

Abstract—Physically queueing is a reality on many industries Queueing optimization techniques are used in several in-
that provide services or sell goods. Waiting in a queue can be dustries to improve customer service. In the healthcare sector,
stressful and exhausting for the clients because of the enforced queueing models are used to improve resource utilization in
idle time, and may lead to decreased customer satisfaction.
Queueing theory has been widely used to assess client waiting hospitals [5], and to handle the tradeoffs that will improve
times, to optimize staff schedules, and to increase the robustness the efficiency and the quality of the provided services of
of a queueing system against a variable demand for service. healthcare systems [4]. In pharmacies with high workloads
In this paper, we are exploring how multiple industries that or multiple points of service, queueing models can assess
require queues can benefit from machine learning to predict service and waiting times [6]. In airports, queue planning
the clients’ waiting times. We begin by predicting waiting times
on bank queues, and then we propose how the procedure can is necessary for security controls and the check-in process
be generalized to more industries and automatized. A publicly [7]. Queueing lines can also be observed in everyday life
available dataset containing entries of people queueing in banks activities, such as paying at groceries, waiting for a table at a
is initially utilized, and after training a fully connected neural restaurant, or waiting to order at a fast-food restaurant. While
network, a mean absolute error of 3.35 minutes in predicting research has shown that longer waiting times may sometimes
client waiting times was achieved. We are then presenting a
web application that is managing queues of different scenarios lead to higher consumption in some cases [8], most queueing
and industries. The queues may have unique parameters, and scenarios would benefit from queue management to reduce
the system can adapt to each queue as it creates a per queue the cost on the used resources, in terms of personnel cost and
optimally trained neural network for waiting time prediction. consumer waiting times.
The use and the capabilities of the system are validated with the Queueing theory attempts to study the waiting lines through
use of a simulator. Machine learning, therefore, proves to be a
viable alternative to queueing theory for predicting waiting time. mathematical analysis. The earliest studied problems in this
domain concerned the congestion of telephone traffic and were
Keywords—Machine learning, pattern recognition, queue sys- investigated by the mathematician A. K. Erlang [9]. A queue
tem, queueing analysis, web application. can be modeled as a First-In First-Out (FIFO) node in which
clients arrive, possibly wait for some time, and take some
time to be processed by the server before they depart from
I. I NTRODUCTION AND R ELATED W ORK the queue [10]. The Kendall’s notation [11] is typically used
to describe a queueing node in the form of A/S/c, where A is
Queueing problems exist when multiple people need access the probability distribution of durations between each arrival
to a resource, and the service cannot match the level of to the queue, S the probability distribution of service times and
demand. On the one hand, queueing is a necessary evil when c the number of servers at the node. Using queueing theory,
accessing valuable resources like health-related ones, as the queue managers aim to balance a queueing system’s service
idle time of those resources is expensive [1]. On the other to customers by keeping the queues short and thus the waiting
hand, queues may get unnecessary big even for this purpose times low (that might mean an increased number of servers),
and may lead to long idle times for the customers. Time is and the economic upkeep of the system (that would mean to
a valuable resource, and consumers have to make decisions keep the number of servers low). By constructing a queueing
regarding the use of it when purchasing services or goods [2]. model, the waiting time for any client, and the queue length
The idea that ”time is money” has a long history, and the at any time can be predicted.
earliest recorded version has been attributed to Antiphon of Machine learning techniques and simulation models can
ancient Greece (ca. 430 BC) [3]. There is also a link between also be of use to deal with queueing problems. An im-
long waiting times and customer dissatisfaction [4], and thus, provement to the prediction of the overall waiting time for
industries should strive for better resource allocation that will daily radiation treatment appointments, when compared to
optimize waiting queues. the rough estimates that are typically given to patients, was
achieved by a regression model used in an oncology de-
This work was co-financed by Innosuisse. partment [12]. Machine learning was also used in another

978-1-7281-4087-2/19/$31.00 ©2019 IEEE 17


DOI 10.1109/AI4I46381.2019.00013
study to predict patient waiting and facility delay times for
radiology examinations [13]. Simulations can also be used
to model queueing problems [14]. By simulating different
distributions for client arrival and service times, as well as
a variable number of available servers, it is possible to predict
the expected performance of a queue system and to optimize
it for specific scenarios.
Several enterprise queue management solutions offer busi-
nesses the tools to manage queues, and thus reduce waiting
times and improve service efficiency. To the best of our
knowledge, there is currently no generic queueing system,
where anybody can set up a queue that anyone can join. We
are proposing QueueForMe, a system with which anyone can
register as a creator and open a queue by defining an initial set
of parameters unique to that queue, along with the response
options for those parameters. Such a parameter could be the Fig. 1. Histogram of the customer waiting time in minutes.
number of luggage for the scenario of a queue for checking
in at the airport, for example. Each client that joins the queue
responds to all the necessary parameters, and the expected deviation of 5.95 minutes. The histogram of the waiting time
waiting time for the client is inferred using machine learning. values of the dataset is presented in Fig. 1.
The machine learning model is taking into account the time 2) Data Preprocessing and Feature Engineering: From the
the client joined the queue, the position of the client in the given dataset, for each client, we have calculated the number
queue, the number of available servers for the queue, as well of people waiting in the queue at the time the client joined
as the responses of the client to the aforementioned additional the queue. To do so, we have calculated the queue departure
parameters. The model is continuously adapting to potential time for each client by adding the waiting time to the arrival
changes in queue patterns by using data from past clients. time, and then we counted the number of people that were yet
The rest of the paper is organized as follows. In Section to depart from the queue at the time a new client joined the
II, we are presenting a neural network-based waiting time queue. Fig. 2 presents the histogram of the number of people
predicting solution for the scenario of clients waiting to be waiting in the queue.
served in a bank. We are then proposing our generic queueing From the timestamp that the client joined the queue, we
system in Chapter III that can be used in various industries extracted 3 features; the day of the week (ranging from 0 to
and can exploit queue specific parameters when predicting the 4, for Monday to Friday), the hour (ranging from 8 to 14), and
estimated waiting time of the clients. We validate the learning the minutes (ranging from 0 to 59). We used mean encoding,
capabilities of the queueing system with a simulator we have also known as target encoding, to encode new features from
built. Finally, we conclude our work in Section IV. those 3 existing categorical features and the target variable.
The idea of mean encoding for a regression task is simple.
II. WAITING T IME P REDICTION IN A BANK S CENARIO Let x be a categorical variable and y a target variable. For
each distinct element in x we are computing the mean of the
1) Dataset: In order to lay the basis for how machine corresponding values in y. Then each entry of xi in the feature
learning can be utilized to predict waiting times of new clients vector is replaced with the corresponding mean.
joining a queue, we are using a dataset published by Bishop In total, we are using 4 features as the input for modeling,
et al. [15]. This dataset includes information regarding queues the people waiting in the queue, the day of the week, the hour,
formed and served in 3 banks in Ogun State, Nigeria, over a and the minutes, and the waiting time variable as mentioned
period of 4 weeks. In total, 52444 clients are reported, and above forms the output.
each entry includes the time the client joined the queue, the 3) Experimental Setup: For the machine learning experi-
waiting time, the service time, and the total time in the system ment presented in this study, we have used Python 3.7.3 and
(waiting time + service time). Unfortunately, the number of Tensorflow 2.0.0-beta1. To evaluate the performance of our
servers is not reported in the dataset. It is evident from the system, we split the available dataset into a training set (80%)
throughput of the system that the number of servers is greater and a test set (20%), keeping the test set completely unseen
than zero for every case, but it is unknown if it was a constant during the training phase. We have decided to use a neural
number throughout the days. network over other machine learning models because of the
There are no missing values in the dataset. The waiting time continuous training capabilities of a neural network. When
variable represents the amount of time in minutes each user a new batch of training data is gathered, an existing neural
had to wait in the queue before being served and is the output network can be trained solely on those, and there is no need
variable that our machine learning model is trained to predict. to train on all available training data regularly. This is ideal
It has a mean value of 13.18, a median of 12, and a standard for a queue management system, as new data are consistently

18
Fig. 2. Histogram of the people waiting in the queue.

being produced.
4) Results: We have trained a fully connected neural net-
work with 2 hidden layers, the first with 12 neurons and the
second with 8 ones. We have used the Rectified Linear Unit
(ReLU) [16] as the activation function of all hidden layers,
and the Adam optimization algorithm [17] for the iterative Fig. 3. Views of the QueueforMe web application when (a) the creator is
update of the network weights based on the training data. An creating a new queue, (b) the client has just joined a queue, (c) the creator is
serving a new client, and (d) the client is being served by the creator.
exhaustive tuning of all related hyperparameters is out of the
scope of this paper, and commonly used default values for the
architecture of the neural network were used. for a queue by queue name or by the creator’s name, and
After 500 epochs of training, a mean absolute error of 3.35 can finally join the queue. After joining the queue, the client
minutes was achieved on the test set. To have an estimation is getting information about the queue including the position
of the predictive capability of the trained model, we are in the queue along with an estimated waiting time predicted
comparing against the naive mean and the naive median by a neural network trained for the specific queue using past
model; these are the models that always predict the mean queue data. The creator can operate the queue by asking for
and the median waiting time of the training set. The naive the next available client in the queue, and the corresponding
mean model had a mean absolute error of 4.71 minutes on client is getting a notification to be served. Screenshots of the
the test set, and the naive median an error of 4.59 minutes. QueueForMe web application can be seen in Fig. 3.
Our model has, therefore, achieved an improvement of 28.9% 2) Additional Queue Parameters: In a future version of
over the naive mean model and 27% over the naive median QueueForMe, the creator of a queue will have the option
one. Unfortunately, since there is no information regarding to define a set of queue specific parameters along with the
the deployed servers, we can not compare the predictive restricted set of responses for each parameter. Clients joining
performance of our model with one produced by queueing the queue will have to give a response to each of the defined
theory. parameters. These additional parameters set our solution apart
In order to make our research reproducible, we are sharing since such customizable additional parameters do not exist
the code that we used for the tests of the current study here in queueing theory, in a manner that can be automatically
(https://doi.org/10.5281/zenodo.3378407). The dataset used in exploitable. The corresponding neural network of each specific
this analysis is available here (https://doi.org/10.1016/j.dib. queue will be able to extract more valuable information and
2018.05.101). detect patterns among those parameters.
3) Simulator: To verify the learning capabilities of each
III. P ROPOSING A G ENERIC Q UEUEING S YSTEM neural network that is created with every queue, we have
1) QueueForMe: We are proposing QueueForMe, a web developed a simulator with which we can simulate customers
application that allows everyone to create a virtual queue joining a queue over a specific period of time. In our tool,
allowing clients around to join. QueueForMe includes two we can select the distribution at which new clients join the
types of users, the creators, and the clients. The creators are queue, the number of available lines and the distribution of
the ones that need to log in to our platform in order to create a the service time. A queue specific neural network is then
queue by providing a queue name and a description. A client retrained learning from the provided simulated customers that
does not need any credentials for the platform, can search have passed from the queue. The trained model is also saving
statistics regarding its predictive performance. Screenshots of

19
(a) (b) (c) (d)

Fig. 4. Views of the simulator web application (a) setting global queue parameters with the customer arrival distribution, (b) setting the number of open
lines and the service time distribution, (c) displaying the average statistics for the simulated dataset and starting a simulation, and (d) getting the error of the
corresponding neural network.

the simulator can be seen in Fig. 4. neural network of each queue, and different distributions of
4) Industry Specific Queue Simulation: In a future version each parameter response can be simulated using the simulator.
of the simulator we will also include the queue specific addi-
tional parameters as described above. Each queue will have a
R EFERENCES
predefined set of parameters, and each parameter will have a
set of valid responses. Using the simulator, the operator will [1] D. Worthington, “Queueing models for hospital waiting lists,” Journal
be able to simulate different distributions for each response to of the Operational Research Society, vol. 38, no. 5, pp. 413–422, 1987.
each parameter. New features fed to the neural network will [2] C. Mogilner, H. E. Hershfield, and J. Aaker, “Rethinking time: Implica-
be engineered by aggregating the parameter responses of all tions for well-being,” Consumer Psychology Review, vol. 1, no. 1, pp.
41–53, 2018.
previous queuers in relation to a current queuer. [3] B. Perrin, Plutarch’s Lives, ser. Loeb classical library. W. Heinemann,
1920, no. v. 9. [Online]. Available: https://books.google.ch/books?id=
IV. C ONCLUSION bSJgAAAAMAAJ
[4] A. Komashie, A. Mousavi, P. J. Clarkson, and T. Young, “An integrated
In this paper, we have explored how machine learning can model of patient and staff satisfaction using queuing theory,” IEEE
be used for predicting the waiting time of people queueing in journal of translational engineering in health and medicine, vol. 3, pp.
1–10, 2015.
lines. We have started by using a publicly available dataset [5] S. Belciug and F. Gorunescu, “Improving hospital bed occupancy
of queues in banks, and by training a neural network, we and resource utilization through queuing modeling and evolutionary
achieved a mean absolute error of 3.35 minutes, improving computation,” Journal of biomedical informatics, vol. 53, pp. 261–269,
2015.
over the performances of naive models. Unfortunately, we
[6] R. A. Nosek Jr and J. P. Wilson, “Queuing theory and customer satis-
could not directly compare against queueing theory because faction: a review of terminology, trends, and applications to pharmacy
the dataset lacked information about the deployed servers. practice,” Hospital pharmacy, vol. 36, no. 3, pp. 275–279, 2001.
After presenting a specific case on how machine learning can [7] R. De Neufville, L. Budd, and S. Ison, “Airport systems planning
and design,” Air transport management: An international perspective,
be used to predict waiting times in queueing scenarios, we vol. 61, 2016.
are generalizing on more industries. We presented our work [8] S. Ülkü, C. Hydock, and S. Cui, “Making the wait worthwhile: Experi-
on QueueForMe, a web application that allows everyone to ments on the effect of queueing on consumption,” Management Science,
2019.
create a virtual queue, and everyone around to join. Using a [9] A. K. Erlang, “The theory of probabilities and telephone conversations,”
simulator, we can verify the predictive capabilities of the queue Nyt. Tidsskr. Mat. Ser. B, vol. 20, pp. 33–39, 1909.
specific neural networks. As future work, we will include the [10] J. F. Shortle, J. M. Thompson, D. Gross, and C. M. Harris, Fundamentals
ability to add queue specific parameters at the queue creation of queueing theory. John Wiley & Sons, 2018, vol. 399.
[11] D. G. Kendall, “Stochastic processes occurring in the theory of queues
phase with predefined responses. This additional information and their analysis by the method of the imbedded markov chain,” The
will be exploited by the underlying waiting time-predicting Annals of Mathematical Statistics, pp. 338–354, 1953.

20
[12] A. Joseph, T. Hijal, J. Kildea, L. Hendren, and D. Herrera, “Predicting hospital pharmacy performance,” Iranian Red Crescent Medical Journal,
waiting times in radiation oncology using machine learning,” in 2017 vol. 16, no. 3, 2014.
16th IEEE International Conference on Machine Learning and Appli- [15] S. A. Bishop, H. I. Okagbue, P. E. Oguntunde, A. A. Opanuga, and
cations (ICMLA). IEEE, 2017, pp. 1024–1029. O. Odetunmibi, “Survey dataset on analysis of queues in some selected
[13] C. Curtis, C. Liu, T. J. Bollerman, and O. S. Pianykh, “Machine learning banks in ogun state, nigeria,” Data in brief, vol. 19, pp. 835–841, 2018.
for predicting patient wait times and appointment delays,” Journal of the [16] A. F. Agarap, “Deep learning using rectified linear units (relu),” arXiv
American College of Radiology, vol. 15, no. 9, pp. 1310–1316, 2018. preprint arXiv:1803.08375, 2018.
[14] M. Bahadori, S. M. Mohammadnejhad, R. Ravangard, and E. Tey- [17] D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,”
mourzadeh, “Using queuing theory and simulation model to optimize arXiv preprint arXiv:1412.6980, 2014.

21

You might also like