<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>A tutorial on network-wide multi-horizon trafic forecasting with deep learning</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Giovanni Buroni</string-name>
          <email>gburoni@ulb.be</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Gianluca Bontempi</string-name>
          <email>gbonte@ulb.be</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Karl Determe</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Bruxelles Mobilite</institution>
          ,
          <addr-line>Bruxelles</addr-line>
          ,
          <country country="BE">Belgium</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Machine Learning Group, ULB</institution>
          ,
          <addr-line>Bruxelles</addr-line>
          ,
          <country country="BE">Belgium</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Trafic flow forecasting is fundamental to today's Intelligent Transportation Systems (ITS). It involves the task of learning trafic complex dynamics in order to predict future conditions. This is particularly challenging when it comes to predict the trafifc status for multiple horizons into the future and at the same time for the entire transportation network. In this context deep learning models have recently shown promising results. This models can inherently capture the non-linear space-temporal correlations (ST) in trafic by taking advantage of the huge volume of data available. In this study the authors present a LSTM encoder-decoder for multi-horizon trafic flow predictions. We adopted a direct approach in which the model simultaneously predict trafic conditions for the entire Belgian motorway transport network at each time step. The results clearly show the superiority of this model when compared with other deep learning models. In the workshop, conference attendees will learn how to process and visualize mobility data, obtain optimal features for trafic flow forecasting, build a LSTM encoder-decoder and perform predictions in an online manner.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>INTRODUCTION</title>
      <p>Trafic forecasting systems are crucial in modern cities. These
systems can potentially provide accurate and timely
information to public and private organizations by relying on data
collected in real-time. These organizations can in turn take action
through policy and lead to more sustainable mobility. These
aspects have enormous economic, social and environmental
implications. Nowadays, thanks to the development of cutting-edge
technologies and advances in artificial intelligence, trafic
forecasting has reached results never seen before. In particular, the
advent of deep learning (DL) models allowed to take advantage
of the enormous volume of mobility data to capture the complex
non-linear space-temporal relationships governing road trafic.
Moreover, they proved to be particularly efective when it comes
to predict trafic for both multiple forecast horizons and for
multiple streets. In ITS context, the advantages of DL when compared
with traditional machine learning models are summarised as
follow [8, 9]:
• model huge volume of space-temporal trafic data;
• perform multi-horizon road trafic predictions on large
scale transportation networks;
• achieve greater forecasting accuracy;
• comply to real-time requirements characterizing online
forecasting systems in ITS;</p>
      <p>In the recent literature for multi-horizon forecasting, DL
methods can be categorised into (i) iterated approaches using
autoregressive models or (ii) direct methods based on
sequence-tosequence models [7]. The former approaches use one-step-ahead
prediction models where each model’s output is recursively fed
into future inputs to obtain multi-step predictions. On contrary,
direct methods (ii) are trained to explicitly generate forecasts
for multiple predefined horizons in a single step. These models
generally present better forecasting accuracy than the
iterativebased methods. In this paper, we present a tutorial to build and
train a Direct LSTM encoder-decoder model. The model performs
predictions for trafic data related to the entire Belgian motorway
network. The model is tested over two-weeks period in an online
fashion. The results show the DL model obtained better
predictive accuracy when compared to advanced seasonal persistence
model and other deep learning models. The data and models code
are available at https://www.kaggle.com/giobbu/.
2</p>
    </sec>
    <sec id="sec-2">
      <title>NETWORK-WIDE FORECASTING</title>
      <p>The aim of trafic forecasting is to predict future trafic conditions
given a sequence of historical trafic observations. These
observations are detected by sensors, such as GPS, radio frequency
identification devices, multi-sensors, cameras and Internet
technology, that monitor the trafic status of roads in real-time. In
our study, at each time step t , the trafic flow is monitored at S
street segments of the entire transportation network. Hence, the
road network is modelled as multiple parallel time-series and
represented by the matrix X[i,k]:
 x1,1
 ...

 xi,1
 ...
 xt,1
. . .
. . .
. . .</p>
      <p>x1,k
.
.</p>
      <p>.
xt,k
. . .
. . .
. . .</p>
      <p>x1,S 
... </p>
      <p>
xi,S 
... </p>
      <p>
