Open-access Predicting sonic log from well log in the Sergipe-Alagoas Basin using XGBoost Regressor algorithm

Abstract

The XGBoost Regressor algorithm has been extensively applied in the petroleum industry for predictions from petrophysical data. The objective of this study was to predict the compressional sonic log (DT) of offshore wells in the Sergipe-Alagoas Basin (Brazil) from conventional geophysical logs — gamma ray (GR), deep resistivity (RT90), bulk density (RHOB), and neutron porosity (NPHI) — using a dataset of 28 wells. Following exploratory data analysis and a caliper-based quality control procedure, hyperparameters were optimised using RandomisedSearchCV with GroupKFold cross-validation (cv=10), grouping by well identity to prevent depth-point leakage between wells during tuning. The assessment of model generalisation was conducted through the implementation of a Leave-One-Well-Out (LOWO) protocol, wherein each of the 28 wells was designated as a blind test set once, with the remaining 27 wells being utilised for training purposes. The XGBoost Regressor was benchmarked against Ridge Regression and Random Forest (RF) under the same LOWO protocol. The employment of ensemble methods (RF and XGBoost) resulted in a substantial enhancement in performance when compared with the linear baseline, thereby confirming the non-linear nature of the relationship between the input logs and DT in the Sergipe-Alagoas Basin. The predictive performance of XGBoost and RF was found to be equivalent (median R2 = 0.82, median RMSE = 4.36 µs/ft, median MAE = 3.14 µs/ft across 28 wells), while Ridge Regression yielded a median R2 of 0.62, thus demonstrating the inadequacy of linear approaches. Feature importance analysis identified neutron porosity (NPHI) as the dominant predictor (63.6%), consistent with the physical relationship between porosity and compressional velocity. Four wells (14.3%) presented R2 below 0.70, a phenomenon attributable to geological and petrophysical factors, including compaction anomalies, fluid saturation effects on sandstone intervals, and the underrepresentation of shallow depth ranges in the training distribution. This pattern was confirmed by the consistent underperformance of both RF and XGBoost for these wells, rather than algorithmic limitations. This study demonstrates the reliability of XGBoost in predicting sonic logs across a range of geological contexts within the Sergipe-Alagoas Basin. Furthermore, it establishes a reproducible LOWO-based evaluation framework that has the potential to be applicable to other sedimentary basins.

KEYWORDS:
machine learning; XGBoost Regressor; sonic log prediction; leave-one-well-out; petrophysics; well log

1. INTRODUCTION

In recent years, technological advances have resulted in the widespread adoption of machine learning (ML) algorithms across various sectors, including business, industry, medicine and geosciences. In this context, geology and geophysics have proactively investigated the potential of these tools to enhance existing models and develop process prediction and automation techniques (Ali et al., 2021; Mello e Silva et al., 2019; Wu et al., 2024). One of the most pertinent applications is the prediction of geophysical well log curves (Feng et al., 2021; Chagas et al., 2010; Rahmati et al., 2024). In the realm of geophysical profiling, the compressional wave sonic log (DT) has emerged as a prominent tool, distinguished by its unique capacity to provide detailed insights into the subsurface characteristics of oil wells. Its significance is twofold: firstly, its capacity to be integrated with seismic data for synthetic seismogram generation and seismic horizon calibration; and secondly, its role in porosity estimation, rock mechanical property assessment, and wellbore stability analysis (Chagas et al., 2010). However, obtaining this profile is not always possible due to cost or operational constraints, which can hinder interpretation and integration with other data, especially in poorly explored basins where the density of information is very low.

It has been demonstrated by numerous studies that machine learning (ML) algorithms have the capacity to effectively predict the compressional sonic log from well logs that have been routinely acquired. Feng et al. (2021) employed Random Forest with grid search optimization and feature importance analysis to impute missing well logs in the Volve Field, North Sea, establishing a widely referenced methodological framework for data-driven log reconstruction. Tahiru et al. (2022) applied Gradient Boosting to predict compressional and shear sonic logs in the deep offshore Niger Delta Basin using gamma ray, resistivity, density, and neutron porosity as input features, achieving R2 values of 0.88 to 0.99 at blind wells in a geological setting comparable to other passive margin basins. Saleh et al. (2025) compared Random Forest, CatBoost, XGBoost, and deep learning approaches for sonic log prediction in the Shahd SE field, Western Desert of Egypt, reporting that ensemble methods outperformed the remaining algorithms with correlation coefficients of 89-89.6% and RMSE of 5.85-6.03 µs/ft at blind wells. Vázquez-Ayala et al. (2025) demonstrated the applicability of a hybrid CNN-GRU deep learning architecture for sonic log prediction in the Tabasco Basin, Mexico, achieving RMSE values of 1.4-1.7 µs/ft under well-level holdout validation. At a broader scale, Kim et al. (2023) applied Gradient Boosting, Random Forest, and Artificial Neural Networks to predict compressional and shear wave velocities across Japan using borehole databases, confirming the generalization capacity of tree-based ensemble methods in diverse geological contexts.

Despite these advances, most published studies evaluate model performance on a single blind well, which limits the assessment of generalization across different geological conditions within the same basin. Furthermore, cross-validation schemes based on random depth-point splitting overestimate performance because adjacent depth samples are highly correlated, a well-documented source of data leakage in well log prediction tasks. In order to address these limitations, the present study adopts a Leave-One-Well-Out (LOWO) protocol, in which each of the 28 wells in the dataset is held out once as a blind test set while the remaining 27 wells are used for training. Hyperparameter optimization is performed using RandomizedSearchCV with GroupKFold cross-validation (cv=10), grouping by well identity to prevent depth-point leakage during tuning. The XGBoost Regressor is benchmarked against Ridge Regression and Random Forest under the same LOWO protocol to contextualize its performance relative to a linear baseline and a competing ensemble method.

The objective of this study is to predict the compressional sonic log of offshore wells in the Sergipe-Alagoas Basin (Brazil) using the XGBoost Regressor algorithm trained on gamma ray (GR), deep resistivity (RT90), bulk density (RHOB), and neutron porosity (NPHI) logs, and to evaluate the model's generalization capacity across the full well inventory of the basin. This work also aims to establish a reproducible LOWO-based evaluation framework that can be extended to other geophysical log types and applied to other sedimentary basins.

