In this research paper, we explored the predictive capabilities of three different models of Polynomial Regression (PR), Extreme Gradient Boosting (XGB), and LASSO to estimate the density of supercritical carbon dioxide (SC-CO2) and the solubility of niflumic acid as functions of the input variables of temperature and pressure. The optimization of hyperparameters for these models is achieved using the innovative Barnacles Mating Optimizer (BMO) algorithm. For SC-CO2 density estimation, PR exhibits remarkable accuracy, showing an R-squared value of 0.99207 for data fitting. XGB performs admirably with an R2 of 0.92673, while LASSO model demonstrates good predictive ability, showing an R2 of 0.81917. Furthermore, we assess the models’ performance in predicting the solubility of niflumic acid. PR exhibits excellent predictive capabilities with an R2 of 0.96949. XGB also delivers strong performance, yielding an R-squared score of 0.92961. LASSO performs well, achieving an R-squared score of 0.82094. The results indicated promising performance of machine learning models and optimizer in estimating drug solubility in supercritical CO2 as the solvent applicable for pharmaceutical industry.