## 5 Construction of a Predictive Model for Accident Losses in Coal Mining Equipment Safety Investment
### Accident Loss Prediction Model Based on IPSO-BP  
The improved particle swarm optimization (IPSO) algorithm was combined with a BP neural network model to construct a joint prediction model for predicting accident losses in coal mine equipment safety investment programs. The implementation process of the IPSO-BP model includes the following key steps:  
(1) Model construction stage  
The input layer of the model receives coal mine equipment safety investment as input features \((X_{1},X_{2},\cdots,X_{5})\) and accident loss as output (\(Y\)). Initialization of particles and population sets the velocity and position of particles, initializes the weights and thresholds of the BP neural network, specifies important parameters such as population size, iteration number and learning rate, and seeks the optimal parameters of the BP network through the improved particle swarm optimization (IPSO) algorithm. (2) Model training phase  
A fitness function is defined to evaluate the effectiveness of model fitting, for example, using the mean square error (MSE) as an evaluation criterion to ensure that the difference between the model predictions and the true values is as small as possible. The optimization process optimizes the weights and thresholds of the BP neural network by constantly updating the position and velocity of the particles through the IPSO algorithm. In each iteration, the performance of the particles is evaluated based on the fitness function, and the optimal position and its corresponding optimal solution are updated to gradually approximate the global optimal solution. (3) Model evaluation stage  
Using relevant error metrics such as root mean square error (RMSE) and Coefficient of Determination (R\({}^{2}\)), the prediction ability of the IPSO-BP model is comprehensively evaluated to verify its accuracy and generalization ability. The structure of the model and the pseudo-code steps are shown in Figures 4 and 5. Figure 4: IPSO-BP accident loss prediction model architecture. 1. Data collection: Collect the raw data needed for the prediction model and preprocess them. a. Data collection: collect raw data needed for the prediction model, including coal mine equipment safety investment(\(X_{1},X_{2},X_{3},X_{4},X_{5}\))and the corresponding accident loss (\(Y\)). b. Pre-processing: Clean, normalize and standardize the data to ensure the quality and consistency of the data. 2. Data set division: The data set was divided using the \"bootstrapping\" method. 3. build the BP neural network architecture: a. Design the input layer, hidden layer and output layer of BP neural network: Input layer: the data of 5 indexes of coal mine equipment safety investment(\(X_{1},X_{2},X_{3},X_{4},X_{5}\))are taken as the input layer of the prediction model. Hidden layer: the number of hidden layer nodes (\(L\)) can be calculated by the formula: \(L=\sqrt{m+n}\ +\epsilon\), in this paper, \(L\) is set as 5. Output layer: accident loss \(Y\)as the output layer. b. Determine the number of neurons and activation function of the hidden layer: The number of neurons in the hidden layer is set to 5. The activation function selects Sigmoid function. c. Train and adjust the network structure: Using the training set data, the BP neural network prediction model is constructed and adjusted experimentally to determine the best network structure. 4.Parameter setting: Setting inertia factor (\(Wmin=0.4,Wmax=0.9\)), acceleration constant(\(c1=2,c2=2\)), dimension(\(Dim=10\)) Sum of nodes in input and hidden layers, particle swarm size(\(sizeof=20\)), maximum number of iterations(\(maxiter=100\)), boundaries(\(lb,ub\)) Setting according to the range of input data, fitness function Root Mean Square Error (RMSE) is used as the fitness function to evaluate the performance of each particle. 5. Optimizing neural networks using IPSO a. Initialize particle swarm positions and velocities: Randomly initialize particle positions and velocities.