2. MATERIAL AND METHODS

2.1 Geological context

The Sergipe-Alagoas Basin (Figure 1) is a rift-symmetric, NNE/SSW elongated basin. It is bounded to the north by the Pernambuco-Paraíba Basin, through the Maragogi Highlands, and to the south by the Jacuípe Basin. The name Sergipe-Alagoas is due to the fact that the basin is divided into two sub-basins, Sergipe and Alagoas, separated by the Jaboatã-Penedo highland (Lana, 1990).

Figure 1
Location of the Sergipe-Alagoas Basin and the wells (ANP).

The onshore and offshore sedimentary sequences of the Sergipe-Alagoas Basin reflect distinct tectono-sedimentary phases of the Brazilian Equatorial Continental Margin (BECM): pre-rift, rift, post-rift and drift. The onshore portion covers an area of approximately 13,000 km2, while its offshore portion is around 40,000 km2 (Feijó, 1994; Campos Neto et al., 2007; Antonietto et al., 2015). The stratigraphic evolution of the Sergipe-Alagoas Basin is similar to that of other marginal sedimentary basins in the South Atlantic, beginning with continental sequences that gradually transition to marine (Asmus & Porto, 1972; Berggren & Hollister, 1974; Asmus, 1984; Kellogg & Mohriak, 2001; Milani et al., 2007; Mohriak et al., 2008; Mohriak & Fainstein, 2012). The formations observed belong to the interval of wells containing the five profiles required for the study. These formations are present in the Transgressive Drifter and Regressive Drifter phases. In chronostratigraphic order of time (older to newer):

Muribeca Formation: marine depositional sequence composed of thick siliciclastics, evaporites, microbial carbonates and shales, and intercalated shales and calcilutites (Campos Neto et al., 2007).

Riachuelo Formation: marine sedimentation where thick siliciclastics were deposited at the basin margin and in low blocks. In areas of low sedimentary input, banks of oolites and oncolites were deposited in a carbonate ramp. In the lagoon and slope areas, calcilutites and shales were deposited (Campos Neto et al., 2007).

Cotinguiba Formation: carbonate ramp sedimentation, with massive calcilutites and breccoids in the proximal part, and shales, marls and calcilutites on the slope and in the rest of the basin (Campos Neto et al., 2007).

Calumbi Formation: successive deposition of shales after the sedimentation pattern changed from carbonate to siliciclastic, due to a major transgressive event at the end of the Coniacian (Campos Neto et al., 2007).

2.2 Data

Well log data from 28 offshore wells in the Sergipe-Alagoas Basin were provided by ANP (Brazilian National Agency of Petroleum, Natural Gas and Biofuels) in LAS format. Each well contains Gamma Ray (GR), Deep Resistivity (RT90), Bulk Density (RHOB), Neutron Porosity (NPHI), Compressional Sonic (DT), and Caliper (CALI) logs. All data processing and model training were performed in Python, using the LasIO library for LAS file reading, Pandas and NumPy for data manipulation, and Plotly and Matplotlib for visualization. The complete preprocessing workflow, including exploratory data analysis, mnemonic standardization, and quality control scripts, is documented in the public repository associated with this study.

2.2.1 Quality control

The preprocessing pipeline comprised four main steps: (i) standardization of curve mnemonics across acquisition vendors; (ii) removal of values outside physically plausible limits (Table 1); (iii) linear interpolation of isolated DT gaps (limited to 10 consecutive samples); and (iv) a caliper-based IQR filter to remove intervals affected by borehole washout. The IQR filter was applied to the CALI curve of each well independently, removing depth samples where CALI fell outside [Q1 − 1.5 × IQR, Q3 + 1.5 × IQR]. The DT curve was not used as a removal criterion at any stage of the quality control procedure. After all preprocessing steps, the final dataset contains 231,816 depth samples across the 28 wells. Descriptive statistics before and after quality control are presented in Table 2, and the corresponding distributions are illustrated in (Figure 2).

Table 1
Physical plausibility limits applied to each curve prior to quality control.
Table 2
Descriptive statistics of input features and target variable before and after caliper-based quality control.
Figure 2
Distributions of input features and target variable before (blue) and after (green) caliper-based quality control for the 28 wells of the Sergipe-Alagoas Basin dataset. The resistivity log (RT90) is displayed on a logarithmic scale owing to its multi-order-of-magnitude dynamic range. Quality control was based exclusively on the Caliper curve (CALI); the compressional sonic log (DT) was not used as a removal criterion.

Three observations from Table 2 are worth noting. First, the standard deviation of GR decreased from 32.63 to 24.73 gAPI after quality control — a reduction of approximately 24% — indicating that the removed intervals contained anomalous GR readings consistent with zones of borehole wall collapse. Second, the maximum CALI value decreased from 28.76 to 20.84 in, confirming that the IQR filter effectively removed intervals of severe washout while retaining all well-conditioned sections, as evidenced by the post-QC minimum of 8.245 in, which remains above the typical offshore bit diameter. Third, and most importantly, the mean and standard deviation of DT were practically unchanged (97.20 → 97.03 µs/ft; 15.56 → 15.36 µs/ft), confirming that the caliper-based quality control did not introduce any systematic bias into the distribution of the target variable.

2.2.2 Feature selection

Four logs were selected as input features: GR, RT90, RHOB, and NPHI. The caliper (CALI) was excluded from the predictive model because it reflects borehole geometry rather than formation properties, and its values are directly affected by the same washout conditions removed during quality control. The four selected features are physically related to compressional velocity through well-established petrophysical relationships: RHOB and NPHI are directly linked to porosity, which governs acoustic slowness; GR serves as a lithology indicator; and RT90 captures fluid content and clay volume variations (Wyllie et al., 1956). This feature set is consistent with comparable studies in the literature (Tahiru et al., 2022; Saleh et al., 2025).

2.2.3 Validation split

