A Model for Robot Arm Pattern Identification using K-Means Clustering and Multi-Layer Perceptron Model Identifikasi Pergerakan Lengan Robot menggunakan K-Means Clustering dan Multi-Layer Perceptron

Predictive maintenance of industrial machines is one of the challenging applications in Industry 4.0. This paper presents a comprehensive methodology to identify robot arm (SCARA) movement patterns to detect the mechanical aging of the robot, which is determined by the abnormal movement of the robot arm. The dataset used is two robot arm movements that go from point A to B and then back to point A. Accelerometer data is used to measure the signal of SCARA actions, mainly focus on the non-linear movement. The identification of the movement pattern of the robot arm is made by combining k-means and multilayer perceptron. The proposed approach first extracts valuable features as characteristics of the two datasets from the time domain statistical value parameters. K-means clustering technique is initiated to label the training dataset. In this phase, the elbow curve is used to determine the number of clusters in the dataset, which is 2 clusters. Moreover, the assumption is used to determine which cluster is labeled as a normal and abnormal movement. Hence, a multilayer perceptron approach is proposed to predict the testing dataset. The proposed multilayer perceptron model yields an accuracy of 94.14%, whereas its cross-validation yields an accuracy of 96.12%.


INTRODUCTION
The trends of labor shortages, short commodities cycles, small orders, significant variations, and frequent changeovers has an impact to the manufacturing industries. In response to the mentioned urgencies, more intelligent and flexible workstations are needed in the production lines. For instance, electronic manufacturing processes must be agile and precise in order to shorten operation time and increase efficiency.
Robot manipulators are essential production machines in many industrial and manufacturing environments. Due to its high speed and high accuracy, robot manipulator has been used in varied applications (Zhang et al., 2016). Selective Compliance Assembly Robot Arm (SCARA) is an industrial robot that can reduce labor costs and strengthen manufacturing flexibility. The SCARA robot has a prismatic joint and 3 (three) rotary joints whose axes parallel each other. SCARA system compliant with the X-axis and Y-axis direction and has good rigidity in the Z-axis direction. It has another feature; its series of two structures are similar to human arms (Zhang et al., 2016). It can be programmed to make the machine perform the corresponding work, and it can also change the program to complete a variety of work (Chen and Patton, 2012). SCARA can perform various production jobs such as assembly, insertion, screw locking, loading and unloading, pick-and-place, stacking, and packaging. Finally, SCARA can effectively perform intelligent identification, inspection, and sorting using its vision systems to reduce defect rates for consistent quality delivery.
However, many triggers can lead to faults in industrial robots. Brake failures caused by wear (Bittencourt et al., 2014) and motor faults caused by short circuits (Fantuzzi et al., 2003) are two examples. Due to the risk of loss on robot operation, condition-based maintenance methods have been studied vigorously to perform scheduling maintenance actions based on the machine's condition, measured without interrupting the normal machine operations. Condition monitoring can be defined as a decision-making strategy that assists real-time diagnosis of occurring failures and forecasts future health of the machine's health by continuously observing the condition of its component and system (Peng et al., 2010). It can also be defined as regularly collecting information about engine conditions to detect failures or deterioration on it. A significant loss of productivity can be prevented by adopting successful strategies for failure detection (Ruishu et al., 2018).
Based on most common cases, in datadriven predictive maintenance modeling, the record of failure or abnormal period must be contained in the dataset as a true value. However, several cases does not have anomaly identification in the historical data, so that classical data-driven approaches cannot be conducted (Borgi et al., 2017). Hence, this paper aims to detect the faults or abnormality of the robot arm based on historical robot arm movement data by using unsupervised learning with K-means clustering to label the normal or abnormal movement of the robot arm and then using MLP to predict the testing dataset. Kmeans is used due to its simple principle, convenience, and high efficiency (Hu et al., 2023). Although k-means could converge prematurely in a large scale dataset, this drawback can be prevented by integrating metaheuristics, such as PSO (Bouyer and Hatamlou, 2018) and Cuckoo algorithm (Isazadeh et al., 2018). Since the dataset volume is still considered as medium-to-low dataset, the convergence issue would be assumed negligible. the outline of this paper is as follows: section 2 specifies the method used in the analysis, whereas section 3 explains the result of the analysis. In the latter part, section 4 ends this paper with a conclusion.