xt,S 
where xi,k is the value of trafic flow at time i and street
segment k.</p>
      <p>The prediction task can be seen as the process of learning a
mapping function, f from X previously observed features to Z
future streets’ features, f : X → Z .
3</p>
    </sec>
    <sec id="sec-3">
      <title>MULTI-HORIZON FORECASTING</title>
      <p>In the study, the goal is to perform multi-horizon forecasting of
the trafic flow based on the current and past trafic conditions
of the entire transportation network. To achieve so, a direct
strategy is implemented for multivariate multi-horizon
timeseries forecasts as discussed in Bontempi et al. [2].</p>
      <p>
        At each time step t , we obtain:
(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )
where Zt +1 is the matrix containing the multi-horizon trafic
lfow predictions, (t + 1, t + 2, ..., t + h) for all S street segments,
and h is the forecast horizon.
      </p>
    </sec>
    <sec id="sec-4">
      <title>LSTM ENCODER-DECODER Preliminaries</title>
      <p>4.1.1 Sequence-to-Sequence Learning. In deep learning
sequenceto-sequence learning (Seq2Seq) is about training DL models to
convert sequences from one domain to sequences in another
domain. Multi-horizon trafic flow forecasting at transportation
network scale can be seen as Seq2Seq learning problem, where
the sequence of trafic flow observations from the past is learned
to predict the sequence of observations in the future. The use DL
models ofers several advantages [4, 9]:
• natively support sequence input data (sequence of flow
observations);
• directly support multiple parallel input sequences for
multivariate inputs (multiple street segments);
• map input data directly to an output vector ( multi-horizon
predictions).</p>
      <p>4.1.2 Long Short-Term Memory (LSTM). Long Short-Term
Memory (LSTM) network is a special kind of recurrent neural
network (RNN), which is capable of learning short and long-term
dependencies of the input data [5] LSTM unit is composed of
three gates: input, forget and output gate. These gates determine
whether or not to let new input in (input gate), delete the
information because it is not important (forget gate) or to let it impact
the output at the current time step (output gate). LSTMs are now
widely used to deal with sequence data for learning the temporal
dependency of the space-temporal data.</p>
      <p>4.1.3 Encoder-Decoder architecture. The encoder-decoder
models present a particular type of architecture particularly efective
for Seq2Seq learning problem [9]. Here’s how it works:
• Encoder Module: the input sequence of the encoder is
fed to the module. This generates an internal state that is
passed as the "context" to the decoder.
• Decoder Module: it is trained to predict the target
sequence, given the input sequence of the decoder and the
memory state vectors from the encoder. The encoder’s
state allows the decoder to obtain information about what
it is supposed to generate.
4.2</p>
    </sec>
    <sec id="sec-5">
      <title>Direct LSTM encoder-decoder</title>
    </sec>
    <sec id="sec-6">
      <title>Architecture</title>
      <p>At first we frame our prediction problem by diving the
timedependent input features into two categories as shown in Figure
1 : (i) the observed inputs (trafic flow of streets) which can only
be retrieve at time step t and are unknown beforehand, and the
time-based covariate inputs (features such as day-of-the-week at
time t ) which can be predetermined.</p>
      <p>The Direct LSTM encoder-decoder (D_lstm_ED) Architecture
is shown in Figure 2. As the figure shows, the encoder module
takes as input all past features (both observed roads’ trafic flows
and known temporal features) and encode them into a latent
space. This encoded "context" is then fed as internal state to the
decoder module together with the known future covariates as
inputs. After being trained, the model perform the forecast of the
future (multiple) trafic flow values for the whole road network
at each time step.</p>
      <p>EXPERIMENTAL SETTINGS
5.0.1 OBU Data . As from 2016, all owners of Belgian lorries
having a Maximum Authorized Mass in excess of 3.5 tonnes must
pay a kilometre charge. Every road user who is not exempt from
the toll must then install an On Board Unit (OBU) recording the
distance that a lorry travels on Belgian public roads. Because of
their value as mobility indicator, the OBU data are made
available to Bruxelles Mobilite’, the public administration responsible
for equipment, infrastructure and mobility issues in
BruxellesCapital Region. Each truck device sends a message approximately
every 30 seconds (from 3 a.m. to 2.59 a.m. of the following day).
Each OBU record contains an anonymous identifier (ID resetting
every day at 3 a.m.), the timestamp, the GPS position (latitude,
longitude), the speed (engine) and the direction (compass). Moreover,
OBU data includes vehicle data characteristics: weight category
(MAM), country code and European emission standards
classiifcation of the engine (EURO value). The large volume and the
streaming nature of the OBU data required the set up of a big
data platform for an eficient collection, storage and analysis [ 3].</p>
      <p>5.0.2 Data Processing &amp; Time-based Covariates. Before