Model generalization was evaluated using a Leave-One-Well-Out (LOWO) protocol, in which each of the 28 wells was held out once as a blind test set while the remaining 27 wells were used for training. This approach ensures complete separation between training and test data at the well level, avoiding the inflated performance estimates that arise from random depth-point splitting of correlated adjacent samples. The number of depth samples per well after quality control is summarized in Table 3.

Table 3
Number of depth samples per well after quality control, used in the Leave-One-Well-Out (LOWO) validation protocol.

2.3 Methodology overview

The methodology adopted in this study follows a sequential workflow comprising four main stages: data preprocessing and quality control, hyperparameter optimization, Leave-One-Well-Out (LOWO) validation, and model comparison. Figure 3 provides a schematic overview of the complete pipeline.

Figure 3
Overview of the methodology workflow. Stage 1: data preprocessing and quality control, yielding a consolidated dataset of 231,816 depth samples. Stage 2: independent hyperparameter optimization of the three models using RandomizedSearchCV with GroupKFold cross-validation (cv = 10), grouped by well identity. Stage 3: Leave-One-Well-Out (LOWO) validation across all 28 wells, producing 28 independent evaluation scores per model. Stage 4: model comparison based on the median and interquartile range (IQR) of R2, RMSE, and MAE across all held-out wells.

In the first stage, raw LAS files from 28 wells were loaded and subjected to the preprocessing steps described in Section 2.2, yielding a quality-controlled dataset of 231,816 depth samples. The four input features — GR, RT90, RHOB, and NPHI — were extracted alongside the target variable DT.

In the second stage, hyperparameters for each of the three models — Ridge Regression (Hoerl & Kennard, 1970), Random Forest (Breiman, 2001), and XGBoost (Chen & Guestrin, 2016) — were optimized independently using RandomizedSearchCV with GroupKFold cross-validation (cv=10), with well identity as the grouping variable. This grouping strategy ensures that all depth points from a given well appear exclusively in either the training or the validation fold, preventing the inflated cross-validation scores that result from random depth-point splitting of serially correlated log data.

In the third stage, the optimized models were evaluated under a Leave-One-Well-Out (LOWO) protocol. In each of the 28 iterations, one well was held out as a blind test set and the model was retrained from scratch on the remaining 27 wells using the previously optimized hyperparameters. Performance was quantified using R2, RMSE, and MAE for each held-out well, yielding a distribution of 28 independent evaluation scores per model.

In the fourth stage, the three models were compared based on the median and interquartile range (IQR) of their LOWO metrics, providing a robust summary of predictive performance and variability across the full well inventory of the Sergipe-Alagoas Basin.

2.4 XGBoost Regressor

The gradient boosting decision tree algorithm was first proposed by Friedman (2001). Its principle is based on using the gradient descent method to generate new trees, such that the objective of the model is minimized with each iteration. Based on this concept, Chen & Guestrin (2016) developed XGBoost, an improved version of the gradient boosting algorithm that can be applied to classification and regression models.

XGBoost is a tree-based ensemble model that uses the combination of multiple decision trees to form a robust predictor. In regression models, the algorithm continuously adds new regression trees, adjusting the residuals of previous models using the trees generated in subsequent steps. The final result is obtained by summing the predictions of all the trees in the model (Nguyen et al., 2019), as expressed in equation:

y ^ i = ∑ k = 1 K f k x i (1)

where y^i is the predicted value for observation i, K is the total number of trees, fk represents the k-th decision tree, and xi are the input features.

A distinctive feature of XGBoost compared to other boosting methods, such as gradient boosting (Ke et al., 2017) and adaptive boosting (Margineantu & Dietterich, 1997), is the way its objective function works. The objective function combines two main components: a loss function that measures prediction error and a regularization term that controls model complexity (Chen & Guestrin, 2016). This can be formulated as:

L ϕ = ∑ i = 1 n l y ^ i , y i + ∑ k = 1 K Ω f k (2)

where l is a differentiable convex loss function that measures the difference between the prediction y^i and the target yi, and Ωfk is the regularization term that penalizes the complexity of the model to prevent overfitting. The regularization term is defined as:

Ω f = γ T + 1 2 λ ∑ j = 1 T w j 2 (3)

where T is the number of leaves in the tree, wj is the score on the j-th leaf, and γ and λ are regularization parameters. During training, the loss is minimized using second-order Taylor series expansion, which speeds up convergence and makes the model more efficient and robust (Chen & Guestrin, 2016).

XGBoost offers several advantages that make it particularly suitable for well log prediction tasks. First, it efficiently handles non-linear relationships between input features, which is essential for modeling complex geological relationships (Pan et al., 2022). Second, the algorithm is robust to outliers and missing data, common challenges in well log datasets (Feng et al., 2021). Third, XGBoost provides feature importance rankings, enabling interpretation of which well logs contribute most to sonic log prediction (Ribeiro et al., 2016). Finally, its efficient parallel processing capabilities allow for rapid hyperparameter optimization, which is crucial for achieving optimal predictive performance (Qiu et al., 2024).

These characteristics make XGBoost particularly well-suited for predicting sonic logs from conventional well logs, as demonstrated by recent successful applications in reservoir characterization and petrophysical property estimation (Pan et al., 2022; Rahmati et al., 2024; Wu et al., 2024).

2.5 Metrics

To evaluate the performance of the XGBoost Regressor model in predicting sonic logs, three standard metrics were employed: Mean Absolute Error (MAE), Root Mean Square Error (RMSE), and Coefficient of Determination (R2). These metrics are widely used in regression problems and provide complementary information about model accuracy and reliability (Montgomery & Runger, 2018).

The Mean Absolute Error (MAE) measures the average magnitude of prediction errors, providing an easily interpretable metric in the same units as the target variable. It is defined as:

MAE = 1 n ∑ i = 1 n | Y true , i − Y pred , i | (4)

The Root Mean Square Error (RMSE) gives higher weight to larger errors due to the squaring operation, making it more sensitive to outliers than MAE. It is calculated as:

RMSE = 1 n ∑ i = 1 n ( Y true , i − Y pred , i ) 2 (5)

