{'fraction_non_alphanumeric': 0.0384850069735007, 'fraction_numerical': 0.008150278940027894, 'mean_word_length': 4.251773861295491, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Learning Causal Graphs in Manufacturing Domains using Structural Equation Models

Many production processes are characterized by numerous and complex cause-and-effect relationships. Since they are only partially known they pose a challenge to effective process control. In this work we present how Structural Equation Models can be used for deriving cause-and-effect relationships from the combination of prior knowledge and process data in the manufacturing domain. Compared to existing applications, we do not assume linear relationships leading to more informative results.


I. INTRODUCTION
To be published in the Proceedings of IEEE AI4I 2022. Complex manufacturing processes as, e.g. for battery cells show high scrap rates and thus high production costs and large environmental footprints. One of the driving factors is the missing knowledge on the interdependencies between the process parameters, intermediate product properties and the quality characteristics [1]. Together we call this the causeand-effect relationships (CERs). CERs can be visualized as a network with the process and product characteristics as nodes and the CERs as directed edges [1], [2]. It is the goal of our paper to unify expert knowledge and process data to derive such a network, which allows the visual identification of • root-causes of erroneous products, • relevant parameters for process control during successive production steps and • important characteristics to predict the quality of the final product.
In complex manufacturing domains, CERs form a linked mesh of hundreds of involved factors [1]. Typically, CERs are derived by running Designs of Experiments (DOEs). However, DOEs can be time-demanding and the production line has to be stopped in the meantime leading to prohibitively high costs. Moreover, if there are many potential CERs, the number of experiments can become infeasible. At the same time, the Internet of Things (IoT) allows data processing and storage along the whole production line, leading to a vast amount of accessible information. It is thus desirable to derive the CERs from the existing observational (or nonexperimental) data. For this purpose, Bayesian Networks can be used to unify expert knowledge and data. From these, CERs can be derived under the assumption of causal sufficiency [3]. This approach is called causal discovery or structure learning. The most common example in the manufacturing domain [4]- [6], is the PC algorithm [3]. This algorithm relies on the assumption of faithfulness and on efficient statistical tests for conditional independence. In principle the PC algorithm can be applied with any test for conditional independence. However, existing nonparametric tests do not scale well [7], [8]. Most of the applications of the PC algorithm either discretize the measurements, or researchers approximate the joint distribution of the variables by a multivariate normal distribution. For discrete data and normally distributed data fast tests for conditional independence exist. However, the former leads to a loss of information, while the latter requires a linear dependency between the variables to be exact. In case of manufacturing data this is most likely a misspecification [9]. Simulation studies show, that the performance of the PC algorithm can be poor in case of non-linearity [10]. This questions the application of the PC algorithm for large or highdimensional manufacturing data. In recent years, Structural Equation Models (SEM), which can incorporate arbitrary functional relationships, were increasingly proposed to derive Causal Bayesian Networks. They replace the assumption on faithfulness by a functional form of the conditional distributions (see Equation (1)). While the PC algorithm returns a set of graphs, methods based on SEMs often derive a single graph. To the best of our knowledge, we are the first to apply SEMs to derive such graphical models in the manufacturing domain. The paper is structured as follows. In Section II we present potential prior knowledge and available data in manufacturing domains. We continue in Section III by reviewing Bayesian Networks and SEMs and explain Causal Additive Models (CAM). In Section IV we present an extension of CAM, called TCAM, which efficiently incorporates prior knowledge. We apply our method in Section V to process data of the assembly of battery modules at BMW. We conclude in Section VI.

II. DATA AND CHALLENGES IN COMPLEX MANUFACTURING DOMAINS
In this section we describe the data sources and propose a preprocessing of the data. Then, we explain the broad prior knowledge in manufacturing domains. Finally, we mention common challenges with production data.
A. Data Sources along the Production Line The assembly of products consists of production lines, which again contain several stations, which are passed in a fixed order and where process steps are carried out. During those process steps the piece is transformed or it is combined with other parts in order to achieve a predefined outcome. All involved parts are assigned to unique identifiers. Data of different types is collected along the production process: • Process data: the stations take measurements of the involved parts (e.g. thickness of the piece) and the parameters of the machine (e.g. weight of applied glue). • End-of-Line (EoL) tests take additional quality measurements of the intermediate or final products. • Station information: at some production steps the pieces are spread out to identical stations, such that parts can be processed in parallel and every piece is assigned to one of the stations. • Bill of Material (BoM): the BoM contains the information which pieces were merged together and on which position they have been worked in. • Supplier data: suppliers transmit data on provided goods. The preprocessing of the data, which is depicted in Figure 1, consists of the following steps: 1) Collect the data for every intermediate product.
2) Iteratively merge the data of all subcomponents of a final product. Measurements of identical subcomponents, which are placed in the same position, can be found in the same column. Eventually, the final tabular data set contains all measurements that can be associated with a final product.

