## 3 Model Building and Algorithm Design
### Model Solution  
In logistic regression, the sample set of the training model consists of \(m\) groups of labeled data:  
\[\Big{\{}\left(X^{(1)},Y^{(1)}\right),\Big{(}X^{(2)},Y^{(2)}\Big{)},\ldots, \left(X^{(m)},Y^{(m)}\right)\Big{\}} \tag{7}\]  
\(X^{(j)}\) represents the evaluation indicator system, its dimension is \(n\), and the value of \(n\) is the number of selected evaluation indicators. \(Y^{(j)}\) represents the output results of whether the mine pressure is dangerous. Bringing each group of sample data into Formula (6), the probability of occurrence of mine pressure hazard predicted by this group of data can be obtained, as shown in Formula (8). \[h_{\omega}\Big{(}x^{(j)}\Big{)}=\frac{1}{1+\exp[-(\omega_{1}x_{1}^{(j)}+\omega _{2}x_{2}^{(j)}+\ldots+\omega_{n}x_{n}^{(j)}+b)]} \tag{8}\]In the formula, \(i=1,2,\ldots,n\), and \(n\) represents the number of selected evaluation indicators; \(j=1,2,\ldots,m\), and \(m\) represents the number of samples, that is, the amount of obtained mine pressure sample data. Suppose that the probability that the mine pressure is dangerous is \(h_{\omega}(x)\), that is, the probability that \(y=1\). This is shown in Formula (9). \[p(y=1|x;\omega)=h_{\omega}(x) \tag{9}\]  
The probability that the mine pressure is not dangerous, that is, the probability of \(y=0\), is shown in Formula (10). \[p(y=0|x;\omega)=1-h_{\omega}(x) \tag{10}\]  
For the convenience of calculation, the above assumption functions are integrated to obtain Formula (11). \[p(y|x;\omega)=[h_{\omega}(x)]^{y}.[1-h_{\omega}(x)]^{1-y} \tag{11}\]  
Since the probabilities derived from each group of samples are independent, for all samples, the maximum likelihood function is shown in Formula (12). \[L(\omega)=\prod_{j=1}^{m}p(y|x_{i};\omega)=\prod_{j=1}^{m}\left[h_{\omega} \left(x_{i}^{(j)}\right)\right]^{y^{(j)}}.\left[1\ -\ h_{\omega}\left(x_{i}^{(j)}\right)\right]^{1-y^{(j)}} \tag{12}\]  
Finally, the maximum likelihood function is solved; that is, the greater the probability of all sample data finally being obtained, the better. For the convenience of calculation, the logarithm of the above likelihood function is taken. Taking the logarithm does not affect the monotonicity of the original function; rather, it enlarges the difference between the function values, so that the categories of each sample can be better distinguished. The result of taking the logarithm is shown in Formula (13). \[l(\omega)=\log L(\omega)=\sum_{j=1}^{m}\left[y^{(j)}.\log h_{\omega}x_{i}^{j}+ \left(1-y^{(j)}\right).\log\left(1-h_{\omega}x_{i}^{j}\right)\right] \tag{13}\]  
After taking the logarithm, the new function obtained is an upward convex function, which can be solved with a gradient boosting algorithm to obtain the maximum likelihood function value. Alternatively, we can multiply the above function by \(-1\) to make it a minimum negative log-likelihood function, which is a downward convex function, for which the new function can be solved with a gradient descent algorithm. The loss function is obtained by taking the average of m samples and the minimum negative log-likelihood function. The loss function is shown in Formula (14). \[J(\omega)=-\frac{1}{m}l(\omega)=-\frac{1}{m}\sum_{j=1}^{m}\left[y^{(j)}.\log h _{\omega}x_{i}^{j}+(1\ -y^{(j)}).\log\left(1\ -h_{\omega}x_{i}^{j}\right)\right] \tag{14}\]  
The traditional solution method uses the batch gradient descent algorithm to solve the parameter values of the equations. The update formula of \(\omega\) in the batch gradient descent algorithm is shown in Formula (15). \[\omega_{i}:=\omega_{i}-\alpha\frac{\partial}{\partial\omega_{i}}J(\omega_{i}) \tag{15}\]  
In the formula, \(:=\) represents the variable value update symbol, and the purpose is to continuously change the influence weight of the corresponding indicator on the mine pressure hazard according to the gradient of the mine pressure hazard evaluation indicator in each iteration and finally find the optimal weight \(\omega\) of each evaluation indicator.