The Coefficient of Determination (R2) indicates the proportion of variance in the dependent variable that is predictable from the independent variables. It ranges from 0 to 1, where values closer to 1 indicate better model fit:

R 2 = 1 − ∑ i = 1 n ( Y true , i − Y pred , i ) 2 ∑ i = 1 n ( Y true , i − Y avg ) 2 (6)

where n is the number of observations, Ytrue represents the actual sonic log values, Ypred represents the predicted values, and Yavg is the mean of the actual values.

The optimal model is characterized by minimizing MAE and RMSE while maximizing R2. Lower MAE and RMSE values indicate smaller prediction errors, while higher R2 values indicate that the model explains a greater proportion of the variance in the sonic log data. These metrics were calculated for both the cross-validation phase and the blind test to assess the model’s generalization capability (Pedregosa et al., 2011).

2.6 Hyperparameter optimization

The performance of machine learning models is closely associated with the appropriate choice of hyperparameters. To optimize the hyperparameters of the three models, this study employed the RandomizedSearchCV method from the scikit-learn library (Pedregosa et al., 2011), which uses random sampling to identify the best hyperparameter combinations within a defined search space. A total of 50 random combinations were evaluated per model. The criterion used to select the best configuration was the mean R2 across all validation folds.

To prevent data leakage during hyperparameter tuning, cross-validation was performed using GroupKFold (cv = 10) with well identity as the grouping variable, ensuring that all depth samples from a given well appeared exclusively in either the training or the validation fold within each split. Standard random KFold applied to depth-point data would place adjacent samples — which are highly correlated due to the continuity of geological formations — on both sides of a split, artificially inflating validation scores and overestimating generalization performance.

The hyperparameter search ranges and final optimized values for the three models are presented in Table 4. The best GroupKFold cross-validation R2 scores obtained during tuning were 0.890 for XGBoost, 0.888 for Random Forest, and 0.770 for Ridge Regression, confirming the superior capacity of ensemble methods to capture the non-linear relationships between the input logs and DT in the Sergipe-Alagoas Basin.

Table 4
Hyperparameter search ranges and optimized values for the three models.

3. RESULTS

3.1 LOWO performance overview

Table 5 summarizes the Leave-One-Well-Out (LOWO) performance of the three models across the 28 wells of the Sergipe-Alagoas Basin, expressed as the median and interquartile range (IQR) of R2, RMSE, and MAE. The distributions are illustrated in Figure 4 (boxplots) and Figure 5 (per-well R2 comparison).

Table 5
Summary of LOWO performance metrics for the three models across 28 wells.
Figure 4
Distribution of LOWO performance metrics across 28 wells for the three models. The red dashed line in the R2 panel indicates the R2= 0.70 threshold. Circles represent outlier wells. Ridge Regression shows substantially higher variability and lower central tendency than the ensemble methods.
Figure 5
Per-well R2 from LOWO validation, sorted by XGBoost performance. The red dashed line marks R2= 0.70. The near-identical performance of Random Forest and XGBoost across all 28 wells — including the four underperforming wells — confirms that prediction limitations are data-driven rather than model-specific.

Ridge Regression achieved a median R2 of 0.621 (IQR = 0.259), with a median RMSE of 6.06 µs/ft and MAE of 4.64 µs/ft. The wide IQR and the occurrence of negative R2 values in two wells (Figure 4, min = −0.29) indicate that the linear model failed systematically in a subset of wells where the relationship between the input logs and DT is predominantly non-linear. Both ensemble methods substantially outperformed the linear baseline: Random Forest yielded a median R2 of 0.815 (IQR = 0.160, RMSE = 4.38 µs/ft) and XGBoost a median R2 of 0.818 (IQR = 0.152, RMSE = 4.36 µs/ft). The near-identical performance of RF and XGBoost — differing by less than 0.01 in median R2 — confirms that the predictive limit for this feature set and basin is consistent across gradient-based and bagging ensemble methods. Notably, XGBoost presented the smallest IQR across all three metrics, indicating marginally greater consistency across wells.

Figure 5 shows the per-well R2 comparison sorted by XGBoost performance. A consistent pattern is observed: Random Forest and XGBoost produce nearly identical R2 values for each well, whereas Ridge Regression diverges substantially, particularly in the lower-performing wells. This confirms that the dominant limitation in those wells is not algorithmic but reflects properties of the input data that cannot be captured by any of the three models evaluated.

3.2 XGBoost – detailed analysis

Given that XGBoost demonstrated the best overall LOWO performance, the following analysis focuses on this model. When all 231,816 predicted depth samples from the 28 LOWO iterations are aggregated, the global scatter between predicted and measured DT values yields R2= 0.913, RMSE = 4.53 µs/ft, and MAE = 3.30 µs/ft (Figure 6). This aggregated view complements the per-well median metrics by showing the overall point-by-point prediction quality across the full depth range of the basin. The point cloud aligns closely with the 1:1 reference line throughout the DT range of approximately 55-165 µs/ft, with no systematic bias apparent across the bulk of the data.

Figure 6
Scatter plot of XGBoost predicted versus true DT values aggregated across all 28 LOWO iterations (231,816 depth samples). The red line represents the 1:1 reference. Global metrics: R2= 0.913, RMSE = 4.53 µs/ft, MAE = 3.30 µs/ft.

Residual analysis across all 28 wells (Figure 7) shows that the prediction errors are approximately symmetrically distributed around zero, with a global mean residual of +0.187 µs/ft, indicating negligible systematic bias. The residual distribution is unimodal and approximately normal, with the majority of errors concentrated within ±10 µs/ft. The plot of residuals versus predicted DT confirms that the variance of errors is relatively homogeneous across the full prediction range, with no strong heteroscedastic pattern, though a slight increase in dispersion is observed at higher DT values, corresponding to shallower or more porous formations where acoustic slowness is more sensitive to local petrophysical variations.

Figure 7
Residual analysis for XGBoost LOWO predictions across all 28 wells. Left: histogram of residuals showing a near-symmetric distribution with mean = +0.187 µs/ft. Right: residuals versus predicted DT, showing no strong systematic pattern across the prediction range.