B. Prior Knowledge
As the stations are passed in a fixed order, we know that CERs across different stations can only act forward in time. Additonally, in many manufacturing organizations, tools as the Failure Mode and Effect Analysis (FMEA) [11] are implemented to extract expert knowledge on CERs in the production process and to provide the information in a structured form.

C. Challenges of Data Analysis in Manufacturing
Often, similar information is recorded multiple times along the production line, leading to multicollinearity [4]. Also, sensors might deliver non-informative data by recording implausible values. Industrial data is also reported to be drifting over time. However, even in shorter time intervals, data of a series production contains thousands of observations. This distinguishes the manufacturing domain from other applications of causal discovery as medicine, genetics or the social sciences.

III. STRUCTURE LEARNING OF GRAPHICAL MODELS A. Some Preliminaries on Graphical Models
Let G = (V, E) be a directed acyclic graph (DAG) [12,Chapter 6] Nodes that can be reached from X j through a directed path are called the descendants of X j . In the following we denote random vectors with bold letters as Z and random variables as Z. Let X = (X 1 , . . . , X p ) be a random vector representing the data generating process. For a graph G with nodes X 1 , . . . , X p , we call (X, G) a Bayesian network if the local Markov property holds, i.e.
for any X j that is not a descendant of X i in G. Here, X ⊥ Y |Z denotes the conditional independence of X and Y given Z. In that case, we can deduce additional conditional independencies for X from the graph G using the concept of d-separation [12]. For a Bayesian Network (X, G), it then holds that X i ⊥ X j |S if X i and X j are d-separated by S in G. On the other hand, if there is a graph G, such that X i ⊥ X j |S implies that X i and X j are d-separated given S in G, then X is called faithful with respect to G. As multiple graphs can contain the same d-separations, this graph G is in general not unique. To promote the intuition, assume that X has a joint density f . Then X i ⊥ X j |S can be characterized by where f (x i |Z = z) denotes the conditional density function of X i given Z = z. Thus, if we already know S, then X j does not provide additional information on X i . Assume that we are interested which variable in {X j , X S } causes the variable X i to be out of the specification limits. Then we know, that the root causes can be found within S.

B. Graph Learning with Structural Equation Models
While the PC algorithm is the classic approach for deriving a Causal Bayesian Network, recent research focused on identifying it using acyclic SEMs [10], [13]- [15]. They assume that there exists a permutation Π 0 (1, . . . , p) = π 0 (1), . . . , π 0 (p) and functions {f , = 1, . . . , p}, such that where π 0 ( k ) < π 0 ( ) for all k = 1, . . . , v and ε 1 , . . . , ε p are i.i.d. noise terms. As the estimation of f in Equation (1) is difficult in high dimensions, one typically restricts the function class and the distribution of the noise terms. In this work, we assume that the functions follow the additive form where ε ∼ N (0, σ ) and c ∈ R. To ensure the uniqueness of the f k, and without loss of generality, we set E (X ) = 0 combined to final data set: and E (f k, (X k )) = 0, for all = 1, . . . , p, π 0 (k) < π 0 ( ). From Equations (1) and (2) we derive that and only if f k, = 0. Let G 0 be the graph on X 1 , . . . , X p , that contains the edge X i → X j if and only if f i,j = 0 for π 0 (i) < π 0 (j). Then (X, G 0 ) is a Bayesian network, as it is fulfilling the Markov property. If we assume that the functions f k, in Equation (2) are nonlinear and smooth, then [15] show that G 0 is identifiable from observational data. This is in contrast to the PC algorithm, which typically returns a class of graphs. Note that we do not presume that the distribution is faithful to some DAG, which is a central assumption of the PC algorithm. We emphasize that for the PC algorithm non-linearity is an obstacle as efficient conditional independence testing is just feasible for multivariate normal data. In contrast, we can utilize the nonlinearity for identifying SEMs to receive more informative results (under the assumption of Equation (2)). An example of a learning algorithm for SEMs is the Causal Additive Model (CAM, [10]). We will focus on CAM due to its applicability to high-dimensional data, its ability to capture non-linearity and due to the theoretical justification that G 0 can be identified, if the functions on the right-hand side of Equation 2 are nonlinear and smooth. [10] propose to find G 0 with the following steps: 1) Find the underlying node ordering Π 0 of X 1 , . . . , X p .
2) Identify the influential functions f k, with feature selection methods. To make things more precise, consider N observations (x i1 , . . . , x ip ) , i = 1, . . . , N from X and call the data matrix D ∈ R N ×p .
1) Finding the node ordering: [10] show that if • the functions f k, are smooth and non-linear and can be approximated well and • the derivatives of f k, and the fourth moments of f k, (X k ) and X k are bounded. then the following estimator for Π 0 is consistent as N → ∞: Here, we define ||x k || 2 2,N := 1 N N k=1 x 2 k and f k, is found by running an additive model regression [16] of X on {X k : π(k) < π( )}. For large p, [10] propose a greedy method to findΠ. Let G be a DAG on X with edges E(G). For simplicity we denote the edge X k → X by (k, ). A score for G is defined by The functions f k, are estimated by running an additive model regression of X on its parents in G. Intuitively, S(G) indicates how much variation of D is captured by G. The edges that can be added to G without causing cycles are denoted by Starting with the empty graph G 0 , [10] iteratively add the edge The functions f k, are found by regressing X on its parents in G t , while f k, are found by regressing X on its parents in G = (X, E(G t ) ∪ {(k , )}). Thus, the edge (k 0 , 0 ) maximally reduces the unexplained variance. We set G t+1 = (X, E(G t ) ∪ {(k 0 , 0 )}) and continue until we obtain a complete DAG, which implies the node ordering. This greedy method is still computationally intense for large p. Thus, [10] propose to take advantage of sparse structures, where p is large but the number of edges in the graph is assumed to be small: to this end they start by a preliminary neighborhood selection (PNS) step. Here, initially for every ∈ {1, . . . , p} a superset of neighbors of X in G 0 is identified. In the subsequent node ordering step, one only considers the superset of the neighbors, when greedily adding new edges. This reduces the computation time of the algorithm significantly, if the sizes of the supersets are considerably smaller than p.
2) Identifying edges: After the node ordering is set, we need to identify the influential characteristics for every X among those X k for whichπ(k) <π( ). The idea is to detect those f k, which are not 0, using feature selection methods [16], [17]. For those k, a change in X k has an effect on X . For a comparison of CAM and the PC algorithm based on simulated data sets with known ground truth, see [10].