obtaining the matrix of Figure 1, the OBU data are processed. Firstly,
we consider two months period OBU data, from the 1st of January
to the 28th of February, 2019, and the major motorways related
to Belgium retrieved from OpenStreetMap1 with Module osmnx
in Python. Then, we filter the records with respect to their street
segments location and resample with a 30 minutes interval. The
trucks are considered on the road network if their location falls
within the polygons area representing the street segments 2. We
took into consideration street segments with an average trafic
lfow higher than 10 vehicles/half-hour. The number of street
segments (and consequently the number of time series analyzed)
amounts to 5187 with 2832 observations (Fig. 5). Finally, starting
from Timestamp variable, we create the following covariates:
• a Sine and Cosine transformation of the Hours of the Day.</p>
      <p>This will ensure that the 0 and 23 hour for example are
close to each other, thus accounting the cyclical nature of
the variable;
• the Days of the Week. Each day of week shows particular
pattern of trafic flow;
• the Working/Week-end Days. There is a clear diference in
trafic flow between the working days and the week-end
days.</p>
      <p>This features are deterministic and therefore are known in
advance for future trafic flow predictions.</p>
      <p>5.0.3 Data Preparation for DL models. In order for the DL
model to learn, the sequence of observations must be transformed
in the form of { nsampl es , nt imest eps , nf eatur es }. Therefore, we
transform X to a three dimensional tensor Tt to represent the
trafic flow data, t xwxM, where t denotes the total number of
samples, w refers to length of sequence observations and M is
the total number of features:</p>
      <p>
        Tt = (X1, X2, . . . , Xt )
(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )
where Xi is the sample at time i. Thus, Xt is the matrix:
 xxt −tx−wt......w,+1,l1,1 ... ... ... xxt −tx−wt......w,+k,lk,k ... ... ... xxt −tx−wtw,......+M,lM,M  (
        <xref ref-type="bibr" rid="ref4">4</xref>
        )
The shape of each Xt is what the model expects as input for
each sample.
      </p>
      <p>5.0.4 Seasonal Persistence and other DL models. As a
baseline to compare our DL model, we consider Seasonal Window
Persistence Model (SW). Within a sliding window, observations
at the same time and same day in previous three-weeks seasons
are collected and the mean of those observations is returned as
persisted forecast. As an example, if the data are hourly and the
forecasting target is 9 a.m. on Monday, then if the window size
is 1 the observation of last Monday at 9 a.m. will be returned as
forecast. A window of size 2 means returning the average of the
observations of the last two Mondays at the same hour.
Moreover, we compare our model with other DL models: two
LSTM models that performs predictions respectively with a
direct approach (D_lstm) and with an iterated approach (A_lstm)
and a LSTM-based seq2seq architecture with iterated approach
1https://www.openstreetmap.org
2OBU Data processing is available at
https://www.kaggle.com/giobbu/obu-datapreprocessing
(A_lstm_ED) where the decoder’s predictions are reinjected into
the decoder’s input.</p>
      <p>5.0.5 Forecasting Evaluation and Metrics. In order to fully
exploit the properties unique of real-time data, we adopt the so
called interleaved-test-then-train evaluation scheme [1]. Each
observation is used to test the model before it is used for training,
and from this the forecasting accuracy is incrementally updated.
Therefore, the model is always being tested on instance it has not
seen. To measure the forecasting accuracy of the competing
forecasting approaches we use the well-known Root Mean Squared
Error, RMSE, and Mean Absolute Error, MAE. For multi-horizon
forecasts these metrics are defined as follows:</p>
      <p>RMSEi =</p>
      <p>MAEi =
s Pit=1 PhH=1 (ei,h )2</p>
      <p>nH