Feature importance analysis (Figure 8) reveals that neutron porosity (NPHI) is by far the dominant predictor, accounting for 63.6% of the total F-score. Deep resistivity (RT90) contributes 17.8%, bulk density (RHOB) 14.7%, and gamma ray (GR) 3.9%. The dominant role of NPHI is physically consistent: compressional wave slowness is directly related to formation porosity through the Wyllie time-average equation (Wyllie et al., 1956), and NPHI provides the most direct measurement of porosity among the four input features. The secondary contribution of RT90 reflects the influence of fluid content and clay volume on both resistivity and acoustic velocity, particularly in sandstone intervals. The relatively low importance of GR — despite its role as a lithology discriminator — suggests that in the Sergipe-Alagoas Basin, lithological variation is largely captured indirectly through NPHI and RHOB.

Figure 8
XGBoost feature importance (F-score) for DT prediction. NPHI is the dominant predictor (63.6%), consistent with the direct physical relationship between porosity and compressional wave slowness. GR contributes minimally (3.9%), suggesting that lithological information is largely encoded in the porosity and density logs.

Figure 9 illustrates the LOWO prediction for well 9-BRSA-1280D-SES, the well with the largest sample count in the dataset (21,838 depth samples, depth range 3,450-5,776 m). This well achieved R2= 0.930, RMSE = 3.986 µs/ft, and MAE = 2.843 µs/ft. The predicted DT curve closely follows the measured log across the entire depth interval, reproducing both the low-frequency trend and the high-frequency variations associated with lithological changes. A small negative bias of −0.710 µs/ft indicates a marginal tendency to underestimate DT, consistent with the global mean residual. This well illustrates the model's capacity to generalize effectively when trained on the remaining 27 wells covering comparable geological settings.

Figure 9
LOWO prediction for well 9-BRSA-1280D-SES (R2= 0.930). Left: predicted (red) and measured (black) DT curves versus depth. Right: scatter plot of predicted versus true DT with 1:1 reference line (red) and linear trend (orange dashed). Metrics: RMSE = 3.986 µs/ft, MAE = 2.843 µs/ft, bias = −0.710 µs/ft.

Four wells presented R2 below the 0.70 threshold under LOWO validation for both XGBoost and Random Forest (Table 6). This convergent underperformance across two independent ensemble algorithms, using identical training data and features, indicates that the prediction limitation is inherent to the data characteristics of these wells rather than to the modelling approach. The geological and petrophysical factors associated with this underperformance are examined in the Discussion section.

Table 6
Wells with R2< 0.70 under LOWO validation for XGBoost.

Figure 10 illustrates the prediction for well 3-BRSA-1069-SES (R2= 0.385), the lowest-performing well in the dataset. In contrast to the well shown in Figure 9, the predicted curve systematically overestimates acoustic slowness throughout the interval, with a positive bias of +4.249 µs/ft — indicating that the model predicts the rock as slower (higher DT) than measured. The scatter plot shows that the trend line (y = 1.201x − 14.331) departs markedly from the 1:1 reference, confirming a systematic rather than random error. The geological factors underlying this behaviour are discussed in Section 4.

Figure 10
LOWO prediction for well 3-BRSA-1069-SES (R2= 0.385). Left: predicted (red) and measured (black) DT curves versus depth. Right: scatter plot showing systematic positive bias (+4.249 µs/ft), indicating that the model consistently overestimates DT across the entire depth interval. Metrics: RMSE = 6.352 µs/ft, MAE = 4.554 µs/ft.

4. DISCUSSION

A key methodological contribution of this study is the adoption of the Leave-One-Well-Out (LOWO) protocol combined with GroupKFold cross-validation for hyperparameter optimization, in which well identity is used as the grouping variable. Most published studies on compressional sonic log prediction evaluate model performance on a single blind well (Tahiru et al., 2022; Saleh et al., 2025; Vázquez-Ayala et al., 2025), which provides no information about the variability of prediction quality across different geological conditions within the same basin. A single blind well test can be highly optimistic if that well happens to be representative of the training set, or misleadingly pessimistic if it is atypical. By evaluating all 28 wells under identical conditions, the LOWO protocol provides a statistically robust characterization of model generalization: the interquartile range of R2 across wells (IQR = 0.152 for XGBoost) quantifies prediction variability that a single blind well evaluation would entirely conceal. Furthermore, the use of GroupKFold during hyperparameter tuning ensures that cross-validation scores are not inflated by the high serial correlation between adjacent depth samples, a known source of data leakage in random depth-point splitting schemes applied to well log data.

Feature importance analysis identified neutron porosity (NPHI) as the dominant predictor of DT in the Sergipe-Alagoas Basin, accounting for 63.6% of the total F-score. This result is physically consistent with the Wyllie time-average equation (Wyllie et al., 1956), which establishes a direct relationship between formation porosity and compressional wave slowness: higher porosity leads to greater separation between grains and therefore higher DT values. Bulk density (RHOB) and deep resistivity (RT90) contribute 14.7% and 17.8%, respectively, reflecting their roles as secondary indicators of compaction state and fluid content. Gamma ray (GR) ranks last with 3.9%, suggesting that in the predominantly siliciclastic and shale-dominated stratigraphy of the Sergipe-Alagoas Basin, lithological variation is captured indirectly through the porosity and density logs rather than through radioactivity. This finding contrasts with Saleh et al. (2025), who reported GR as the most important feature in a CatBoost model trained on carbonate-dominated formations of the Western Desert of Egypt, where lithological contrasts between sandstone, siltstone, and limestone generate stronger GR differentiation relative to porosity variations. The divergence in feature importance rankings between the two studies illustrates that data-driven models reflect the local petrophysical relationships of the basin in which they are trained, and that feature importance rankings should not be generalized across geological settings without independent validation.

