The Business Analytics Dispatch Banner

An AI Crystal Ball? How We Predict Future Outcomes Using a Temporal Fusion Transformer Model

Our data science and analytics teams handle and apply lots of data for insightful decision-making. Last year, I presented the data science team with a challenge: use historical data to predict a key business driver for each of the next 8 periods. We wanted to have a data-driven preview of what we might see in the in each of the next eight periods so that we could anticipate the actual outcome and make better decisions with a an eight-period.

The data science team went to work researching ways we could do this and tested a few different methodologies. We have lots of input data from our own and public sources to feed any model we wanted to test, which worked well for us. With that said, we had low expectations about finding a predictive model that produced anything reliable.

Testing different algorithms is always our approach. For the semi-technical readers, before settling on Temporal Fusion Transformer (TFT), the algorithms we tested included ARIMA, VAR, GARCH, ARCH models (univariate), Prophet, NHits, and Nbeats. TFT is an attention-based deep learning neural network algorithm. Using a mix of inputs, it produces a forecast over multiple periods in a future time horizon that you can determine. You can predict days, weeks, months quarters (really any interval is possible) into the future. Your choice.

The picture below shows the concept of how TFT works.

Salvatore Tirabassi

Source: Bryan Lim, Sercan Ö. Arık, Nicolas Loeff, Tomas Pfister. “Temporal Fusion Transformers for interpretable multi-horizon time series forecasting.” International Journal of Forecasting. Volume 37, Issue 4, October–December 2021, Pages 1748-1764.

A continuous improvement process best describes how we developed and continue to refine the model. It’s a never ending process of improvement, as a true crystal ball is never achieved.

These are the four stages of development we went through after choosing TFT as our algorithm:

  • Stage 1a: Selecting all logical observed inputs and test how they drive the model. We started with over 100 and the final model only used 20. Go to Stage 1b as needed.
  • Stage 1b: Refining the time intervals of the observed inputs. Since the inputs might come in varying time intervals (daily, weekly, monthly and quarterly, etc…), we needed to find methods to standardize them. You should choose an interval that matches the decision-making forecast you are producing, if you can. Go back to Stage 1a as needed.
  • Stage 2: Model iteration and improvement. Complete back testing. Examine early predictions. Go back to Stages 1a and 1b as needed. At this point, you have probably settled on one or two of the most promising algorithms.
  • Stage 3: Begin using in production and comparing predictions to the future periods as they unfold. Learn and refine by going back to any previous stage as needed.
  • Stage 4. Continuous improvement loop. Write long-term road map. Test new inputs as they are presented. Continuous scrutiny of the predictions against what actually happens – learn and make changes by going back to any previous stage as needed.

Note that at any of the stages of development, you can use a TFT encoder decoder to measure the importance of different inputs in the algorithm to learn which ones have the most impact on your prediction.

Below are the results of our model. The orange line is the actual result of the key driver and the blue line is the prediction of the key driver that was made 8 periods ago. The area to the right without the orange line is the next 8-period forecast. So, at Period 19, we can use the blue line forecast to take action based on what Periods 20-27 tell us. When we reach Period 20, we evaluate the updated forecast and we make a decisions accordingly for the future periods. This way, we have a rolling 8-period prediction/decision cycle.

Salvatore Tirabassi

As you can see the model has been refined to a level that it makes useful predictions and handles volatility of the prediction with some reliability. Right now, we don’t use this to predict the future down to the exact number, which would be ideal, but we use it for a directional understanding of where things are headed so we can make better decisions at the current decision point.

See my blog post on survival regression for predicting consumer credit risk here.

FAQs about this Blog Post

  1. What methodology did the data science team employ to predict key business drivers for future periods, and how did they refine the process?
    The data science team tackled the challenge of predicting future business drivers by testing various algorithms, ultimately settling on the Temporal Fusion Transformer (TFT), an attention-based deep learning neural network algorithm. Before arriving at TFT, they experimented with other methods such as ARIMA, VAR, GARCH, ARCH models (univariate), Prophet, NHits, and Nbeats. Following the selection of TFT, the team underwent a continuous improvement process consisting of four stages: selecting observed inputs, refining time intervals, iterating and improving the model, and finally, incorporating it into production and continuously refining based on real-world outcomes.
  2. How does the Temporal Fusion Transformer (TFT) algorithm function, and what role does it play in the predictive process?
    TFT is a deep learning neural network algorithm designed for multi-horizon time series forecasting. It utilizes a mix of inputs to produce forecasts over multiple periods into the future, allowing users to predict days, weeks, months, quarters, or any desired interval. The algorithm’s effectiveness lies in its ability to handle volatility and provide reliable predictions, albeit not down to the exact number. Instead, it offers a directional understanding of future trends, empowering decision-makers to make informed choices at each decision point.
  3. What does the continuous improvement loop entail, and how does the model adapt to changing circumstances?
    The continuous improvement loop involves ongoing refinement and enhancement of the predictive model. It begins with selecting logical observed inputs and testing their impact on the model, followed by refining time intervals and iterating to improve the model’s accuracy through backtesting and early prediction examination. As the model is deployed in production, it is continuously compared to actual outcomes, allowing for further learning and refinement. At any stage, the use of a TFT encoder decoder helps measure the importance of different inputs, enabling the team to prioritize those with the most significant impact on predictions. This iterative process ensures that the model remains adaptive to changing circumstances and evolving data patterns, facilitating better decision-making over time.

About me
With a focus on strategic financial leadership, my role as a CFO has been pivotal in guiding companies through periods of growth and transformation. My proficiency in analytics and data science empowers me to drive informed decision-making and optimize financial performance. Let’s connect on LinkedIn to discuss how my Fractional CFO expertise can contribute to your company’s success with CFO PRO+Analytics.