IV. METHODOLOGY
The goal of this section is to derive a method that combines the current results on structure learning of SEMs with the features of the manufacturing domain in Section II.

A. Recap of Common Prior Knowledge
Compared to other applications of causal discovery, it is typical for the manufacturing domain, that there exists prior knowledge, see Section II. In particular, there is a partial and transitive ordering of the variables implied by the stations' ordering. Additionally, we include expertise on the absence of edges. Both facets shall improve the algorithm's runtime.

B. Adaptions to CAM
The data generating process behind manufacturing data sets often leads to a low number of conditional independencies in X, when compared to p. Thus, the Causal Bayesian Network of X is not sparse. This poses a challenge to many structural learning algorithms in higher dimensions. We show in this subsection how prior knowledge on the node ordering and the existence of edges can be incorporated so that structure learning remains feasible. To formalize our prior knowledge, let t : {1, . . . , p} → {1, . . . , T }, so that t(k) < t( ) means that there can only be edges from X k to X but not vice versa. Further, let F be a boolean matrix, where F k, = True if the edge from X k to X is known to be absent.
1) Preliminary Neighborhood Selection: For every measurement X , we determine a set of possible parents among those k, where F k, = False and t(k) ≤ t( ). Denote that set for index by P .
2) Node Ordering: We start by adding all potential edges that go across stations and add them to the initial graph G 0 , as those can not cause any cycle. The score of G 0 hence is We continue by determining the node ordering as in Section III-B. Note that we only need to determine the node ordering for indices k, so that t(k) = t( ). The initial inclusion of across-station-edges saves update steps of M (Equation 4). This makes the algorithm feasible even for non-sparse highdimensional settings, if the number of tiers T or the number of edges known to be absent is sufficiently large.
3) Pruning: The pruning step is identical to CAM. In the manufacturing industry, the prior knowledge on t(k) < t(l) is often given by the temporal nature of the production process. We therefore call our adaption TCAM (Temporal Causal Additive Models). It is sketched in Algorithm 1. The energy storage of electric vehicles is called a battery pack which is composed of battery modules, which in turn contain a fixed number of battery cells. A battery module connects the battery cells in series or parallel and it protects those cells against shock, vibration and heat. Thus, the battery module is a key component for the safety of battery-electric vehicles. We apply TCAM to data collected at the assembly at BMW. The data set under investigation contains 7254 battery modules with 738 variables each.

