## 3 Data Source and Analysis
### Using a Neural Network to Build an Early Warning Model
#### 3.2.4 Training of Early Warning Model  
1. Determining the number of input neurons and the input matrix  
Given that 22 influencing factors and 500 questionnaires exist for workers, the number of input neurons is 22, and the size of the input matrix is 500 \(\times\) 22. The input matrix must be transposed because of the particular requirements of Matlab. The final input matrix size is 22 \(\times\) 500.
2. Determining the number of output neurons and the output matrix  
The safety states of workers are reflected by a score, and the number of worker questionnaires is 500. Thus, the number of output neurons is 1, and the size of the output matrix is 500 \(\times\) 1. The output matrix must be transposed because of the particular requirements of Matlab. The final output matrix size is 1 \(\times\) 500.
3. Determining the number of hidden neurons  
According to the Kolmogorov theorem, the number of hidden layer nodes is chosen to be eight. The final neural network model is shown in Figure 3. (\(W\) is the weight of the input to the neuron, and \(b\) is the bias of the neuron.)  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Grade** & **State** & **Fractional Interval** \\ \hline
1 & Security & (0, 0.25) \\
2 & Mild risk & (0.25, 0.5) \\
3 & Moderate risk & (0.5, 0.75) \\
4 & Severe risk & (0.75, 1) \\ \hline \hline \end{tabular}
\end{table}
Table 10: Division of security states.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Worker Information** & **Attributes** & **Proportion** \\ \hline  & 18–26 & 8\% \\  & 27–35 & 22\% \\ Age & 36–44 & 24\% \\  & 45–53 & 40\% \\  & 53 and above & 6\% \\ \hline Has the worker experienced & Experienced an accident & 24\% \\ an accident & No accident & 76\% \\ \hline  & Sichuan & 17\% \\  & Shandong & 19\% \\ Area & Jiangsu & 20\% \\  & Jilin & 13\% \\  & Others & 31\% \\ \hline  & Bachelor’s degree and above & 1\% \\ Education level & Specialist & 15\% \\  & High school & 31\% \\  & Junior high school and below & 53\% \\ \hline  & Skilled worker & 27\% \\ Type of work & Ordinary worker & 52\% \\  & Manager & 14\% \\  & Others & 7\% \\ \hline Gender & Female & 22\% \\  & Male & 78\% \\ \hline \hline \end{tabular}
\end{table}
Table 9: Statistics of survey objects’ information.  
(4)  
Leverberg-Marquardt algorithm  
The BP algorithm has some shortcomings, such as slow convergence, low training efficiency and poor numerical stability. The non-linear neural network learning algorithm named the Levenberg-Marquardt (LM) algorithm can greatly improve the above defects [50]. The LM algorithm is a combination of the gradient descent method and quasi-Newton method. The algorithm expects to achieve a high-order training speed without calculating the Hessian matrix and the formula is shown in Equation (11).  
\[x_{k+1}=x_{k}-[J^{T}J+\lambda I]^{-1}J^{T} \tag{11}\]  
In the formula, J is the Jacobian matrix. When using the Levenberg-Marquardt algorithm, if the decline is too fast, one can use a smaller \(\lambda\) to increase its similarity to the Gaussian Newton method. Alternatively, one can use a larger \(\lambda\) to increase its similarity to the gradient descent method. The Matlab toolbox provides the TRAINLM function for the calculation of the Levenberg-Marquardt algorithm.  
(5)  
Importing data and determining parameters  
In this study, the neural network toolbox in Matlab was utilized to train the neural network model. The input and output matrices were imported into Matlab separately. During the model training process, the training function was TRAINLM, the adaptive adjustment learning function was LEARNGDM, the performance function was the mean square error, the number of network layers was 2, the number of training times was 1000, the target error was 0, and the other parameters were set to the default values of the toolbox.