Abstract:The accuracy of reservoir porosity prediction is crucial for assessing the storage capacity and quality of underground reservoirs. However, existing methods for porosity prediction face challenges such as limited model algorithms, low accuracy, and poor generalization. To enhance the precision of porosity prediction, this study proposes a Stacking ensemble learning method optimized by Optuna. First, gray relational analysis is used to select input parameters, including acoustic time difference, well depth, rock density, dip angle, and photoelectric absorption index. The input data is then normalized, and Optuna is employed to optimize the model parameters. Based on metrics like root mean square error, mean absolute error, and determination coefficient, random forest, support vector regression, and K-nearest neighbors are chosen as base learners for the Stacking model, with elastic net regression serving as the meta-learner. Comparative results reveal that while RF excels in handling nonlinear data, it shows instability in predictions; the Stacking model reduces RMSE by approximately 10% compared to RF. SVM demonstrates strong generalization ability but requires complex parameter tuning, with the Stacking model achieving about a 39% reduction in RMSE compared to SVM. KNN is insensitive to outliers but performs poorly on high-dimensional data, with the Stacking model lowering the error by about 21% compared to KNN. Additionally, XGBoost effectively avoids overfitting but is sensitive to outliers and requires complex tuning, with the Stacking model reducing the error by approximately 30% compared to XGBoost. Overall, the results indicate that the Optuna-optimized Stacking model significantly improves the accuracy of porosity prediction, providing a valuable reference for evaluating the oil and gas storage capacity of reservoirs.