# Time-Series Prediction of Failures in an Industrial Assembly Line Using Artificial Learning
## 3 Materials and Methods
### Modelling Using the NAR Network  
NAR is a nonlinear model. It is good at predicting the future of any time-series data. Its input layer consists of past values (lags, \(d\)). Its hidden layers learn nonlinear relationships and produce outputs through activation functions. The neurons in each layer are connected to those in the subsequent layer through weighted connections. The learning capability of such networks is provided by weights and biases. In the output layer, the predicted value is computed and, via feedback, used as input in the subsequent iteration. However, the behaviour and performance of the model are significantly influenced by its hyper-parameters, which must be carefully optimised. The hyper-parameters of NAR networks are dataset partition sizes for training, testing, and validation; activation functions in the layers; a training algorithm; training parameters such as counts of training iterations, momentum, learning rate, and learning threshold; the count of hidden layers in the network; the neuron counts in the hidden layers. The validation performance and generalisation capability of the model are assessed using metrics such as MSE, MAE, and \(R^{2}\) to determine the optimal values of these hyper-parameters. The success of NAR networks depends on their architecture and the careful selection of these hyper-parameters. Although specific methods exist for selecting certain hyper-parameters, for example, hidden layer count, neurons per layers, and iteration counts, many are still determined through trial and error. The number of hidden layers is typically determined based on problem complexity. The more hidden layers the network has, the more capability the network has to represent complex features, but the more risk of overfitting it has. A network with zero hidden layers performs well for linearly separable functions or decisions. The ability to approximate functions that map continuously from one finite space to another can be achieved with just one hidden layer. However, the use of two hidden layers allows for the unique representation of arbitrary decision boundaries. Networks with three or more hidden layers can approximate any smooth mapping to an arbitrary level of precision. From these explanations, it is evident that 0, 1, or 2 layers are generally sufficient. Having too few neurons per layer may lead to inadequate representation, while having too many may result in overfitting. Various formulas exist to determine the optimum neuron number in each layer. One such formula is \(N_{h}\ \leq\ \frac{N_{i}}{(\alpha\ *(N_{i}+N_{o}))}\) where \(N_{i}\) and \(N_{o}\) are the neuron numbers in the input and output layers, respectively; \(N_{s}\) is the data count in the training set; and \(\alpha\) is an arbitrary scaling factor, typically ranging from 2 to 10. \(N_{h}\) stands for the neuron number in the hidden layer. In this study, the total number of data points is 45,654, with 80% used for training, so, \(N_{s}=36,523\), \(N_{i}=1\), \(N_{o}=1\), and \(\alpha=10\). Therefore, the neuron number must satisfy \(N_{h}\ \leq\ 3044\). Nevertheless, a higher number of neurons can be used provided that overfitting is avoided. The term _Configuration(t)_ is the output, while (_Configuration\({}_{t-1}\)_, _Configuration\({}_{t-2}\)_, _Configuration\({}_{t-3}\)_) are inputs, indicating that the output feeds back into the input. In the form of a function, it can be expressed as _Configuration\({}_{t}=f(Configuration_{t-1}\)_, _Configuration\({}_{t-2}\)_, _Configuration\({}_{t-3}\)_, \(w\), \(b)\)_ where \(w_{ij}\) represents the weights of each connection. \(b\) means bias. It can improve a model's prediction efficiency. It adds a constant value leading to systematic behaviour [27]. \(j^{th}\) neuron in any layer consists of all weighted values coming from previous layer. Equation (5) governs these calculations. \[net_{j}=b+\sum_{i}^{NN}y_{i}w_{ij} \tag{5}\]  
where \(NN\) is the total number of neurons in the previous layer. \(net_{j}\) is the value of \(j^{th}\) neuron.