Assembly Line and Bayesian Networks

10 Ottobre 2022

What’s wrong in my assembly line? Ask the Bayesian Network

What is the article about

In this article I’m going to discuss one project I did for HP Inc., where I used Bayesian Networks to perform root-causes analysis for quality issues on a high-tech manufacturing line.


Bayesian Networks are a algorithm used to find cause-effects relationships between variables. It has applications in different fields, for example in medical, to diagnose conditions given symptoms. 


In this article we will discuss how we used this algorithm in an assembly line. In this case, trying to make a parallel to the medical case, the condition is a quality failure of a assembled product when inspected (out of specifications) and symptoms are the upstream processes variables.


While in other Machine Learning based algorithms every relationship is learned during training, with Bayesian Networks we need to provide to the algorithms the cause-effects relationships. If we picture the Bayesian network as a graph the structure could be 

A→B→C (A causes B, B causes C). 


What is a Bayesian Network

Bayesian Networks are probabilistic models used to assess the probability of an event based on a graph structure representing the relationships among variables and historical data. It also allows to set some evidence, as in setting some variable states to retrieve the a-posteriori probabilities. First I compute the a-priori probabilities, before any additional knowledge, and then I see how these probabilities change when I add additional information. For example, how do process variables’ parameters change after I set the evidence that a part is bad? If the change is significant, that process variable is likely to affect the failure.

Here is an example of Bayesian Network application to explain the cause behind computer failure (Horný, 2014). The cause for a computer not turning on could be either an electricity malfunction or a computer malfunction (Figure 4). Electricity failure and computer malfunction are the causes of computer failure. In terms of directed graph, they are its parents, while computer failure is the child. Once the graph structure is given, the algorithm will start computing conditional probabilities of each children given his parents – e.g. in this case if each variable is binary there will be in total 23 computed conditional probabilities, for each combination of the parent variables and for each value of the child; this will be


P(ComputerFailure=0│ElectricityFailure=0&ComputerMalfunction=0)

P(ComputerFailure=0│ElectricityFailure=0&ComputerMalfunction=1)

P(ComputerFailure=1│ElectricityFailure=1&ComputerMalfunction=1)




Once the prior-probabilities are computed, it will be possible to set the evidence and compute the posterior probabilities, i.e. P(Effect). This will correspond to probability of electricity failure given computer failure. If it turns out that the probability of a computer malfunction is higher than that of an electricity failure, effort and resources will be focused on the first potential cause. Posterior probabilities are computed using Bayes Rule,



Adding the additional variable ‘Light Failure’, as displayed in Figure 5,can help improving posterior probabilities. If P(noelectricity=0), we can set both the evidences simultaneously, Light Failure = No and Computer Failure = Yes. What would come out in the network is that posterior probability P(ElectricFailure=0). Intuitively, if the computer doesn’t turn on but the light turns on, that excludes the possibility of an Electricity Failure, so given that there are only two possible causes, the only option left is Computer Malfunction.  In cases such as this one, when there is a need for understanding which variables are responsible for an outcome or a failure, making use of an additional variable can help finding the answer.


Hands-on Session

Bayes Server is a licensed software mostly used to build Bayesian Networks in an easy way. It offers the possibility to learn nodes’ distributions as well as the structure of a network. It can be used for prediction, classification, forecasting, anomaly detection and many another use cases.


The first use case I tried was building a Bayesian Network to study failures root-causes. The first step has been importing the required data. The tool offers a built-in discretization feature. I used this option and split each of the predictors into 4 equal frequency classes. The tool will also detect automatically the variables from the dataset - which can be a database or a file from local memory, to create nodes. An alternative would be to manually create the nodes. Also, variables that take on a single value are detected and easily excluded from the model. 


Once nodes are present, the following step is adding all the edges that make the acyclic directed graph structure. The choice I made initially has been setting the nodes manually. The reason for the choice is that I wanted to prevent the tool from building links that are illogical, for instance creating nodes going from one process another that us upstream in the assembly line. 


I therefore added the nodes following mainly the flow of the line. I started from the initial process and linked each one to the one immediately following. At some stages more than one variable is measured at one step, so at those level there is an incoming edge from each one of the previous level nodes and an outgoing edge from each node towards the following level. 


For the construction of the structure I adopted for some aspects from the paper Monitoring and Diagnosis of a Multi-Stage Manufacturing Process Using Bayesian Networks. The case focuses specifically on detection of machine sensor failure by looking at the probability of having multiple discording measurements of the same part. The structure used is also a linear one along the manufacturing flow. 


 Once edges are present, the next step is learning the distributions for each variable. Again, they can be either input manually or learned from data. I opted for the second option and uploaded a table with rows as distinct parts and columns as variables, including predictors and target. This way the a-priori distributions are learned, starting from the root, which will only have the probabilities for each discrete state, down to the other nodes, which will have the conditional distributions for each combination of states of the parents. All the variables used, as already mentioned, are discrete. Nonetheless, there is the option for continuous variables, for which mean and variance must be input.


Once the parameters are learned, it will be possible to get insights about the a-posteriori distributions. If I set the evidence on the target variable to Failure Above the Specification, I can look at how much the distributions from the other variable change. If the probability of a state increases drastically then I can say it is associated with the failure.

Conclusions

Depending on the situation, the power on Bayesian Network could be different. When the subject matter expert knowledge is ground for easy manual building of the graph and, at the same time, the underlying cause and effect relationships are powerful, a-posteriori distributions can turn out helpful in explaining the logic behind an event.


Alternatively, when subject matter knowledge is lacking or when the problem is too complex to investigate, such structural learning algorithms can help explain relationships in the data and causations. Even a visual output could help experts broadening their subject understanding and consider new perspectives.


If you need some help setting up data solutions for you line, please reach out to carlo@arsolutions.it