Full text
A Comparison of Anomaly Detection Methods for Industrial Screw Tightening Diogo Ribeiro1, Lu´ıs Miguel Matos1, Paulo Cortez1, Guilherme Moreira2, and Andr´e Pilastri3 1ALGORITMI R&D Centre, Department of Information Systems, University of Minho, 4804-533 Guimar˜aes, Portugal. [email protected], [email protected], [email protected] 2Bosch Car Multimedia, Braga, Portugal [email protected] 3EPMQ - IT CCG ZGDV Institute, 4804-533 Guimar˜aes, Portugal. [email protected] Abstract. Within the context of Industry 4.0, quality assessment procedures using data-driven techniques are becoming more critical due to the generation of massive amounts of production data. In this paper, we address the detection of abnormal screw tightening processes, which is a relevant industrial task. Since labeling is costly, requiring a manual effort, we focus on unsupervised approaches. In particular, we assume a low-dimensional input screw fastening approach that is based only on angle-torque pairs. Using such pairs, we explore three main unsupervised Machine Learning (ML) algorithms: Local Outlier Factor (LOF), Isolation Forest (iForest) and a deep learning Autoencoder (AE). For benchmarking purposes, we also explore a supervised Random Forest (RF) algorithm. Several computational experiments were held by using recent industrial data with 2.8 million angle-torque pair records and a realistic and robust rolling window evaluation. Overall, high quality anomaly discrimination results were achieved by the iForest (99%) and AE (95% and 96%) unsupervised methods, which compared well against the supervised RF (99% and 91%). When compared with iForest, the AE requires less computation effort and provides faster anomaly detection response times. Keywords: Autoencoder ·Deep Learning ·Industry 4.0 ·Isolation Forest · One-class classification ·Random Forest ·Unsupervised learning. 1 Introduction The current competition market increases the pressure for industrial companies to improve their productive processes (e.g., increasing efficiency and reducing costs). Within this context, a key aspect is the reduction of assembly errors during the production of products. Following the Industry 4.0 revolution, most modern factories make use of automation and robots that are interconnected
2 D. Ribeiro et al. with data sensors. While fully autonomous robots are used in some production plants, there are still industrial tasks that require a human operator. In effect, several companies use assembly machines that combine the flexibility of robotic arms with the guidance of human operators. In particular, handheld screwdrivers are often used in assembly factories, presenting the advantage of an automatic adaption to different torque profiles. During the screw tightening process, data is collected in real-time, generating several instances with multiple features, including angle-torque pairs. Once the operation is finished, the full screw response curve is presented to the operator, who needs to accept or reject it (due to lack of quality issues) in a small amount of time. While defects are rare in this domain, they are related with a diverse range of situations, such as floating screws, stripped screws and other situations. Often, the defect is detected too late down the production chain, which results in extra production times and costs. A common approach to detect industrial screw tightening anomalies is to use a defect catalog that contains a curated set of normal and failure examples. Each time a new screw tightening is executed, the obtained angle-torque curve is compared with a predefined set of rules. However, this expert system detection method is rather static, requiring a manual collection and labeling of data. Thus, there is a potential to automate and improve the detection task by using Machine Learning (ML) algorithms. Within our knowledge, this approach has been scarcely studied. The research work more closely related with our approach was based on a Long Short-Term Memory (LSTM) neural network that uses annotated angle-torque screw responses [5]. Yet, such LSTM assumes a supervised learning that is rather impractical in several industrial settings. In effect, labeled data is costly (involving manual effort) and assembly companies typically produce big data. Thus, using a unsupervised learning for industrial screw tightening anomaly detection would result in a more valuable and automated approach. One of the challenges that anomaly detection has to address is that boundaries between normal data and abnormal data are often not clearly defined [4]. Moreover, the scarcity and diversity of anomalous data makes it a non trivial task that is typically addressed by using an unsupervised or one-class learning [19]. Under the one-class learning approach, the training datasets only contain “normal” data points and the anomaly (often termed outlier) is detected when new data is considered distant from the training learning space. In this paper, we explore a low-dimensional input approach for the anomaly detection of industrial screw tightening processes that only assumes angle-torque pairs. To model the data, we adapt three main unsupervised algorithms that are only trained with normal screw tightening process instances (thus one-class): Local Outlier Factor (LOF), Isolation Forest (iForest) and a deep learning Autoencoder (AE). For comparison purposes, we also test a supervised (two-class) Random Forest (RF). To evaluate the learning methods, we use a dataset with 2.8 million angle-torque pairs that were recently collected from an automotive multimedia assembly company. Several computational experiments were conducted by using a realistic rolling window evaluation that simulates several training and
A Comparison of Anomaly Detection Methods for Ind. Screw Tightening 3 testing iterations through time. For each iteration, both the anomaly detection performance and the computational effort were measured. This paper is organized as follows. Section 2 presents the related work. Next, Section 3 describes the collected industrial assembly data, anomaly detection learning models and evaluation procedure. Then, Section 4 presents the experimental results. Finally, Section 5 discusses the main conclusions and future work directions. 2 Related Work The topic of anomaly detection has been researched in several fields of study [6]. It is often regarded as a one-class task, since anomalous patterns are typically scarce in most datasets. Several learning methods have been proposed for an unsupervised anomaly detection, such as [1, 3]: Local Outlier Factor (LOF), One-Class Support Vector Machine (OC-SVM) and Isolation Forest (iForest). Following the success of Deep Learning, Autoencoders (AE) have been increasingly adopted for anomaly detection tasks [21]. When compared with conventional methods (e.g., LOF, OS-SVM and IF), AEs tend to provide faster training times, thus are capable of handling a larger amount of training data. In particular, the AE model can be updated to include new instances without retraining the full model [14], which is highly relevant when high velocity data is generated. Regarding the specific screwing tightening use case, the research literature involving ML approaches is scarce. For the automatic identification of behaviour patterns on blind fasteners installation, [7] presents a kernel density-based pattern methodology to classify good or bad examples. In [18], Support Vector Machine (SVMs) with different kernel functions (e.g., linear and polynomial) were used to monitor screw fastening processes on the cover of hard disks based on the driver motor data. The obtained data-driven models were then used to detect incomplete screwing processes. This work differs from ours as it correlates motor power on a time series instead of the actual handled screw driver output (e.g., angle and torque). In [15], another data-driven analysis was conducted on thread fastening tasks that used a robotic manipulator. The problem was addressed by a supervised SVM classifier, aiming to estimate how much of the screw has been inserted by using the thread vibration from a torque sensor. As explained in Section 1, the most similar related work was performed by Cao et al. [5], where a supervised learning LSTM was used to infer the quality of the assembly by analyzing the screwing tightening angle-torque curve. The main novelty of our approach is that we use a pure unsupervised one-class learning, which is more suited for high volume industrial screwing data. 3 Materials and Methods 3.1 Industrial Data Our case study is related with a major automotive multimedia assembly company, where a new fastening process starts with the insertion of several sub-parts
4 D. Ribeiro et al. (the total number varies from product to product) into the assembly jig. Then a scanner reads the imprinted barcode and the machine automatically loads the screw tightening program. Next, the human operator proceeds with an alignment of the matching pair and initiates the task. Using the help of the handheld screwdriver, the operator is guided to fasten each screw in a specific order, leaving the remaining technical details (e.g., torque and angle) to be handled automatically by the machine. Screw after screw, the operator is presented with a “Good Or Fail” (GOF) result, which is calculated automatically by the assembly machine based on its internal configuration. Each time the tightening is finished, the assembly system generates a local .csv file with all process details. All files are then imported into a centralized big data server cluster. The new data is then made available via the export of a .json file. Until this point, we have no control over the generated data stream. In this work, we have designed a Python virtual environment that is capable of retrieving the industrial data by using Apache Spark queries to the central cluster. The raw data variables of the retrieved data are summarized in Table 1. Let idenote a screw fastening procedure for some product unit, where i∈ {1,2, ..., N}and Nrepresents the total number of screw tightening processes. For each iprocess, there is a real-time generation of several k∈ {1,2,3, ..., Ki} values, where Kidenotes the total number of observations and each product unit can produce a different Kivalue. For a particular iand kvalue, the machine automatically registers the angle (αi,k) and torque (τi,k) measurements. Typically, each screw fastening produces hundreds of angle-torque pairs, such as exemplified in Fig. 1. It should be highlighted that while there is no direct temporal variable, the angle (αi,k) attribute can be used as sequential or temporal measure of the fastening, since in almost cases its value increases as the procedure continues. A tightening process is composed of four main steps s∈ {1,2,3,4}(Table 2). In order to succeed at combining sub-parts, every screw must sequentially meet the transition conditions of each step within the parameterized time. The steps are exemplified in Fig. 1, where the short blue curve denotes the initial rotation (step s=0) used to catch the screw and the remainder curve colors (s= 1 – red, s= 2 – green, s= 3 –purple and s= 4 – orange) denote the four main fastening steps. For each step, the screw fastening tool stores the step number, total angle and torque values. At the beginning of step s=4, the fastening tool computes an estimate of the DTM Clamping Angle (dtmclampt). Once the process is nearly finishing, the real DTM Clamping Angle is measured (dtmclampa). Then, the final GOF result is computed by the screw assembly machine (attribute screwgof). In this work, we adopt the last variable (screwgof attribute) as the supervised label of the screwing process. Thus, this variable, denoted as yifor the i-th screw tightening process, is used to select the instances for learning methods (e.g., only normal examples are fed into the one-class methods) and also to define the normal and abnormal labels used to evaluate the models (when using test “unseen” data). The values were directly computed by the assembly machine
A Comparison of Anomaly Detection Methods for Ind. Screw Tightening 5 Table 1. Description of the industrial screw tightening data variables. Variable Description Hundreds of values per screw fastening (k): angle (αi,k) Value for the angle (e.g., -208.1 degrees) torque (τi,k) Value for the torque (e.g., 35.6 Ncm) gradient Torque gradient for two consecutive angle values (e.g., 20) Four values per fastening (one for each step): stepnr Screwing step number (s∈{1,2,3,4}) tstepangle Total step angle (e.g., 990 degrees) tsteptorque Total step torque (e.g., 39.3) One value per fastening (i): dtmclampa Value for actual DTM Clamp (e.g., 79.1) dtmclampt Value for predicted DTM Clamp (e.g., 30.2) timestamp Timestamp (e.g., “2020-10-08 06:30:51”) product Product family identifier (e.g., “2222111) serial Product serial number (e.g., “11111) screwnr Screw number (∈{1,2,...,8}) screwenergy Total energy required (e.g., 19959) totalangle Total angle (e.g., 2993 degrees) totaltorque Total torque (e.g., 30000 Ncm) screwgof (yi) Screwing process “Good” (1) or “Fail” (0) 0 500 1000 1500 2000 2500 3000 angle 0 10 20 30 40 50 60 70 torque stepnr 0 1 2 3 4 Fig. 1. Example of a normal (“Good”) screw tightening.
6 D. Ribeiro et al. Table 2. Description of the screw fastening process steps. Step Description Transition condition Simple torque (s=1) Serves as a transition to the next step when the thread starts to be formed. Achieve either the transition torque or angle within the parameterized time range. Angle (s=2) Fixed number of turns conducted. Min Angle <Angle Target <Max Angle within stipulated time. Torque (s=3) Apply a fixed torque value. Min Torque <Torque Target <Max Torque within stipulated time. Seating control (s=4) Apply a torque value from the screw seating value to the part. Clamping Torque <Max Seating Torque; Min Total Angle <Total Angle <Max Total Angle; Min Total Torque <Total Torque <Max Total Torque. software tool, which includes a rather rigid internal set of rules that define a normal fastening cycle (based on a catalog of normal and abnormal examples). It should be noted that in a few cases, this assembly tool provides a wrong labeling, such as classifying a fastening cycle as normal when it actually was a defect. However, since we have big data and it is costly to manually verify all fastening cycles, we assume here that the provided yivalues are a reasonable oracle for testing the proposed anomaly detection methods (which do not use any labels). In terms of preprocessing, we grouped all records by product family (product), serial number (serial) and screw number (screwnr, maximum of 8 screws per individual unit). This grouping allows a fast identification of all kvalues related with a tightening process (i), which is useful for anomaly detection evaluation purposes. The resulting dataset corresponds to around two days of screw tightening processes, collected in November of 2020, and it includes a total of 2,853,967 entries related with N=6,162 fastening cycles. On average, there is around Ki=463 records (angle-torque pairs) per cycle. Moreover, the dataset is highly unbalanced. In effect, there are 74 defects that correspond to only 2% of the screw tightening cycles. 3.2 Anomaly Detection Angle-Torque Approach There are two screw tightening anomaly detection goals. The first and most important goal is to automatically detect if there has been a failure in the screw fastening cycle (yi=“Fail”). Once a failure has been detected, the secondary goal is to automatically identify where (within the full cycle) the defect took place. The secondary goal is needed to fine tune the detection details, providing additional information that helps the human operator to accept the machine learning result.
A Comparison of Anomaly Detection Methods for Ind. Screw Tightening 7 In this work, we assume that each anomaly detection model outputs a decision score (di), such that the higher the score, the more probable is the chance that an anomaly has occurred for the i-th tightening screw process. In order to achieve both goals simultaneously, the anomaly detection methods are fed with the all individual and more instant kvalues (one at the time). This means that each i-th screw fastening produces a total of k∈ {1,2, ...Ki}examples that are used for training or testing purposes, resulting in di,k anomaly decision scores. To compute the overall decision score di(thus perform the main goal), the individual scores are averaged, thus di=Pkdi,k/Ki. For distinct ivalues, the resulting scores (di) can be compared with the target variable (yi), allowing the computation of the Receiver Operating Characteristic (ROC) curve [8]. If class labels are needed, then a fixed Th threshold value needs to be set, such that the i-th output is interpreted as an anomaly if di> Th. The specific Th can be selected by using historical unlabeled data (e.g., by adopting a given percentage above the maximum AE reconstruction error) or by selecting the best specificity-sensitivity trade-off from a ROC curve that is generated when using a labeled validation set. As for the secondary goal, if fine-grained target values (yi,k) were available, then the individual decision scores (di,k) could be used to generate ROC curves or other classification performance measures. Since our dataset does not contain any fine-grained target labels, we will adopt a fixed threshold to demonstrate the applicability of the secondary goal but without robustly studying it. Moreover, given that we use pure unsupervised ML models, the threshold will be set using historical unlabeled data (see Section 4). Regarding the input features, the industrial screw tightening data includes several attributes with different granularities (Table 1): fine-grained – angle (αi,k), torque (τi,k) and gradient; step-grained – step number, total step angle and torque; and one per each i-th tightening – such as dtmclampa,screwenergy and yi. To select the input variables (and also to tune the AE models, see Section 3.3), we conducted preliminary experiments by considering only the training data of the first rolling window iteration, thus related with the oldest data records (Section 3.4). This oldest training data was further split into training (to fit the models, with W−Ttightening screw processes) and validation sets (with Ttightening cycles). In particular, we initially tested anomaly detection models that were fed with all possible input variables (e.g., angle, torque, gradient, total step angle, energy). However, the obtained models provided substantially worst results when compared with the low-dimensional angle-torque input approach. Moreover, the full input anomaly detection models required much more memory and computational effort. In some cases, such as when using LOF, the computational training process even halted due to an out-of-memory issue. Based on these results, all screw anomaly methods described in this work assume just two input values: the simpler angle-torque pairs (αi,k, τi,k) for each (i, k) example. 3.3 Learning Models Three unsupervised learning algorithms were selected for the empirical comparison: LOF, iForest and a AE. These methods are are only trained with normal
8 D. Ribeiro et al. cases (one-class approach). For benchmarking purposes, we selected the popular Random Forest (RF) method. However, we note that RF is a supervised learning method that, contrary to the one-class methods, requires labeled data for the training procedure. Thus, RF was trained with both normal and abnormal angle-torque instances. To implement the methods we used the scikit-learn (for RF, LOF and iForest) [16] and TensorFlow (for AE) [9] Python modules. At an initial stage, we also explored the OC-SVM implementation of scikit-learn. However, our training sets are too large for the algorithm, which did not compute results in an affordable time (e.g., the first rolling window iteration execution was halted after 40 hours of execution time). In order to provide a fair comparison, and also reduce the computational effort, in the experiments we assumed in general the default scikit-learn and keras hyperparameter values. Before feeding the models, all angle-torque data values were first normalized, where the numeric values were transformed to fit into a [0,1] scale by using a max-min normalization, via the MinMaxScaler procedure of the sklearn module. Unlike the other anomaly detection methods, LOF is a density-based algorithm that heavily depends on K-nearest neighbors [3]. It is designed as local because it depends on how well isolated an object is from the surrounding neighborhood. Instead of classifying an object as being an outlier or an inlier, an outlier factor is assigned describing up to which degree the object differs from the rest of the dataset. It should be noted that LOF can be used to detect both local and global outliers. Moreover, it can be trained with multi-class instances. In this paper, in order to provide a fair comparison, we only use normal examples to fit the model, where the outlier factor score is directly used as the anomaly decision score (di,k). Isolation Forests (iForest) take advantage of two major characteristics of anomalous points: they are present in fewer quantities and are also numerically different to normal instances. This means that anomalous instances are prone to be more easily isolated (separated from the rest of the instances) than normal points. Using this principle, an anomaly detection method can be based on the construction of a tree structure to isolate every single instance and then evaluate their normality. Due to their nature and tendency to be quickly isolated, abnormal instances are closer to the root of the tree. This characteristic, also known as Isolation Tree or iTree, forms the basis of anomaly detection for this model. An iForest [13] is based on an ensemble of iTrees for a given dataset. Anomalies are the instances that are closer to the root of the tree and will have shorter average path lengths. The scikit-learn provides an anomaly score that ranges from ˆyi,k =-1 (highest abnormal score) to ˆyi,k =1 (highest normal score). Thus, we rescaled these scores into the [0,1] anomaly probability range by computing di,k = (1 −ˆyi,k)/2. Autoencoders (AE) are unsupervised learning techniques that efficiently compresses and encode data to a lower-dimensional representation [10]. The includes an encoding stage, where compression occurs by reducing the input data (the number of features describing the dataset) into a latent space (defined by a bot-
A Comparison of Anomaly Detection Methods for Ind. Screw Tightening 9 tleneck layer), and a decoding stage, where the model tries to reconstruct the original data from the latent space. When adapted for our anomaly detection case, the training algorithm is only fed with normal instances and it attempts to generate two output values (ˆαi,k,ˆτi,k) that are identical to its inputs (αi,k, τi,k). When a new (i, k) instance is evaluated, we compute the Mean Absolute Error (MAE) [1]: MAEi,k = (|αi,k −ˆαi,k|+|τi,k −ˆτi,k|)/2 (1) This reconstruction error is used as the decision score di,k =MAEi,k, where higher reconstruction errors should denote a higher anomaly probability. In terms of the deep AE architecture, we assume a dense AE with two inputs (αi,k, τi,k), two output nodes and a fully-connected structure that includes a stack of layers in both the encoder and decoder components. All hidden layers use the popular ReLU activation function, while the output nodes assume the logistic function (all inputs are normalized ∈[0,1]). Every hidden layer is also attached with a Batch Normalization layer, which reduces the internal covariate shift, discards the need of dropout layers and normalizes the layer inputs for each batch of data that passes through it [12]. In order to define the number of layers and units per layer, we performed several trial-and-error preliminary experiments. These experiments assume the same oldest training data used to set the input variables (Section 3.2). The tested architectures use a bottleneck layer with 1 hidden node (to define the latent space) and a varying range of hidden layers. The best results, measured in terms of the lowest reconstruction error for the validation set, were achieved for an AE with 20 layers (including the input, Batch Normalization and output layers), as shown in Fig. 2. In this work, the selected AE is trained with the Adam optimization algorithm using the MAE loss function, a total of 100 epochs and early stopping (with 5% of the training data being used as the validation set). 1 1 22 1 Input Features Encoder 2 BN BN 1 BN Latent Space BN 1 1 BN 2 BN Input Features Decoder BN BN BN Fig. 2. The adopted dense AutoEncoder (AE) structure (the numbers denote the number of hidden units per layer and the term BN represents a Batch Normalization layer). As explained in Section 2, the AE model can be adapted to dynamic environments when there are frequent data updates. In [14], two neural network learning modes were compared: reset and reuse. When new data arrives and the neural network is retrained, the former assumes a random weight initialization, while the latter uses the previously trained weights as the initial set of weights. In this work, we compare both learning modes when executing the rolling window evaluation.
16 D. Ribeiro et al. 8. Fawcett, T.: An introduction to ROC analysis. Pattern Recognit. Lett. 27(8), 861– 874 (2006). https://doi.org/10.1016/j.patrec.2005.10.010 9. Gulli, A., Pal, S.: Deep learning with Keras. Packt Publishing Ltd (2017) 10. Hinton, G., Salakhutdinov, R.: Reducing the dimensionality of data with neural networks. Science 313(5786), 504–507 (2006). https://doi.org/10.1126/science.1127647 11. Hollander, M., Wolfe, D.A., Chicken, E.: Nonparametric statistical methods. John Wiley & Sons (2013) 12. Ioffe, S., Szegedy, C.: Batch normalization: Accelerating deep network training by reducing internal covariate shift. In: Bach, F.R., Blei, D.M. (eds.) Proceedings of the 32nd International Conference on Machine Learning, ICML 2015, Lille, France, 6-11 July 2015. JMLR Workshop and Conference Proceedings, vol. 37, pp. 448–456. JMLR.org (2015) 13. Liu, F.T., Ting, K.M., Zhou, Z.: Isolation forest. In: Proceedings of the 8th IEEE International Conference on Data Mining (ICDM 2008), December 15-19, 2008, Pisa, Italy. pp. 413–422. IEEE Computer Society (2008). https://doi.org/10.1109/ICDM.2008.17, https://doi.org/10.1109/ICDM.2008.17 14. Matos, L.M., Cortez, P., Mendes, R., Moreau, A.: Using deep learning for mobile marketing user conversion prediction. In: International Joint Conference on Neural Networks, IJCNN 2019 Budapest, Hungary, July 14-19, 2019. pp. 1–8. IEEE (2019). https://doi.org/10.1109/IJCNN.2019.8851888 15. Matsuno, T., Huang, J., Fukuda, T.: Fault detection algorithm for external thread fastening by robotic manipulator using linear support vector machine classifier. In: 2013 IEEE International Conference on Robotics and Automation, Karlsruhe, Germany, May 6-10, 2013. pp. 3443–3450. IEEE (2013). https://doi.org/10.1109/ICRA.2013.6631058 16. Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., VanderPlas, J., Passos, A., Cournapeau, D., Brucher, M., Perrot, M., Duchesnay, E.: Scikitlearn: Machine learning in python. J. Mach. Learn. Res. 12, 2825–2830 (2011), http://dl.acm.org/citation.cfm?id=2078195 17. Pereira, P.J., Cortez, P., Mendes, R.: Multi-objective grammatical evolution of decision trees for mobile marketing user conversion prediction. Expert Syst. Appl. 168, 114287 (2021). https://doi.org/10.1016/j.eswa.2020.114287 18. Ponpitakchai, S.: Monitoring Screw Fastening Process: an Application of SVM Classification. Naresuan University Engineering Journal (NUEJ) 11(2), 1–5 (2016). https://doi.org/https://doi.org/10.14456/nuej.2016.11 19. Ruff, L., G¨ornitz, N., Deecke, L., Siddiqui, S.A., Vandermeulen, R.A., Binder, A., M¨uller, E., Kloft, M.: Deep one-class classification. In: Dy, J.G., Krause, A. (eds.) Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsm¨assan, Stockholm, Sweden, July 10-15, 2018. Proceedings of Machine Learning Research, vol. 80, pp. 4390–4399. PMLR (2018), http://proceedings.mlr.press/v80/ruff18a.html 20. Tashman, L.J.: Out-of-sample tests of forecasting accuracy: an analysis and review. International Journal of Forecasting 16(4), 437 – 450 (2000). https://doi.org/10.1016/S0169-2070(00)00065-0 21. Zhou, C., Paffenroth, R.C.: Anomaly detection with robust deep autoencoders. In: Proceedings of the 23rd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, Halifax, NS, Canada, August 13 - 17, 2017. pp. 665– 674. ACM (2017). https://doi.org/10.1145/3097983.3098052