Managing Operational Risk: Proven Strategies & Best Practices
Jun 30, 2025 in Industry Overview
Learn effective methods for managing operational risk. Discover key frameworks, controls, and culture tips to protect your business today.
Not a member? Sign up now
A custom deep neural network to predict stock
Paulo Maia on Nov 9, 2021
In this article, we will cover a use case in the construction industry related to forecasting the needed materials for construction and the time in which they will be required. In the construction industry, there is a lot of uncertainty between the order time and the time in which it is actually executed, due to several factors which will be described in detail below.
Let’s cover the case where we want to buy heavy industry materials from a supplier, but we only have a high-level estimate of the amount we will need. We are not sure right away the exact time and characteristics of the materials that will be needed, since there might be some delays in the project, and changes between order and execution. We have clients that are executing constructions and contact us with preliminary orders with their requirements.
We need to know several things about this process:
Let’s consider the following data entities and associated historical data for this problem:
Supplier |
Dispatches the raw materials we need. |
|
Builder |
Executes the construction. |
|
Construction |
The site which is being built. |
|
Material |
A material request. |
|
For each stakeholder involved in the process, there are things causing uncertainty in the questions described above. We may over or underestimate the amount/quality of the required materials (both from inaccurate information from the construction plans or from internal uncertainties in the estimates). The builders can waste or use in a more efficient way a certain material. The delay between order and execution depends on the complexity of the construction process, time of the year (holidays!), and supplier bottlenecks, among others.
There are some relevant features that can be extracted to make this problem easier to predict:
For simplification purposes, let’s assume we only want to predict a single material: e.g. beams needed for a single unit in the construction.
We need to determine:
In this initial approach, we take the features at order time and try to predict the number of beams needed, and the number of days between order and execution. This is done using a multitask model, with two regression tasks.
The advantages of this approach are that it is easy to set up, the targets are easy to interpret, makes the model more robust, and might increase the performance. However, there are several disadvantages:
We can alternatively build a multitask classification model, where we consider two tasks:
The table below shows an example of what this artificial sampling would look like:
Sampling Date: Randomly sampled dates between order_date and execution_date
Execution Beam Width (hypothesis): The comparison we’re performing. These are the values of beams that are in stock.
Execution Beam Width: What really happened. We use the comparison to “Execution Beam Width (hypothesis)” as a target.
In blue are shown the rows where the target is positive, and in orange where they are negative. For instance, a sampling date of 25/2/2021 is close enough to our execution date to consider it as a positive target for prediction, while 20/2/2021 is not. In terms of execution beams, the target is positive when the pre-orders and the execution matches.
Regarding model architecture, we can build a two-stream model: we separate the features belonging to the delay between order and execution and the difference between ordered and executed material, since we’ll have multiple rows with similar features, and this tells the model to treat them differently in an explicit way.
The proposed architecture is relatively simple: a set of dense and dropout layers, followed by an aggregation operation (e.g. concatenation). Afterward, another set of Dense/Dropout layers transforms this concatenated latent space. In the bottom, two different softmax layers, one for each task, are added.
Compared to Option 1, this architecture has the advantage of allowing a decision process based on prediction confidence and only predicting items that the client is able to produce. However, the process complexity is higher: you need to create positive and negative training samples, and it is harder to set up.
We can also add custom penalizations in our loss function according to the business problem. If we predict 30 beams in a building that needs 20, it’s ok. If it needs more, it will not be sufficient. When the model doesn’t predict the same material, but a compatible one, we can punish it less. When it’s not, punish it more.
Building a multitask classification model allows us to create a decision process based on the expected value. Namely, what’s the probability P of needing K units of a product has an expected value of P x K units.
To know which materials to keep in stock for the next N weeks, the expected value for all constructions that are ordered and not yet executed can be summed.
What metrics would be important to measure?
Internally, for building and evaluating your model, you can use Machine Learning metrics:
But this tells nothing about how good the model is at predicting the amount you need to stock. You need to measure business metrics as well:
This article has shown some different ways you can think about product forecasting problems, where there are a lot of products with similar characteristics.
We only cover the specific case of forecasting a single product type (beams) with different characteristics. However, this could be generalized for different products – such as the amount of cement needed – by adapting the model. Since there are no “cement SKUs”, and any amount predicted is valid, you can replace the sigmoid classification with a linear layer, and create a regression model together with binary classification for the time delay.
Like this story?
Special offers, latest news and quality content in your inbox.
Jun 30, 2025 in Industry Overview
Learn effective methods for managing operational risk. Discover key frameworks, controls, and culture tips to protect your business today.
Jun 30, 2025 in Industry Overview
Learn how bottleneck analysis can help you find and resolve constraints efficiently. Discover tips for effective bottleneck analysis today!
Jun 5, 2025 in Industry Overview
Master quality control automation with proven strategies that drive real results. Discover practical insights from industry leaders.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |