As energy demand continues to rise and conventional fuel sources dwindle, there is growing emphasis on previously overlooked reservoirs, such as tight reservoirs. Shale and coal formations have emerged as highly attractive options due to their substantial contributions to global gas reserves. Enhanced shale gas recovery (ESGR) and enhanced coalbed methane recovery (ECBM) based on gas injection are advanced techniques used to increase the extraction of gas from shale and coal formations. One of the key challenges associated with these formations and their enhanced recovery methods is accurately predicting the sorption process and its profile. This is crucial because it affects how methane (CH4) and carbon dioxide (CO2) are stored and released from the rock, and it significantly impacts the evaluation of gas content and the potential productivity of these formations. Due to the high cost of experimental procedures and the moderate accuracy of existing predictive approaches, this study proposes various cheap and consistent data‐driven schemes for predicting the sorption of CH4 and CO2 in shale and coal formations. In this regard, three intelligent models, including generalized regression neural network (GRNN), radial basis function neural network (RBFNN), and categorical boosting (CatBoost), were taught and tested using more than 3800 real measurements of CH4 and CO2 sorption in shale and coal formations. To find automatically their appropriate control parameters and improve their prediction ability, RBFNN and CatBoost were evolved using grey wolf optimization (GWO). The obtained results exhibited the encouraging prediction capabilities of the suggested models. In addition, it was found that CatBoost‐GWO is the most accurate scheme with total root mean square (RMSE) and determination coefficient (R2) of 0.1229 and 0.9993 for CO2 sorption, and 0.0681 and 0.9970 for CH4 sorption, respectively. Additionally, this approach demonstrated its physical validity by respecting the real sorption tendencies with respect to operational parameters. Furthermore, the CatBoost‐GWO model outperforms recently published machine learning approaches. Lastly, the findings of this study offer a significant contribution by demonstrating that the suggested model can greatly improve the ease of estimating CO2 and CH4 sorption in tight formations, thereby facilitating the simulation of other parameters related to this process. © 2024 Society of Chemical Industry and John Wiley & Sons, Ltd.