# Prediction of Horizontal in Situ Stress in Shale Reservoirs Based on Machine Learning Models
## 4 Results and Discussion
### Field Application  
In this study, across the entire test set, the XGBoost model predicted a maximum horizontal principal stress of 110.89-122.78 MPa and a minimum horizontal principal stress of 95.21-105.05 MPa, with a horizontal stress difference of 12.11-20.53 MPa. The actual stress log of a well on site shows that in the 4230.0-5907.5 m section, the maximum horizontal principal stress ranges from 112.3 to 126.5 MPa, the minimum horizontal principal stress ranges from 96.6 to 106.9 MPa, and the differential stress between the maximum and minimum horizontal principal stresses is 16.3 MPa. The predicted ranges of maximum and minimum horizontal principal stresses exhibit errors within 5%, aligning with engineering tolerance standards. These data not only quantify the stress distribution in the target area but also offer key references for on-site operations. They help optimize hydraulic fracturing designs, predict fracture propagation, and assist in geological modeling, thereby enhancing shale gas development efficiency. Hydraulic fracturing, which depends heavily on stress distribution, focuses on fracture shape, size, and network uniformity in its design. The predicted results indicate that the horizontal stress difference in the Luzhou area is moderate, and fracture propagation is mainly controlled by the maximum horizontal principal stress direction. A lower stress difference (12.11 MPa) may lead to a complex fracture network, forming multi-branch fractures and helping to expand the reservoir modification range. In contrast, a higher stress difference (20.53 MPa) makes fractures tend toward a single main-fracture pattern, with longer fracture lengths but lower fracture complexity. Therefore, in areas with low stress differences, high-viscosity cross-linked fracturing fluids should be used to enhance fracture network complexity and improve reservoir sweep efficiency. In areas with high stress differences, slick water fracturing is more suitable to ensure effective fracture propagation along the maximum horizontal principal stress direction. Additionally, perforation cluster spacing should be optimized based on the stress field, with spacing reduced in areas of high stress gradients to improve fracture uniformity and prevent single fractures from dominating the entire fracturing stage. Fracture propagation is controlled by the stress difference. In areas with small horizontal stress differences, complex fracture networks are more likely to form, while large stress differences favor the generation of stable main fractures. Based on the predicted data, the fracture propagation pattern in the Luzhou area can be further optimized. In areas with low stress differences, the complex fracture network helps improve reservoir sweep efficiency, but fracture widths may be narrow, limiting proppant transportation. Thus, the fracturing fluid system needs to be optimized to enhance sand-carrying capacity. In areas with high stress differences, fractures tend to be single, requiring control of fracturing fluid viscosity to prevent excessive fracture width and insufficient proppant filling. The stress field distribution also determines fracture height: in areas with large horizontal \begin{table}
\begin{tabular}{c c c c c} \hline
**Target Variables** & **Parameters** & **XGBoost** & **SVM** & **RF** \\ \hline \multirow{4}{*}{SHmax} & MAE & 0.250 & 0.345 & 0.621 \\  & MSE & 0.125 & 0.242 & 0.763 \\  & RMSE & 0.353 & 0.492 & 0.874 \\  & R\({}^{2}\) & 0.978 & 0.958 & 0.866 \\ \hline \multirow{4}{*}{SHmin} & MAE & 0.304 & 0.437 & 0.509 \\  & MSE & 0.181 & 0.370 & 0.511 \\ \cline{1-1}  & RMSE & 0.426 & 0.608 & 0.715 \\ \cline{1-1}  & R\({}^{2}\) & 0.959 & 0.917 & 0.885 \\ \hline \end{tabular}
\end{table} 
Table 2: Evaluation Metrics (R\({}^{2}\), MAE, MSE, RMSE) of XGBoost, SVM, and RF Models for SHmax and SHmin Prediction on 20% Unseen Test Set. stress differences, fractures tend to propagate horizontally, while in areas with small stress differences, fractures may exhibit some vertical propagation.