In this blogpost, we will cover a use case in the construction industry related to forecasting the needed materials for a 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.

Business Problem

Let’s cover the case where a supplier, who will be supplying the materials for a factory, will require heavy industry materials, but only has a high level estimate of the amount he will need. He is 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.

The customer is contacting a material production company – our client – that produces these materials and sells them to suppliers.

Our client needs to know several things about this process:

  • When will this specific client execute the order?
  • What material characteristics will be preferable for this customer?
  • What are the best materials to keep in stock right now and by which amount? He needs some fixed time (e.g. 4 weeks) to build them and transport them to a storage facility. If we keep too little in stock, we’ll delay the construction. If we have too much, it’s not that big of a deal, but we have limited space.

Data Entities

Let’s consider the following data entities and associated historical data for this problem:

Supplier

Buys the material from our client.

  • Supplier ID
  • ZIP Code

Builder   

Uses the material given by the supplier.

  • Builder ID
  • ZIP Code

Construction

 

The site which is being built, requiring heavy materials.

  • Location
  • Construction Type (Residential/Industrial, industry type)
  • Building Area/Dimensions
  • Number of expected workers

Material

A material which will be a part of a construction (e.g. power generator, cement, beams, …), at the time it was ordered and that the order was executed.

  • Material Type (e.g. Cement, Power Generator)
  • Characteristics: e.g. – Amount of Cement 3000kg, Power 7500 kW, …

For each stakeholder involved in the process, there are things causing uncertainty in the questions described above. The suppliers may over or under estimate the amount/quality of the material they will need for a certain construction. 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!), supplier bottlenecks, among others.

Relevant Features

There are some relevant features that can be extracted to make this problem easier to predict:

    • Construction x Material: Amount and type of each material needed at order time and execution time for a certain construction. This tells us which constructions over- and underestimated certain materials, and what was the delay between order and execution. It will be used for building the targets of our problem.
    • Builder/Supplier: Statistics for the historical differences in material amount/characteristics between order time and execution time (e.g. ordered 3 tons cement, only needed 2.5 in the past 3 months, on average)
    • Time: Time of the year (month, quarter, season, …) and historical features on the difference between order time and execution time.

Modeling

For simplification purposes, let’s assume we only want to predict a single material: e.g. power needed for a single generator in the building.

We need to determine:

  • Generator Power
  • Time until the order is executed, after it’s ordered with some initial characteristics

Option 1 – Multitask Regression Model

In this initial approach, we take the features at order time and try to predict the amount of power 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 is 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:

  • There’s a set of defined templates for the power generators (SKU – Stock Keeping Unit) and the model might be predicting power values that do not exist!
  • Hard decision process: There’s no way to measure prediction confidence when all you have is a value.
  • Difficult convergence: the domain of possible values is very large, it’s not easy to tell if a prediction is good or not.

 

Option 2 – Multitask Classification

We can alternatively build a multitask classification model, where we consider two tasks:

  • whether or not the execution power in our hypothesis matched a certain generator power in stock. This means we will have to create artificial samples in our dataset: 1 positive row and N negative rows, where N is the number of possible generator units.
  • Probability of the amount of days between today’s date and execution being lower than N weeks. This will require generating random dates between order date and execution date. The value of N is determined according to the needs of production and transportation to storage places by our client.

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_Power_Hypothesis: The comparison we’re performing. These are the values of power generators that are in stock.

Execution_Power: What really happened. We use the comparison to “Execution_Power_Hypothesis” as a target.

In green are shown the rows where the target is positive, and in red where they are negative. For instance, a sampling date of 25/2/2021 is close enough to our execution_date to consider as a positive target for prediction, while 20/2/2021 is not. In terms of execution power, the target is positive when Execution_Power_Hypothesis equals Execution_Power.

 

Model Architecture

Regarding model architecture, we can build a two stream model: we separate the features belonging to the delay between order and execution and 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). Afterwards, another set of Dense/Dropout layers transform 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 a 5000 KW generator in a building that needs 4000, 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.

Decision Process

Building an architecture of multitask classification allows us to create a decision process based on the expected value. Take into consideration the table below, which has the probability of each construction site needing a power generator with an Execution_Power_Hypothesis.

With this, we can calculate the expected amount of generators for construction ID 1 in less than N weeks (our pre-defined time period), as following:

  • 2.5 kW: 0.7 * 0.2
  • 5 kW: 0.1 * 0.2
  • 6 kW: 0.7 * 0.2

For knowing 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.

Impact Measurement

What metrics would be important to measure?

Internally, for building and evaluating your model, you can use Machine Learning metrics:

  • Classification: PR AUC, ROC AUC, …
  • Regression: Mean Absolute Error, Mean Squared Error…

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:

  • How many products did we predict/produce in excess because no one purchased them
  • How many products didn’t we predict/produce on time, leading to an extra delay in the construction

Conclusion

This blogpost has shown some different ways you can think about product forecasting problems, where there’s a lot of products with similar characteristics.

We only cover the specific case of forecasting a single product type (generators) with different power 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 by a linear layer, and create a regression model together with binary classification for time delay.

Let us know if you have a similar problem to solve and want to schedule a brainstorming session with us, at info@nilg.ai!