Robot Anomalies Detection
The performance requirements of robot manipulators are defined by the international standard ISO 9283, which sets two key parameters to assess the precise performance of the manipulator. The two key parameters area pose repeatability and pose accuracy. The ability of the robot to return to the same orientation and position is measured by pose repeatability. On the other hand, Pose accuracy refers to moving to the desired location in three dimensions (Kuric et al., 2021) accurately. Moreover, other factors aside from mechanical problems also included such as geometric and non-geometric characteristics induced by kinematic model imperfections. The robot calibration procedure aims to determine the parameters that impact accuracy and enhance it by altering the software position (Kuric et al., 2021). This procedure comprises modeling, measurement, parameter identification, and, eventually, compensation implementation. Calibration includes measuring the end-effector Cartesian posture of each set of the target value, for example, using a laser tracker device (Kleinkes and Loser, 2011).
Some previous studies dealing with detecting robot anomalies problem in highdimensional data are available. There are six requirements for novelty detection (Markou and Singh, 2003;Miljkovic, 2010): 1) robust trade-off: exclude novel models, yet include known, 2) generalization: avoid false positives and negatives, 3) adaptability: capable of incorporating new information, 4) minimized complexity: applicable for online evaluation, 5) independence: handle varying dimensions and features, 6) parameter minimization: little input from the user.

K-means Clustering
Recently, K-means is found to be the most common method used to create data cluster (Sinaga and Yang, 2020). The classic k-means clustering method divides a dataset into k numbers of distinct groups, using k as the algorithm's input. The algorithm is split into two parts. K centroids are chosen at random in the first phase. In the second step, each data object is assigned to the nearest centroid. The Euclidean distance is used to compute the distance between data items and centroids. The first iteration is complete when all data items are allocated to any of the k clusters, and an early grouping is performed. After the first iteration, the centroids are recalculated by taking the mean of each cluster's data items. A new assignment is created each time K-new centroids are computed. As k new centroids are generated, a new assignment between the same data items and the new centroids must be made, resulting in loops and iterations. As a result, the position of this loop's k centroids and data items may alter in a step-by-step way. It will eventually come to a point where the D centroids will stop updating. It indicates that the clustering convergence condition has been met. The Euclidean distance is utilized to find the distance between data items and centroids in this technique (Shi et al., 2010). Between one data object X = (x1 ,x2 , …xn) and another data object Y = (y1 , y2 , …yn) the Euclidean distance d(X , Y) be calculated based on Equation (1).

Multilayer Perceptron
The Multilayer Perceptron (MLP) is a traditional neuron network with input, hidden, and output layers based on the error backpropagation algorithm (Aizenberg and Moraga, 2007), primarily based on the gradient descent method. The backpropagation method calculates the difference between the desired output d and the network's output. Furthermore, the information is propagated from the output to the input by adjusting the weights to minimize the error. Adjusting the weights is done in order to reduce the mistake propagates the information from the output to the input (Benkachcha et al., 2015).
The MLP application has been used from previous study to predict an uncertain outcome, such as wind speed forecasting (Amellas et al., 2019). There are two neuron model, the first is a multilayer perceptron (MLP) that is handled using a backpropagation method. In contrast, the second model is a form of recurrent neural network treated with the NARX model. The two models have the same network topology, with four input layers (Wind Speed, Pressure Temperature, and Humidity), an intermediate layer defined by 20 neurons and an activation function, and a single output layer described by wind speed linear function. This study will use MLP based on trial and experiment to determine which parameter gives the best outcome. MLP is used compared to the other artificial neural network (ANN) calculation in order to anticipate traffic arrival delays, due to its superior performance and reliability (Nanda et al., 2023).