Pit=1 h=1 |ei,h |</p>
      <p>PH
nH
where ei,h is the error of the forecast for period i and forecast
horizon h.</p>
      <p>
        5.0.6 Space-Temporal Resolution and Model Seting. We
forecast the trafic flow (vehicles/half-hour) of each street segment
in the Belgian motorway network up to 6 hours ahead, forecast
horizons from h = 1 to h = 12. From the whole data set we hold
the last two weeks (672 observations) for testing our models. The
data must be scaled to values between 0 and 1 before we can use
them to train the DL model. The predictive models are initially
iftted on the training set. Then, the models are incrementally
updated, while subsequently adding new data from the test set
as described in previous section.
(
        <xref ref-type="bibr" rid="ref5">5</xref>
        )
(
        <xref ref-type="bibr" rid="ref6">6</xref>
        )
Model avgRMSE avgMAE
Baseline 11.67 7.25
D_lstm 11.28 7.03
      </p>
      <p>A_lstm 11.30 7.12
D_lstm_ED 10.66 6.63</p>
      <p>A_lstm_ED 11.08 6.93</p>
      <p>Table 1: Average values of RMSE and MAE.</p>
      <p>5.0.7 Results. The obtained results are summarised in Table
1. The table shows the average value of RMSE and MAE metrics
for both models over the testing set. The Direct LSTM
encoderdecoder presents better forecasting accuracy for both metrics.
Further, since trafic over the road network may be extremely
heterogeneous in terms of volatility, we estimated the normalised
metrics against the baseline model [6]. For example, N RMSE is
the ratio between the RMSE of the predictor and the baseline
RMSE. A ratio below 1 denotes that the considered predictor is
at least more accurate than the baseline model. In Fig. 3-4, the
average value of normalised metrics is computed for all forecast
horizons separately. These figures highlight once again the
superiority of Direct LSTM encoder-decoder when compared with
other DL models especially for long-range forecast horizons.
6</p>
    </sec>
    <sec id="sec-7">
      <title>OUTLINE</title>
      <p>In the workshop, conference attendees will learn how to perform
trafic flow predictions at transportation network scale by
employing Direct LSTM encoder-decoder model (Fig. 5). A Jupyter
Notebook will be provided in Kaggle3 so attendees can copy it
and readily run the code and interact.</p>
      <p>
        The demonstration will be organise as follow:
(
        <xref ref-type="bibr" rid="ref1">1</xref>
        ) retrieve transportation networks from OpenStreetMap4
and OSMNX5 in Python;
(
        <xref ref-type="bibr" rid="ref2">2</xref>
        ) process OBU data with Geopandas6 with diferent time
granularities and road networks;
and visualize it on Folium8;
(
        <xref ref-type="bibr" rid="ref3">3</xref>
        ) create a dataframe in Pandas7 for trafic flow predictions
(
        <xref ref-type="bibr" rid="ref4">4</xref>
        ) add temporal features and prepare the data in Tensorflow9;
(
        <xref ref-type="bibr" rid="ref5">5</xref>
        ) build and train a Direct LSTM encoder-decoder model in
(
        <xref ref-type="bibr" rid="ref6">6</xref>
        ) perform online predictions and visualise the results with
(
        <xref ref-type="bibr" rid="ref7">7</xref>
        ) compare the results with a Seasonal Persistence and other
Tensorflow;
Matplotlib10;
      </p>
      <p>DL models.</p>
    </sec>
    <sec id="sec-8">
      <title>ACKNOWLEDGMENTS</title>
      <p>The authors acknowledge the support of Programme