The LOWO performance of XGBoost (median R2= 0.818, RMSE = 4.36 µs/ft) is comparable to results reported in similar studies despite the more rigorous evaluation protocol adopted here. Tahiru et al. (2022) reported R2 of 0.88-0.99 at two blind wells in the Niger Delta Basin using Gradient Boosting with the same feature set (GR, RHOB, NPHI, resistivity), though their evaluation on only two wells in a turbidite sand-shale system does not allow direct comparison with the basin-wide variability captured by LOWO. Saleh et al. (2025) obtained correlation coefficients of 89-89.6% (equivalent to R2≈ 0.79-0.80) with RMSE of 5.85-6.03 µs/ft for ensemble methods at a single blind well in Egypt — values slightly lower than those obtained here for XGBoost and Random Forest. Vázquez-Ayala et al. (2025) reported considerably lower RMSE values of 1.4-1.7 µs/ft using a CNN–GRU deep learning architecture in the Tabasco Basin, Mexico; however, their study was conducted in a more homogeneous carbonate-siliciclastic setting with a smaller well inventory, conditions that inherently favour lower prediction errors than the lithologically diverse and structurally complex Sergipe-Alagoas Basin. The near-identical LOWO performance of XGBoost and Random Forest (median R2 difference of 0.004) indicates that the predictive limit imposed by the four-feature input set is consistent across gradient boosting and bagging ensemble approaches. The substantially lower performance of Ridge Regression (median R2= 0.621, IQR = 0.259) confirms that the relationship between the input logs and DT in this basin is predominantly non-linear, consistent with the known sensitivity of compressional velocity to porosity, clay content, and fluid saturation through mechanisms that cannot be adequately captured by a linear model (Chagas et al., 2010). This result is also consistent with Kim et al. (2023), who reported that gradient boosting outperformed linear approaches for wave velocity prediction in a geotechnical dataset with complex geological variability.

Four wells — 3-BRSA-1069-SES, 1-BRSA-930D-SES, 3-BRSA-1207-SES, and 1-BRSA-1013-SES — presented R2 below 0.70 under LOWO validation for both XGBoost and Random Forest, representing 14.3% of the dataset. The convergent underperformance of two independent ensemble models trained on identical data confirms that the prediction limitation is inherent to the characteristics of these wells rather than to the modelling approach. A preliminary analysis of these wells suggests that the dominant factors are geological and petrophysical in nature: anomalous compaction states relative to the regional depth trend, petrophysical heterogeneity of sandstone intervals associated with fluid saturation effects, and — in the case of 1-BRSA-930D-SES, the shallowest well in the dataset — the underrepresentation of shallow depth ranges in the training distribution, where the model has fewer analogues from which to generalize. As the primary objective of this study is to evaluate the performance of the XGBoost Regressor for compressional sonic log prediction across the Sergipe-Alagoas Basin, a detailed well-by-well analysis of these cases is beyond the scope of the present work and will be addressed in a forthcoming study.

Several limitations of the present study should be acknowledged. The predictive model is trained exclusively on data from the offshore portion of the Sergipe-Alagoas Basin and its performance in other geological settings or basins cannot be assumed without independent validation and retraining. The four-feature input set — GR, RT90, RHOB, and NPHI — represents the logs most commonly available in the study area, but excludes measurements such as the photoelectric factor (PE) and formation microresistivity that could improve lithological discrimination in carbonate-rich intervals (Saleh et al., 2025). Finally, while the LOWO protocol provides a rigorous assessment of inter-well generalization, it does not account for temporal or operational variability between logging runs, which may introduce additional uncertainty in practical deployment scenarios.

5. CONCLUSIONS

This study evaluated the XGBoost Regressor for compressional sonic log (DT) prediction from conventional well logs (GR, RT90, RHOB, NPHI) across 28 offshore wells of the Sergipe-Alagoas Basin, Brazil. A Leave-One-Well-Out (LOWO) validation protocol with GroupKFold hyperparameter optimization was adopted to provide a rigorous, leakage-free assessment of model generalization across the full well inventory of the basin. The following conclusions are drawn:

  • XGBoost achieved a median R2 of 0.818, RMSE of 4.36 µs/ft, and MAE of 3.14 µs/ft across the 28 LOWO iterations, demonstrating reliable predictive performance across diverse geological conditions within the basin. The IQR of R2 (0.152) characterizes the natural variability of prediction quality attributable to the geological heterogeneity of the dataset;

  • XGBoost and Random Forest produced near-identical LOWO performance (median R2 difference of 0.004), while Ridge Regression performed substantially worse (median R2= 0.621), confirming that the relationship between the conventional log suite and DT in the Sergipe-Alagoas Basin is predominantly non-linear and not adequately captured by linear models;

  • Feature importance analysis identified neutron porosity (NPHI) as the dominant predictor (63.6% F-score), consistent with the direct physical relationship between formation porosity and compressional wave slowness. The ranking differs from studies in carbonate-dominated settings, underscoring that feature importance is basin- and lithology-specific;

  • Four wells (14.3%) presented R2 below 0.70 for both ensemble models, with underperformance attributed to geological and petrophysical factors including compaction anomalies, fluid saturation effects in sandstone intervals, and shallow depth ranges underrepresented in the training distribution. A detailed analysis of these cases will be the subject of a forthcoming study;

  • The LOWO + GroupKFold framework adopted here provides a reproducible and leakage-free evaluation protocol that can be extended to the prediction of other geophysical log types and applied to other sedimentary basins, provided that sufficient multi-well datasets are available for training.

ACKNOWLEDGEMENTS

The authors would like thank to the Universidade Federal do Paraná (UFPR), Programa de Pós Graduação em Geologia (PPGEOL), Laboratório de Análises de Bacias e Petrofísica (LABAP), Coordenação de Aperfeiçoamento de Pessoal de Nível Superior - Brasil (CAPES) – Finance Code 001, the geologists Marina Martins (PRIO) and Tiago de Bittencourt Rossi (Petrobras) and the data scientist Marcelo Guarido de Andrade (CREWES) for their technical assistance.

Manuscript ID: BJGEO-0001-2026.R1.

How to cite:

Brunetta, R., & Aquino, C. D. Predicting sonic log from well log in the Sergipe-Alagoas Basin using XGBoost Regressor algorithm. Braz. J. Geol. (2026), 56:e00012026. https://doi.org/10.1590/2317-4889/e00012026