Research Flow
This paper proposes a movement pattern identification of Arm Robot (SCARA) that combines an unsupervised learning technique using K-Means clustering and a multilayer perception, a supervised learning technique, using the KERAS model. The contributions in this research can be explained and summarized as follows: 1) Using time-region statistical parameter is proposed for extracting the most characteristic of the signal from the accelerometers SCARA robot. The parameters of time-region statistical, such as mean, max, root-mean-square, standard deviation, skewness, kurtosis, variance, and entropy, are used in this study. All parameters will be through the feature selection using a heatmap to find whether the features are related to each other through the correlation matrix of each feature 2) Combining two techniques between Kmeans clustering, one of the unsupervised learning techniques, and using one of the supervised learning techniques, a multilayer perception using the KERAS model builds a model to predict the other signal of the SCARA robot.
The flowchart shown in Figure 1 and Figure  2 shows the proposed methodology used in this paper. The flowchart is divided into two main parts-first, the proposed methodology using unsupervised learning for labeling train datasets using K-Means Clustering. Furthermore, the proposed methodology supervised learning is used (based on train dataset that labeling using the first method previously) in order to predict the other signal generated by the accelerometers of SCARA robot. The procedure for the proposed methodology discussed in this paper is shown as follows:

1) Unknown SCARA Signal
In this study, SCARA movement data is used as an input in the form of the signal generated from the accelerometers consisting of three axis (X, Y, Z) and inserted into CSV files. The CSV files will be considered as the input in this research.

2) Preprocessing I
In the first preprocessing, the data cleaning is carried out from the CSV files generated by the accelerometers, such as deleting the duplicate data and missing values using the pandas library.

3) Feature Extraction
After the data is cleaned, to extract the characteristic of the SCARA signal, the time-region statistical parameters have been chosen. There are parameters from timeregion used, such as mean, max, root-meansquare, standard deviation, skewness, kurtosis, variance, and entropy, that shown in Table 1.

4) Feature Selection
This paper proposes a feature analysis method based on the correlation matrix with a heat map to find whether the features are related to each other or the target variable. In this case, the correlation can be positive or negative depends on the increase in one value of features, whether it increases or decreases the value of the target variable. This process resulted in the feature selected in this paper, such as mean, max, root-meansquare, standard deviation, and skewness. In contrast, kurtosis, variance, and entropy cannot be used because they correlate with the other features.

5) Movement Pattern Classification
In this study, K-Means Clustering is used to classify various signal that generated by the accelerometers SCARA. The first step in this clustering is to decide the K-value through elbow curve and reinforced by silhouette score, which shows dissimilarity between clusters. This technique, either the elbow curve or the silhouette score, shows that this study will be divided into two groups between 0 and 1. Also, based from the clustering process, it is assumes that 0 is abnormal and 1 is normal. 6) Classified SCARA Signal After the clustering with K-Means has been conducted; hence, the new dataset is labelled so it can be used as a train data to predict the test dataset using one of the supervised learning which is the multilayer perceptron. 7) Preprocessing II Before building the model using the supervised learning, further preprocessing is needed in order to convert the dataframe to NumPy array and conduct dataset splitting. The process is conducted in jupyter notebook using python language. In data splitting, the data is divided into input and output. The output values will be encoded to categorical to shorten the time to process while creating a multilayer perceptron model.

8) Model Building
This part will build a model that can predict the input categories, whether normal or abnormal, using supervised learning. The multilayer perceptron is used to create the model, and the next part will discuss the layer's details. The output of this section would model the SCARA Signal.
Parameter Definition Figure 2. Flowchart of the Proposed Methodology using Supervised Learning in Python.

RESULT AND DISCUSSION
This study will discuss three main parts: preprocessing, unsupervised learning, and supervised learning. The details of the parts will be described as follow.

