Quantifying the wettability of shales is important for reservoir exploration and evaluation, as well as CO2 storage. Conventional experimental measurements are time-consuming and costly, while novel machine learning (ML) algorithms are challenged to predict shale wettability with accuracy and generalizability. Therefore, this study introduces an advanced shale wettability prediction framework by fusing ensemble learning algorithm and automatic hyperparameters optimization schemes (AHOS). Specifically, we firstly collected data from various gas geo-storage conditions from the literature. Then, an ensemble learning algorithm was utilized to extract complex nonlinear relationships among influential variables and shale wettability. During the training process, multiple optimization schemes, including random search (RS), Bayesian optimization (BO), and sequential model-based optimization (SMBO), were used and compared to automatically find the optimal hyperparameters of a wettability prediction model. The results show that AHOS can automatically and efficiently obtain the optimal hyperparameters, thus improves model's generalization. In addition, the prediction model based on AHOS process can accurately predict shale wettability. Through sensitivity analysis, we also revealed that the TOC and gas type are the top two most important influencing factors, which provides insights for CO2 sequestration. Moreover, we validated that the CatBoost model outperforms other tree-based models in predicting shale wettability and the SMBO method can provide a more effective result. In summary, the proposed shale wettability prediction framework is promising and efficient, which contributes to the exploration, evaluation, and development of shale oil reservoirs, further benefit to CO2 storage.