Back to overview

Time Series Forecasting

Reading time approx. 5 minutes
19.12.2024

In close collaboration with one of our clients, we developed an innovative tool for optimizing workforce allocation. One of the recurring challenges for many companies is efficient planning and allocation of personnel to avoid both overstaffing and understaffing. This is particularly crucial in industries with highly fluctuating demand, as it enables cost reduction and improved customer satisfaction.

Such a tool offers numerous advantages. It not only aids in better scheduling of employees' working hours but also enhances productivity and increases employee satisfaction. By forecasting staffing needs based on historical data, companies can act proactively and allocate resources effectively.

Requirements Gathering

To develop an application for optimal workforce allocation, we began with comprehensive requirements gathering. It quickly became evident that transparency and traceability of decisions were of utmost importance to the affected employees. This is especially critical in the case of AI-driven applications, where it is often not entirely clear how specific outcomes are reached, potentially leading to mistrust and resistance.

Our goal was therefore to create a precise and efficient solution that was also highly controllable and understandable. The ability to influence the underlying parameters was particularly important to ensure sufficient transparency and foster acceptance.

Decision-Making and Tool Requirements

During our analysis, it quickly became apparent that this task was ideally suited for a solver. Since we operate within the Java ecosystem, we began searching for suitable tools and came across OptaPlanner. OptaPlanner is a rule-based engine built on Drools, which enables the definition of various criteria and rules to identify optimal solutions.

However, our analysis also revealed that it would not be practical to delegate the entire problem to this engine. Doing so would significantly limit the traceability of decisions and control options. As a result, we defined the core functionalities the tool must fulfil:

  • Calculate and predict workload: The tool must be capable of accurately forecasting future work requirements.
  • Determine staffing needs: Based on these forecasts, it should calculate the necessary personnel requirements.
  • Optimal employee allocation: Employees should be assigned to tasks based on their qualifications and availability.

OptaPlanner meets the requirement of deploying employees exactly where they are most needed.

Time Series Forecasting

One of the key challenges was to accurately predict future workloads. Additionally, we had access to a comprehensive collection of KPIs, such as: new orders, completed orders, pending orders, and processing times.

To effectively utilise this data, we opted for Time Series Forecasting. This proven data prediction technique is particularly prevalent in time-sensitive industries such as transportation, logistics, and energy. It allows for the analysis of historical data, the identification of patterns and trends, and the derivation of reliable forecasts.

Frameworks

Since our project is situated within the Java ecosystem, we initially focused exclusively on Java-based frameworks. However, we discovered that there are only a few specialised frameworks for Time Series Forecasting in Java. This limitation presented us with the challenge of identifying more suitable solutions.

Python und Pandas

At first, Python, with its extensive Pandas library, seemed like an attractive alternative. Pandas offers numerous capabilities for manipulating and analysing time series data. However, using these tools requires significant programming effort and data management. This would substantially slow down the development process of our application and increase its complexity.

Nixtla und NeuralForecast

During our research, we came across Nixtla, particularly its NeuralForecast library. Nixtla provides a suite of tools for time series forecasting designed specifically for easy integration and high accuracy.

Advantages:

  • Easy Integration: Nixtla integrates seamlessly into existing projects and requires minimal preparatory work.
  • High Accuracy: By leveraging advanced neural networks, NeuralForecast delivers highly accurate predictions.
  • Efficient Cross-Validation: Nixtla includes built-in functions for cross-validation, enabling users to evaluate and improve model accuracy.

Cross-validation is a technique used in Machine Learning to assess a model's performance. It involves splitting the available dataset into multiple parts, known as folds. The model is then trained and tested multiple times, with a different portion of the data used as the test set in each iteration, while the remaining data serves as the training set.

Selection and Application of Specific Algorithms

For our time series forecasting project, we decided to compare the following algorithms:

  • TimesNet
  • NHiTS
  • NBEATS

TimesNet
TimesNet is a neural network specifically designed for time series forecasting. It leverages Deep Learning to identify complex patterns and relationships within the data. A key advantage of TimesNet is its ability to provide both short-term and long-term forecasts with high accuracy.

NHiTS (Neural Hierarchical Interpolation for Time Series)
NHiTS employs a multi-step interpolation strategy to enhance forecasting accuracy. This method is particularly useful for time series with seasonal patterns, enabling it to capture fine details and long-term trends simultaneously.

NBEATS (Neural Basis Expansion Analysis for Time Series)
NBEATS uses a basis expansion technique to generate forecasts. It is renowned for its high prediction accuracy and its ability to perform both additive and multiplicative decompositions.

Example:


time_series_graph (Source: Python)


The chart illustrates the historical data for newly received orders in blue. It clearly shows that there are very few orders over the weekends, reflected in the dips in the blue curve.

The predictions from the various models are represented in green, orange, and red. The NHITS and NBEATSx models show very similar trends and closely follow the patterns of the historical data. The RNN model exhibits greater variation in its predictions and forecasts fewer orders over the weekends, aligning more closely with the actual trend. With targeted adjustments, this model could deliver even more accurate predictions and better account for fluctuations in order volumes.

In summary, all three models perform satisfactorily, though none are perfect yet, and they are not currently deployed in production. The analysis has revealed that further optimisations are necessary—such as manually or API-based inclusion of public holidays and consideration of specific customer-related demand spikes. Despite these open issues, the initial results are very promising.

Conclusion

The challenges and opportunities encountered in such a project demonstrate the critical importance of aligning technological innovation with specific business requirements. By leveraging Time Series Forecasting and evaluating various algorithms, companies can accurately predict future workloads and plan their resources efficiently. Although the initial results are promising, there is much room for further optimisation.

Overall, it is evident that such solutions not only enhance efficiency and reduce costs but also sustainably improve employee and customer satisfaction. Companies facing similar challenges can benefit from this approach and should consider integrating such technologies into their planning processes.

Sources

https://www.nixtla.io/