Preprocessing Result
The data analysis involves 1180 CSV files, with a predetermined amount of 700 training sets and 480 test sets. These data will mainly focus on non-linear robot movements, whereas linear movements also treat the same method in this paper. Each CSV contains a 5-second movement of the robot arm. Those datasets are aggregated to obtain the time-region statistical parameter. Therefore, every data record is considered as one CSV aggregation. These extracted datasets would be used in further analysis. The dataset reported no missing values due to its nature of continuous sampling rate.
In feature extraction, specific statistical parameters may be excluded due to their redundancy towards another attribute. Those attributes are kurtosis, variance, and entropy. Others are considered not strongly correlated,  Figure 3.

Unsupervised Learning
Cluster analysis commenced from standardizing the data and determine the number of clusters. The Clusters are determined based on the inertia elbow inertia method, describing the sum of samples' squared distances to their closest cluster center. It is shown from Figure 4, inertia starts decreasing in a linear movement at k=2. Therefore, the optimal number of clusters is 2.
Based on the number of clusters, all of the records are plotted in a pair plot for a better visualization shown in Figure 5. The train set has established two unbalanced observations, consecutively 514 records for cluster 1 and 186 records for cluster 0. Figure 5 indicates that the clusters are distinguishable based on their timeregion statistical parameter. Cluster 1 tends to have a higher attribute value, as shown in the distribution line mainly the orange-colored are dominant with higher values. Based on this pair plot, one may deduct that a particular cluster could signal an abnormality due to its unbalanced records and dominant value. However, this result would not be sufficient to classify without further judgment.

Supervised Learning
After obtaining the normal and abnormal labels in the dataset using the unsupervised learning technique, supervised learning techniques is used, namely Multilayer Perceptron method to predict the testing dataset. As can be seen in figure 6, there is a perceptron architecture, which contains one input layer with 14 dimensions, five hidden layers, and one output layer. , there is a model summary generated when the model is created. The total parameters used in this study are 258 parameters divided into four hidden layers. The first hidden layer is 120 parameters; the second layer is 72; the third layer is 36; the fourth layer is 20, and 10 are the last layer. The non-linear dataset's accuracy is obtained to be 94.14%, which is relatively high. This is done by comparing the model output with the ground truth that have been given in the test set. Furthermore, the validation approach was conducted using 67:33 splitting in KERAS, which yields 96.12% validation accuracy on 50 epochs and a batch size of 2. This process is conducted by randomly dividing the entire dataset into a 67:33 proportion of the training set and the test set. The data separation procedure is conducted based on 10-fold-cross-validation (Malakouti, 2023). The procedure stands as a method of resampling and divided based on predetermined proportion and the accuracy is evaluated 10 times. Therefore, there would be 10 different (randomized slicing) data composition of 67:33 train and test to be calculated. The model's result is repeatedly evaluated, and its accuracy is averaged. This repeated calculation is done to maintain model consistency and to prevent overfitting. The predicted label result for the test dataset is shown in Table 2, in which total categories 0 and 1 are 108 and 372. Therefore, it can be concluded that the normal movement of the robot has higher counts than the abnormal movement of the robot arm.

CONCLUSION
In this study, a methodology to identify the robot arm (SCARA) movement pattern to detect the mechanical aging of the robot was proposed. Determining the robot arm's movement pattern is done by combining unsupervised and supervised learning (k-means and multilayer perceptron). The k-means clustering yields two distinguishable identified movement behavior. These behaviors are labeled to train a supervised learning model to predict a new input with an unknown label. The obtained predictive model has shown sufficient accuracy in model fitting and data split for validation. The specified features used in this paper can be explored for future enhanced predictive modeling based on the massive dataset of acceleration time-series to allow efficient predictive maintenance of industrial robots. The interaction effect between separate axes could also be considered in the following study to improve the model's usefulness.