Operationnel FEDER 2014-2020 de la Region de Bruxelles Capitale
5https://github.com/gboeing/osmnx
6https://geopandas.org
and icity.brussels11 for MOBIAID Project12. The authors are also
grateful to Bruxelles Mobilite for having provided the OBU data
necessary for the work.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Albert</given-names>
            <surname>Bifet</surname>
          </string-name>
          and
          <string-name>
            <given-names>Richard</given-names>
            <surname>Kirkby</surname>
          </string-name>
          .
          <year>2009</year>
          .
          <article-title>Data stream mining a practical approach</article-title>
          . (
          <year>2009</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Gianluca</given-names>
            <surname>Bontempi</surname>
          </string-name>
          , Souhaib Ben Taieb, and
          <string-name>
            <surname>Yann-Aël Le Borgne</surname>
          </string-name>
          .
          <year>2012</year>
          .
          <article-title>Machine learning strategies for time series forecasting</article-title>
          .
          <source>In European business intelligence summer school</source>
          . Springer,
          <fpage>62</fpage>
          -
          <lpage>77</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>Giovanni</given-names>
            <surname>Buroni</surname>
          </string-name>
          ,
          <string-name>
            <surname>Yann-Ael Le</surname>
            <given-names>Borgne</given-names>
          </string-name>
          , Gianluca Bontempi, and
          <string-name>
            <given-names>Karl</given-names>
            <surname>Determe</surname>
          </string-name>
          .
          <year>2018</year>
          .
          <article-title>On-Board-Unit Data: A Big Data Platform for Scalable storage and Processing</article-title>
          .
          <source>In 2018 4th International Conference on Cloud Computing Technologies and Applications</source>
          (Cloudtech).
          <source>IEEE</source>
          , 1-
          <fpage>5</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>Felix</surname>
            <given-names>A Gers</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Douglas</given-names>
            <surname>Eck</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Jürgen</given-names>
            <surname>Schmidhuber</surname>
          </string-name>
          .
          <year>2002</year>
          .
          <article-title>Applying LSTM to time series predictable through time-window approaches</article-title>
          .
          <source>In Neural Nets WIRN Vietri-01</source>
          . Springer,
          <fpage>193</fpage>
          -
          <lpage>200</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Sepp</given-names>
            <surname>Hochreiter</surname>
          </string-name>
          and
          <string-name>
            <given-names>Jürgen</given-names>
            <surname>Schmidhuber</surname>
          </string-name>
          .
          <year>1997</year>
          .
          <article-title>Long short-term memory</article-title>
          .
          <source>Neural computation 9</source>
          ,
          <issue>8</issue>
          (
          <year>1997</year>
          ),
          <fpage>1735</fpage>
          -
          <lpage>1780</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>Rob</surname>
            <given-names>J</given-names>
          </string-name>
          <string-name>
            <surname>Hyndman and Anne B Koehler</surname>
          </string-name>
          .
          <year>2006</year>
          .
          <article-title>Another look at measures of forecast accuracy</article-title>
          .
          <source>International journal of forecasting 22</source>
          ,
          <issue>4</issue>
          (
          <year>2006</year>
          ),
          <fpage>679</fpage>
          -
          <lpage>688</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Bryan</given-names>
            <surname>Lim</surname>
          </string-name>
          , Sercan O Arik,
          <string-name>
            <surname>Nicolas Loef</surname>
            , and
            <given-names>Tomas</given-names>
          </string-name>
          <string-name>
            <surname>Pfister</surname>
          </string-name>
          .
          <year>2019</year>
          .
          <article-title>Temporal fusion transformers for interpretable multi-horizon time series forecasting</article-title>
          . arXiv preprint arXiv:
          <year>1912</year>
          .
          <volume>09363</volume>
          (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Yisheng</given-names>
            <surname>Lv</surname>
          </string-name>
          , Yanjie Duan, Wenwen Kang,
          <string-name>
            <given-names>Zhengxi</given-names>
            <surname>Li</surname>
          </string-name>
          , and
          <string-name>
            <surname>Fei-Yue Wang</surname>
          </string-name>
          .
          <year>2014</year>
          .
          <article-title>Trafic flow prediction with big data: a deep learning approach</article-title>
          .
          <source>IEEE Transactions on Intelligent Transportation Systems</source>
          <volume>16</volume>
          ,
          <issue>2</issue>
          (
          <year>2014</year>
          ),
          <fpage>865</fpage>
          -
          <lpage>873</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>Senzhang</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <surname>Jiannong Cao</surname>
            , and
            <given-names>Philip</given-names>
          </string-name>
          <string-name>
            <surname>Yu</surname>
          </string-name>
          .
          <year>2020</year>
          .
          <article-title>Deep learning for spatiotemporal data mining: A survey</article-title>
          .
          <source>IEEE Transactions on Knowledge and Data Engineering</source>
          (
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>