A novel inverse intelligent model is developed to predict porosity in real time while drilling. It applies established machine learning (ML) models to gas-while-drilling (GWD) data calibrated with core porosity measurements for a saturated oil reservoir. The data are associated with the Cambro-Ordovician sandstone reservoir in the giant Hassi Messaoud oil and associated gas field, located in central-eastern Algeria. The ML methods applied to the input dataset of nine variables recorded while drilling are, extreme learning machine (ELM), support vector regression (SVR), random forest regression (RFR), multilayer perceptron neural network (MLPNN), and generalized regression neural network (GRNN) and their results compared with a suite of statistical prediction accuracy performance metrics: correlation coefficient (R), Nash-Sutcliffe efficiency coefficient (NSE), the root mean square error (RMSE), and the mean absolute error (MAE). The ELM model was found to deliver the highest accuracy in predicting real-time porosity for the validation data records (R∼0.929, NSE∼0.865, RMSE∼3.325%; MAE∼ 2.595%). The method and results identify a rapid and accurate new approach to the real-time prediction of rock porosity with only GWD data. The GWD input variables are typically available in every field well drilled at a much lower cost than running measurement while drilling (MWD) or wireline logging tool traditional used to provide porosity information. Each of the evaluated ML models could be easily integrated with real-time monitoring systems as wells are drilled. By doing so, substantial time saving and economic savings could be achieved in comparison with the extensive laboratory measurements and MWD/wireline tools that currently required to assesses reservoir porosity in field development wells. The method also provides petroleum engineers with real-time “quick look” porosity information during drilling that can contribute to safe real-time decision making. The method has potential for gas and oil reservoir evaluations.