A. Data Preparation
As the missing values rate is low (around 2.4%) we apply naive mean imputation instead of more sophisticated method as [18]- [20]. We then continue by removing features that have only one distinct value and hence provide no information.
As this data set also shows multicollinearity, we apply an expert-based approach. We asked experts to identify clusters of variables containing similar information and to define representatives for them. For a purely data-driven approach in manufacturing, see [5]. Those steps reduced the number of characteristics from 738 to 491. Finally, we standardize the data so the variables' empirical mean and standard deviation is 0 and 1 respectively. Beyond the temporal ordering of the stations, it is reasonable that the production measurements of identical intermediate products as depicted in Figure 1 are independent. Thus, it is possible to restrict the potential edges that have to be considered. Additionally, we assume that some of the recorded measurements as the facility temperature and the selection of the stations are not affected by other measurements. We can mark those values as root nodes, meaning that they have no incoming edges. This further restricts the number and orientation of possible edges.
B. Choice of Software and Hyperparameters 1) Preliminary Neighborhood Selection: For our application of TCAM, we find supersets of the neighbors by applying the LASSO. For ∈ {1, . . . , p}, we run a regression of X on those components of X, which are possible parents according to our prior knowledge. Going forward we mark those variables as potential parents of X , where the corresponding regression coefficient is above 10 −2 . The penalty parameter λ is chosen via cross-validation. Let λ min be the penalty parameter that minimizes the mean squared cross-validation error. Then we choose the maximal λ such that the mean cross-validation error is within one standard deviation of the minimum λ min .
2) Node Ordering and Pruning: For the node ordering we employ the package mgcv by [16]. Let us call the graph after node ordering G N O . In the pruning step we run a sparse additive regressions of X on its parents in G N O for = 1, . . . , p. This step returns p-values for the parents of X in G N O . We follow [10] and set the regressands as parents of X in the final graph, whose p-values are below the threshold of 10 −3 . Fig. 2. Resulting graph of TCAM where the nodes correspond to characteristics of the product and edges correspond to detected CERs. The node coloring is according to the station, where the variable was measured. Edge colors are according to respective source node's color. The blue box highlights the detected relationship between the choice of the stations (green nodes) and the product quality (blue nodes). The red box depicts the similarities between structures of identical subcomponents.

C. Results
The resulting graph is depicted in Figure 2 and contains 491 nodes and 859 edges. We observe that there are a few nodes that have a large number of neighbors. In general this poses a difficulty for most structure learning algorithms and CAM did not finish in reasonable time. For details on the runtime for a low-dimensional special case, see Section V-D. With TCAM and the inclusion of prior knowledge we were able to overcome those obstacles. Further, substructures of identical parts show similar patterns. The red box in Figure 2, highlights patterns consisting of two linked clusters, where one cluster consists of four nodes, while the other one consists of three nodes. Together with process experts we could further verify that many CERs detected by TCAM are plausible. This application is confidential, but we would still like to share one of the insights. TCAM discovered a CER between one station that processed the part and the part's quality. Experts derived that the maintenance of that station was overdue and the CER can be used to find better maintenance intervals. This is one example how graphical models can contribute to an effective and proactive process control.

D. Evaluation against Expert Knowledge
For the characteristics of one of the subcomponents, we derived an expert-based graph, which is depicted in Figure 3. Here, the blue CERs potentially exist, while green CERs surely Fig. 3. Expert-based graph on measurements for subcomponents. The green edges are known to exist, while the blue edges potentially exist. Edges beyond the ones depicted are known to be absent. The darker the node, the later the corresponding variable is measured in the production process.  I  THE AVERAGE  exist. Other CERs can be ruled out. We compare the estimated graphs and runtimes of TCAM, CAM and a variant of the PC algorithm called TPC [21], which allows the inclusion of temporal background knowledge. The significance level is set to 0.01. We run 500 experiments, where we randomly draw 500 subcomponents, while each of them appears in at most one of the runs. We define an adapted Structural Hamming Distance (aSHD) [22] between an estimated graph G est and the one in Figure 3 by the sum over the number of green edges that are not in G est and the number of edges G est that do not appear in Figure 3. The results are depicted in Table I. TPC and TCAM perform better than CAM, which shows the advantage of the inclusion of prior knowledge. Additionally, even in this low-dimensional setting the average runtime for TCAM is smaller than for CAM. Further, we observe that the aSHD of TCAM and TPC is on average quite similar. However, the standard deviation of the aSHD and the standard deviation of the number of edges is smaller for TCAM. This indicates that TCAM delivers more stable and informative results in the manufacturing domain. The original PC algorithm performed worse than TPC and is omitted.

VI. CONCLUSION
We have presented a method to derive the graphical representation of CERs of manufacturing processes based on SEMs. While existing approaches for causal discovery in the manufacturing domain assumed linear relationships between the process characteristics, we applied CAM to find arbitrary additive functional relationships in data. We showed how existing prior domain knowledge can be included and improves the computational burden of CAM. A case study on manufacturing data reveals that the learned graph detects unknown root-causes, delivers more informative results and paves the way to an efficient and proactive process control.