Financial support:

This study was financed in part by the Coordenação de Aperfeiçoamento de Pessoal de Nível Superior – Brasil (CAPES) – Finance Code 001.

Data availability statement:

The dataset supporting the results presented in this article is publicly available at https://github.com/rbrunetta/sonic-log-prediction (Brunetta & Aquino, 2024). The repository includes: Well log data from 28 offshore wells in the Sergipe-Alagoas Basin provided by ANP (Brazilian National Agency of Petroleum, Natural Gas and Biofuels). Complete Python source code for data preprocessing, quality control, and model training. Jupyter notebooks documenting the exploratory data analysis, hyperparameter optimization, and Leave-One-Well-Out (LOWO) validation for Ridge Regression, Random Forest, and XGBoost. Optimized hyperparameter configurations for all three models. Comprehensive documentation for reproducing all results presented in this study. All code is released under an open-source license to facilitate reuse and extension by the research community.

REFERENCES

  • Ali, M., Jiang, R., Ma, H., Pan, H., Abbas, K., Ashraf, U., & Ullah, J. (2021). Machine learning: A novel approach of well logs similarity based on synchronization measures to predict shear sonic logs. Journal of Petroleum Science Engineering, 203, 108602. https://doi.org/10.1016/j.petrol.2021.108602
    » https://doi.org/10.1016/j.petrol.2021.108602
  • Antonietto, L. S., Carmo, D. A., Viviers, M. C., & Adôrno, R. R. (2015). Biostratigraphic and paleozoogeographic review of the upper aptian-albian ostracods of riachuelo formation, Sergipe-Alagoas Basin, Northeastern Brasil. Revista Brasileira de Paleontologia, 18(3), 355-368. https://doi.org/10.4072/rbp.2015.3.02
    » https://doi.org/10.4072/rbp.2015.3.02
  • Asmus, H. E. (1984). Geologia da margem continental brasileira. In C. Schobbenhaus, D. A. Campos, G. R. Derze & H. E. Asmus (Eds.), Geologia do Brasil Brasília: DNPM.
  • Asmus, H. E., & Porto, R. (1972). Classificação das bacias sedimentares brasileiras segundo a tectônica de placas. In Anais Do XXVI Congresso Brasileiro de Geologia (pp. 67-90), Belém, Brazil. São Paulo: Sociedade Brasileira de Geologia.
  • Berggren, W. A., & Hollister, C. D. (1974). Paleogeography, paleobiogeography and the history of circulation in the Atlantic Ocean. In W. W. Hay (Ed.), studies in paleo-oceanography (Special Publications). Oklahoma: Society of Economic Paleontologists; Mineralogists. https://doi.org/10.2110/pec.74.20.0126
    » https://doi.org/10.2110/pec.74.20.0126
  • Breiman, L. (2001). Random forests. Machine Learning, 45(1), 5-32. https://doi.org/10.1023/A:1010933404324
    » https://doi.org/10.1023/A:1010933404324
  • Brunetta, R., & Aquino, C. D. (2024). Sonic Log Prediction using XGBoost.https://github.com/rbrunetta/sonic-log-prediction
    » https://github.com/rbrunetta/sonic-log-predictio
  • Campos Neto, O. P. A., Souza-Lima, W., & Cruz, D. E. G. (2007). Bacia de Sergipe-Alagoas. Boletim de Geociências Da Petrobras, 15, 405-415.
  • Chagas, E. S., Russo, S. L., & Simon, V. H. (2010). Geração de perfil sônico sintético em poços de petróleo através dos modelos de regressão não lineares usando a profundidade como variável regressora. Scientia Plena, 6(12), 1-21.
  • Chen, T., & Guestrin, C. (2016). XGBoost: A scalable tree boosting system. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (pp. 785-794), San Francisco, CA. ACM.
  • Feijó, F. J. (1994). Bacias de Sergipe e Alagoas. Boletim de Geociências da Petrobras, 8, 149-161.
  • Feng, R., Grana, D., & Balling, N. (2021). Imputation of missing well log data by random forest and its uncertainty analysis. Computers & Geosciences, 152, 104763. https://doi.org/10.1016/j.cageo.2021.104763
    » https://doi.org/10.1016/j.cageo.2021.104763
  • Friedman, J. H. (2001). Greedy function approximation: A gradient boosting machine. Annals of Statistics, 29(5), 1189-1232. https://doi.org/10.1214/aos/1013203451
    » https://doi.org/10.1214/aos/1013203451
  • Hoerl, A. E., & Kennard, R. W. (1970). Ridge regression: Biased estimation for nonorthogonal problems. Technometrics, 12(1), 55-67. https://doi.org/10.1080/00401706.1970.10488634
    » https://doi.org/10.1080/00401706.1970.10488634
  • Ke, G., Meng, Q., Finley, T., Wang, T., Chen, W., Ma, W., Ye, Q., & Liu, T.-Y. (2017). LightGBM: A highly efficient gradient boosting decision tree. Advances in Neural Information Processing Systems, 30, 3146-3154. http://papers.nips.cc/paper/6907-lightgbm-a-highly-efficient-gradient-boosting-decision-tree.pdf
    » http://papers.nips.cc/paper/6907-lightgbm-a-highly-efficient-gradient-boosting-decision-tree.pdf
  • Kellogg, J. N., & Mohriak, W. U. (2001). The tectonic and geological environment of coastal South America. In B. Seelinger & U. Kjerfbe (eds.), Coastal marine ecosystems of Latin America New York: Springer.. https://doi.org/10.1007/978-3-662-04482-7_1
    » https://doi.org/10.1007/978-3-662-04482-7_1
  • Kim, J., Kang, J.-D., & Kim, B. (2023). Machine-learning models to predict P- and S-wave velocity profiles for Japan as an example. Frontiers in Earth Science, 11, 1267386. https://doi.org/10.3389/feart.2023.1267386
    » https://doi.org/10.3389/feart.2023.1267386
  • Lana, M. C. (1990). Bacia de Sergipe-Alagoas: Uma hipótese de evolução tectono-sedimentar. In G. P. R. Gabaglia & E. J. Milani (Eds.), Origem e evolução das bacias sedimentares. Rio de Janeiro: Petrobras.
  • Margineantu, D. D., & Dietterich, T. G. (1997). Pruning adaptive boosting. ICML, 97, 211-218.
  • Mello e Silva, F. G., Beneduzi, C. F., Nassau, G. F., & Rossi, T. B. (2019). Using sonic log to estimate porosity and permeability in carbonates. In Proceedings of the 16th International Congress of the Brazilian Geophysical Society, Rio de Janeiro, Brazil. SBGf. https://doi.org/10.22564/16cisbgf2019.295
    » https://doi.org/10.22564/16cisbgf2019.295
  • Milani, E. J., Rangel, H. D., Bueno, G. V., Stica, J. M., Winter, W. R., Caixeta, J. M., & Pessoa Neto, O. C. (2007). Bacias sedimentares brasileiras: Cartas estratigráficas. Boletim de Geociências da Petrobras, 15, 183-205.
  • Mohriak, W. U., & Fainstein, R. (2012). Phanerozoic regional geology of the eastern Brazilian margin. In D. G. Roberts & A. W. Bally (Eds.), Regional geology and tectonics. New York: Elsevier.
  • Mohriak, W. U., Nemcok, M., & Enciso, G. 2008. South Atlantic divergent margin evolution: Rift-border uplift and salt tectonics in the basins of SE Brazil (Special Publications, No. 294). London: Geological Society. https://doi.org/10.1144/SP294.19
    » https://doi.org/10.1144/SP294.19
  • Montgomery, D. C., & Runger, G. C. (2018). Applied statistics and probability for engineers (7th ed.). New York: Wiley.
  • Nguyen, H., Bui, X.-N., Bui, H.-B., & Cuong, D. T. (2019). Developing an XGBoost model to predict blast-induced peak particle velocity in an open-pit mine: A case study. Acta Geophysica, 67(2), 477-490. https://doi.org/10.1007/s11600-019-00268-4
    » https://doi.org/10.1007/s11600-019-00268-4
  • Pan, S., Zheng, Z., Guo, Z., & Luo, H. (2022). An optimized XGBoost method for predicting reservoir porosity using petrophysical logs. Journal of Petroleum Science Engineering, 208, 109520. https://doi.org/10.1016/j.petrol.2021.109520
    » https://doi.org/10.1016/j.petrol.2021.109520
  • Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., & Thirion, B. (2011). Scikit-Learn: Machine Learning in Python. Journal of Machine Learning Research, 12(85), 2825-2830.
  • Qiu, Y., Zhang, N., Yin, Z., Wang, Y., Xu, C., & Zhang, P. (2024). Novel multi-spatial receptive field (MSRF) XGBoost method for predicting geological cross-section based on sparse borehole data. Engineering Geology, 338, 107604. https://doi.org/10.1016/j.enggeo.2024.107604
    » https://doi.org/10.1016/j.enggeo.2024.107604
  • Rahmati, M., Zargar, G., & Tanha, A. A. (2024). Predicting density log from well log using machine learning techniques and heuristic optimization algorithm: A comparative study. Petroleum Research., 9(2), 176-192. https://doi.org/10.1016/j.ptlrs.2024.01.008
    » https://doi.org/10.1016/j.ptlrs.2024.01.008
  • Ribeiro, M. T., Singh, S., & Guestrin, C. (2016). “Why should i trust You?” Explaining the predictions of any classifier. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining. New York: Association for Computing Machinery.
  • Saleh, K., Mabrouk, W. M., & Metwally, A. (2025). Machine learning model optimization for compressional sonic log prediction using well logs in Shahd SE field, Western Desert, Egypt. Scientific Reports, 15(1), 14957. https://doi.org/10.1038/s41598-025-97938-9 PMid:40301475.
    » https://doi.org/10.1038/s41598-025-97938-9
  • Tahiru, I. T., Olagundoye, O., & Alabere, A. O. (2022). Machine learning for sonic logs prediction: A case study from the Niger Delta Basin in the Gulf of Guinea. In International Petroleum Technology Conference, Riyadh, Saudi Arabia. OnePetro. https://doi.org/10.2523/IPTC-21932-MS
    » https://doi.org/10.2523/IPTC-21932-MS
  • Vázquez-Ayala, J. A., Ortiz-Alemán, J. C., López-Juárez, S., Couder-Castañeda, C., & Trujillo-Alcántara, A. (2025). Prediction of sonic well logs using deep neural network: Application to petroleum reservoir characterization in Mexico. Geosciences, 15(11), 424. https://doi.org/10.3390/geosciences15110424
    » https://doi.org/10.3390/geosciences15110424
  • Wu, X., Xu, H., Zhou, H., Wang, L., Jiang, P., & Wu, H. (2024). Improving lithofacies prediction in lacustrine shale by combining deep learning and well log curve morphology in Sanzhao Sag, Songliao Basin, China. Computers & Geosciences, 193, 105735. https://doi.org/10.1016/j.cageo.2024.105735
    » https://doi.org/10.1016/j.cageo.2024.105735
  • Wyllie, M. R. J., Gregory, A. R., & Gardner, L. W. (1956). Elastic wave velocities in heterogeneous and porous media. Geophysics, 21(1), 41-70.

*

Corresponding author.

Conflict of interest:

The authors declare that they have no conflict of interest.

SCIENTIFIC EDITOR:

ASSOCIATE EDITOR:

Publication Dates

  • Publication in this collection
    13 Nov 2026
  • Date of issue
    2026

History

  • Received
    12 Jan 2026
  • Accepted
    24 Aug 2026
Creative Common - by 4.0
This is an Open Access article distributed under the terms of the Creative Commons Attribution license (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
location_on
Sociedade Brasileira de Geologia R. do Lago, 562 - Cidade Universitária, 05466-040 São Paulo SP Brasil, Tel.: (55 11) 3459-5940 - São Paulo - SP - Brazil
E-mail: bjgeo.secretaria@editoracubo.com.br
rss_feed Stay informed of issues for this journal through your RSS reader
Go to top