=Paper= {{Paper |id=Vol-3102/paper9 |storemode=property |title=A Cloud-Hosted Online Learning Approach for Glycemic Index Forecasting |pdfUrl=https://ceur-ws.org/Vol-3102/paper9.pdf |volume=Vol-3102 |authors=Giorgio Lazzarinetti,Nicola Massarenti,Stefania Mantisi |dblpUrl=https://dblp.org/rec/conf/aiia/LazzarinettiMM21 }} ==A Cloud-Hosted Online Learning Approach for Glycemic Index Forecasting== https://ceur-ws.org/Vol-3102/paper9.pdf
        A Cloud-Hosted Online Learning Approach for
                Glycemic Index Forecasting ?

Lazzarinetti Giorgio1[0000−0003−0326−8742] , Massarenti Nicola1[0000−0002−8882−4252] ,
                     and Mantisi Stefania1[0000−0003−4446−9743]

                    Noovle S.p.A, Milan, Italy https://www.noovle.com/en/




        Abstract. Recent developments in diabetes care technologies, like wearable de-
        vices for continuous glucose monitoring, have made it possible for patients to
        access relevant data and properly treat diabetes mellitus diseases. Thanks to ma-
        chine learning, moreover, it has been possible to predict the trend of the level
        of glucose in the blood in real-time, thus preventing diseases. In this research,
        we propose to compare the two main state-of-the-art algorithms for time se-
        ries forecasting, namely Autoregressive Integrated Moving Average (ARIMA)
        models and Recurrent Neural Network (RNN) models. In particular, we propose
        an auto adaptive algorithm for ARIMA models’ parameters selection based on
        the Augmented Dickey-Fuller test for stationarity and autocorrelation and par-
        tial autocorrelation functions for autoregressive and moving average orders and
        we show that somehow this would make the ARIMA model preferable to RNN-
        based models in an online learning scenario for time series forecasting, with a
        root mean square error of 1.11 mmol/l. We also propose some considerations
        related to a Google Cloud based infrastructure to host an online learning appli-
        cation, comparing the performance of the tested models also with respect to their
        training time and their scalability and maintenance, showing that ARIMA models
        clearly require a lighter infrastructure and a less complex pipeline for managing
        model life cycle with respect to RNN-based models.

        Keywords: Continuous Glucose Monitoring · Time Series Forecasting · Autore-
        gressive Integrated Moving Average · Recurrent Neural Network · Online Learn-
        ing.


1     Overview

Diabetes mellitus is a metabolic disorder that causes blood glucose level to deviate from
normal values and can lead serious health complications and in some cases, if not prop-
erly treated, even death [1]. Currently, there is no cure for diabetes, however keeping
?
    Activities were partially funded by Italian ”Ministero dello Sviluppo Economico”, Fondo
    per la Crescita Sostenibile, Bando “Agenda Digitale”, D.M. Oct. 15th, 2014 - Project n.
    F/020012/02/X27 - “Smart District 4.0”.

    Copyright ©2021 for this paper by its authors. Use permitted under Creative Commons Li-
    cense Attribution 4.0 International (CC BY 4.0).
        G. Lazzarinetti et al.

blood glucose levels within the recommended range is a key factor in treating this dis-
comfort. This includes monitoring blood glucose levels, exercising, observing a strict
diet and following an insulin-based treatment [2, 3]. Recent developments in diabetes
care technologies have made it easier for patients to access relevant data. In particular,
there are continuous glucose monitoring (CGM) technologies that record the level of
glucose in the blood at intervals of a few minutes. CGM technologies have the potential
to be used for the prediction of blood glucose concentration with the consequent opti-
mization of glycemic control. Furthermore, recently, machine learning and data mining
techniques have reached a sufficient degree of maturity in forecasting problems to allow
for the prediction of the glycemic index trend. In this research, we present a comparison
of the state-of-the-art algorithms for glucose level forecasting with the aim of develop-
ing an online learning framework, which is able to continuously adapt to changes. In
particular, we compare Autoregressive Integrated Moving Average (ARIMA) models
with Recurrent Neural Network (RNN) models and we test their ability to predict the
glucose level’s trend in the near future (30 to 60 minutes). Moreover, we developed
an auto-adaptive learning algorithm to optimize the ARIMA parameter in an online
learning fashion. The approach for hyperparameter optimization we defined uses the
Augmented Dikey-Fuller (ADF) test for stationarity condition to define the differentia-
tion order and the autocorrelation (ACF) and partial autocorrelation functions (PACF) to
select the range for the autoroegressive and moving average parameters, then optimized
with the Akaike’s Information Criterion (AIC). Differently from other researches in the
field, our algorithm does not perform optimization on a predefined range of the auto-
regressive and moving-average steps, but select these ranges considering the trends and
the statistical significance of each point of the ACF and PACF. The following is orga-
nized as follows. In Chapter 2 the most used approaches for the prediction of time series
will be described with a focus on the prediction of the glycemic index. In Chapter 3 we
describe the dataset used for training the model and we furtherly explain the business
need behind this research. In Chapter 4 we describe in detail the approaches that we
intend to test for the objective and in Chapter 5 we present the experimental results.
Finally, in Chapter 6 we describe the implemented architecture for the online learning
purpose and in Chapter 7 some conclusive remarks.


2   State of the art

In descriptive statistics, a time series is defined as a collection of constant points in time
and expresses the dynamics of a certain phenomenon over time. The analysis of time
series has two main practical applications: on the one hand, to provide an interpreta-
tion of a phenomenon, identifying components of trends, cyclicality and/or seasonality;
on the other, to predict the future trend of the phenomenon [4]. Time series can be of
two types: deterministic, if the values of the variable can be exactly determined starting
from the previous values without any error, stochastic,if the values can be determined
only partially, thus introducing an error in the prediction. Most of the time series of real
data belong to this second set and therefore require technical specification to infer the
next values by introducing the lowest possible error [5]. In recent years, to overcome the
issue related to diabetes mellitus, CGM technologies that record the level of glucose in
                                                         2. STATE OF THE ART

the blood at intervals of a few minutes have spread. The data collected by those instru-
ments is represented by a time series of the glycemic index. Thanks to the availability
of such data, recently many studies related to glycemic index prediction have emerged.
In [6–8] a taxonomy of the different types of existing algorithms for glycemic index
prediction is provided. In particular, four main approaches are identified on the basis of
the type of model used: physiological models [9], data-driven machine learning mod-
els [10–12], hybrid models [13] and control models [14–16]. Another distinction that
can be made between the types of existing algorithms is based on the type of data that
are considered as inputs. In fact, most of the studies are based on the use of CGM data
as the only source of information to predict glucose levels, while others also use differ-
ent inputs such as the meals consumed by patients, the doses of insulin taken and, very
rarely, physical exercise performed [17, 18]. Another note on the possible distinctions
of algorithms concerns the time horizon of the prediction: most algorithms focus on a
short-term prediction (i.e., less than 60 minutes) [19], while others focus on a longer
time horizon [20, 21]. Among these techniques, the most used are certainly data-driven
machine learning models. In a systematic study of models based on neural networks [8]
which is dated back to 2019, it is shown how most of the studies, 20% of those analyzed,
privilege feed-forward neural networks (FFNN) as a prediction tool, 18% RNN in var-
ious form and 19% an hybridization of physiology-based model and machine learning.
As explained in [22], the ability of RNNs to model time sequences is still an extensively
studied topic that has shown interesting results. In [26], for example, Martinsson et al.
propose a method based on RNNs trained using only the historical glucose level. Their
approach, evaluated in terms of root mean square error (RMSE), obtains results com-
parable with approaches proposed by other researchers. In [27], on the other hand, the
objective of the research is to compare the performance of an approach based on RNN
with respect to one based on FFNN both on short-term and long-term predictions. The
result of this research is that RNNs outperform FFNNs on long-term predictions, while
performance is similar on medium- and short-term predictions. A different approach,
but always based on RNN, is presented in [12]. Here, the model that is used is a recur-
rent convolutional network. The objective of the study is to evaluate the effectiveness of
the prediction in the short- and medium-term, comparing the performances obtained in
the training phase on a synthetic dataset and the performances obtained in the prediction
phase on a real dataset. Although the performances on the real dataset are worse than
those reported on the synthetic dataset, the results are still competitive with respect to
the state of the art when compared. Besides deep learning techniques, more classical,
but still very performing approaches in the field of time series are represented by the
statistical ARIMA models. The power of these models lies in their ability to model the
time series while keeping the degree of complexity of the model low. ARIMA models
combine two prediction methods: an autoregressive (AR) method and a moving aver-
age (MA) method which represents the baseline statistical models for time series fore-
casting. Even though there are also simpler models, as AR, MA, ARMA or ARMAX,
there are several studies that show how ARIMA models can be successfully applied to
glucose level forecasting [23–25]. For example, in [23] a study on the application of
ARIMA models to a case of prediction of the blood glucose level is presented. The pro-
posed methodology is based on the identification of the model definition parameters in
        G. Lazzarinetti et al.

an optimal way with respect to the forecasting task and subsequently on their applica-
tion to the real case. The model definition parameters are the auto-regression order (i.e.
the number of previous measurements needed to determine the current value), the mov-
ing average order (i.e. the number of previous white noise values needed to determine
the current value) and the degree of differentiation (i.e. the number of differentiations
necessary to make the series stationary). In [25], an ARIMA-based model is proposed
that uses Akaike’s information verification test to determine the value of parameters in
an adaptive way. This type of approach is certainly better than others because it is able
to take into account the variation of the state of the series over time and is able to apply
ARIMA in an adaptive way based on the trend of the series.


3     Problem Setting

The goal of this research is that of defining an online learning algorithm for glycemic
index forecasting. The research is, indeed, driven by business needs since the devel-
oped algorithm is intended to be used within a system that aims at monitoring some
vital parameters of bus drivers during their working hours in order to prevent diseases.
In particular, data acquisition takes place thanks to different devices that monitor (with
different frequencies) the blood glucose level in terms of glycemic index, the lipid pro-
file and HbA1c, the blood pressure and heart rate. Some of these variables are acquired
manually by a specific device once or twice a day. For these variables a prediction is
not needed, but the collected values are visualized in order to monitor their trend. As far
as the glycemic index is concerned, indeed, it is collected by a wearable device called
Glunovo CGM every 3 minutes, and for this variable the goal is to predict the trend of
the series in the near future, in order to alert the driver in case the trend is going out of
the predefined safe boundaries. Thus, the final system must include: a component for
the prediction of the glycemic index signal in the near future; an alerting system capable
of reporting dangerous situations; a dashboard that can be consulted by the doctor who,
based on the predictions made and the other values collected, decides whether to alert
the driver or not. In this research we implement an algorithm that, at each new value
registered by the Glunovo CGM device, analyzes the historical series up to that instant
and provides a real-time forecast of the trend of the glycemic index for the following
period with an horizon of 30 to 60 minutes. Moreover, the algorithm must be able to
adapt to new registered values in an online learning fashion and it must be suitable for
a huge number of drivers.


3.1   Dataset Description

In order to design the online learning framework, we use an open source dataset called
D1NAMO suitable for the analyzed case. The dataset is described by F. Dubosson et
al. in [29] and contains real readings of the glycemic index acquired under normal
conditions using the wearable device Zephir Bioarness 3. The values of the glycemic
index are acquired every 5 minutes for 9 patients with diabetes, while 6 times a day (non
regularly) for 20 non-diabetic patients. The dataset also contains other information not
relevant for this research since not available in the real scenario. Since for 2 out of the 9
                                                                4. METHODOLOGY

diabetic patients the data collected were relatively scarce, the research was carried out
considering just 7 distinct patients with a minimum number of 928 samples (around 3
days of data collection) for the patient with less detections up to a maximum number of
1438 for the patient with more detections (around 5 days of data collection). In Figure 1
the glucose trend for different patients is shown.




                         Fig. 1. Glucose trend for different patients.




4     Methodology

In designing the algorithms for glycemic index prediction, we decided to test and
compare two different models that also respond to two different situations: the first
(ARIMA) aims at having a model for each patient trained for each new data collected
by the device in an online learning scenario; the second (RNN) aims at creating a model
for each patient trained periodically in an offline model retraining scenario


4.1   ARIMA model

ARIMA models are statistical models that describe the behavior of a series considering
three parameters (described in the following). Consider a time series as a variable yt
that at each instant t is described by the signal value at that instant ηt , plus an error
value t . For what follows, compare R. Adhikari et al. in [4].

                                        yt = ηt + t                                  (1)
    A series is called autoregressive of order p, AR(p), if the value of the series at
instant t is a linear combination of the values of the signal from instants t − 1 to tp .
         G. Lazzarinetti et al.



                        yt = φ1 yt−1 + φ2 yt−2 + ... + φp yt−p + t                         (2)
    A series is said to have a moving average of order q, M A(q), if the value of the
series at instant t is a linear combination of the values that describe the trend of the
series from instants t − 1 to tq .

                            yt = θ1 t−1 + θ2 t−2 + ... + θq t−q                          (3)
    A series is called autoregressive moving average of orders p, q, ARM A(p, q) if it
is both autoregressive of order p and moving average of order q.


   yt = φ1 yt−1 + φ2 yt−2 + ... + φp yt−p + t + θ1 t−1 + θ2 t−2 + ... + θq t−q          (4)
    AR(p), M A(q) or ARM A(p, q) models can only model stationary time series. If
the joint probability distribution function of {yt−s , ..., yt , ..., yt+s } is independent of t
for all s, a series yt is strongly stationary. Thus, for a strong stationary process the joint
distribution of any possible set of random variables from the process is independent of
time. However for practical applications, the assumption of strong stationarity is not
always needed and so a somewhat weaker form is considered. A stochastic process is
said to be weakly stationary of order k if the statistical moments of the process up to
that order depend only on time differences and not upon the time of occurrences of the
data being used to estimate the moments. A homogeneous non-stationary series can,
however, be reduced to a stationary series by introducing an appropriate degree of dif-
ferentiation d. Using this degree of differentiation d, if the series is also autoregressive
with moving average, the series is called autoregressive integrated with moving average
of order p, d, q ARIM A(p, d, q). It is important to note that neither strong nor weak
stationarity implies the other. However, a weakly stationary process following normal
distribution is also strongly stationary. To verify if a series is stationary it is possible
to use some common statistical test like the one given by Dickey and Fuller. To deter-
mine the optimal parameters for an ARMA model, it is necessary to carry out the ACF
and PACF analysis. These statistical measures reflect how the observations in a time
series are related to each other. The ACF is used to measure the correlation between the
current observation and an observation at lag k (using the Pearson coefficient of corre-
lation by assuming that each variable is distributed as a Gaussian), while the PACF is
used to measure the correlation between the current observation and an observation at
lag k, after removing the effect of any correlation due to observations at intermediate
lags (i.e. at lags < k ). For each value of the ACF and PACF also a confidence interval is
computed to measure the significance of that computed correlation. For modeling and
forecasting purposes it is often useful to plot the ACF and PACF against consecutive
time lags. These plots help in determining the order of AR and MA terms. Some empir-
ical considerations, indeed, relates to the following facts: if the ACF decreases slowly
and the PACF decreases very quickly after p steps, the series is AR(p); if the ACF de-
creases very fast and the PACF decreases slowly after q step, the series is MA(q); if
both the ACF and the PACF decrease slowly, the series is ARMA. By analyzing the
graph shown in Figure 2, it is possible to see the ACF and PACF of a time series for 2
degrees of differentiation.
                                                              4. METHODOLOGY




                         Fig. 2. Differentiated series, ACF and PACF



Auto adaptive ARIMA parameters optimization algorithm Given the previous con-
siderations, in this research we define an adaptive logic for optimizing the parameters
of the model p, q and d so that, for each new data point, the best model is recalculated in
real-time on the basis of the historical data in an online learning fashion. In this way, the
trend of the series is predicted for each new data point. Since prediction must be taken in
real-time, it is important to quickly compute the selection of the parameters. The algo-
rithm we designed works iteratively and is reported in pseudo-code in the following. At
each iteration it takes the historical series (values) and calculates the differential of the
series starting from 0 by incrementally increasing the value of the differential to be cal-
culated. Once the differential has been calculated, the ADF statistical test is performed.
This test verifies the null hypothesis that there is a root in the time series. The alterna-
tive hypothesis is the stationarity hypothesis. Through this test, it is therefore possible
to determine with statistical significance whether the series is stationary or not. The test
is verified by considering the value of the p-value and the value of the calculated ADF
statistic. If the p-value < 0.05 and the calculated statistic is less than the first critical
value returned by the test, then the series is considered stationary, otherwise the series
is considered non-stationary. Once the test has been performed, if the null hypothesis
holds, the degree of differentiation of the series is increased and the test is repeated,
if the alternative hypothesis holds, instead the series is considered stationary and the
algorithm proceeds in the determination of the parameters p and q. To determine such
parameters, we use the calculation of the ACF and PACF functions. By following the
empirical considerations previously described, to detect p and q we compute the cut-off
of these series and take the first value of the function which is outside the confidence
interval (considering an alpha of 0.05). We therefore consider the maximum value that p
can take, p max, as the cut-off value of the ACF function and the same for q, q max, as
        G. Lazzarinetti et al.

the cut-off value of the PACF function, i.e. as the number of detections of the ACF and
PACF functions that are outside the 95% confidence interval. The choice to exclude the
values that are outside the confidence interval is determined by the fact that those values
do not have an effective statistical significance in determining the trend of the series.
For this reason, the hypothesis is that the p and q parameters should not be higher than
these cut-off values, however it is not guaranteed that the cut-off values are the optimal
model values. Indeed, once the p max and q max parameters have been determined, to
guarantee the optimal choice of the model, a greedy search of the parameters is carried
out, keeping d fixed and making p vary from 1 to the ACF cut-off value and q from 0
to the cut-off value of the PACF. For each model trained, the AIC is calculated. This
parameter is an estimator of the prediction error and, consequently, of the relative qual-
ity of the statistical model calculated on the input data. Indeed, given a collection of
models for a dataset, the AIC estimates the quality of each model relative to the quality
of the others. In this way, the AIC provides an estimate to make the selection of the
models. In this way it is possible to select the best possible model and with each new
data the model can be retrained and used for prediction.



 Algorithm 1: ARIMA Optimal Parameter Selection
   Input: The time series values ts val to train the ARIMA model
   Output: The optimal parameter p, d, q of the ARIMA model for the given time series
   d ← 0; check ← False;
   while check=False do
       diff val ← differentiate ts val with order d;
       p value, ADF stat, critical val ← compute ADF test over diff val;
       if p value<0.05 and ADF stat