Oil and gas wells frequently encounter the issue of drilling fluid loss circulation as drilling progresses, leading to significant complications and expenses. Effective prediction of mud loss during drilling is crucial for optimizing the selection of loss circulation materials (LCMs), improving drilling efficiency, and reducing costs and risks. This study evaluates an ensemble method comprising five machine learning algorithms: Decision Tree (DT), Linear Regressor (LR), K-Nearest Neighbors (KNN), Gradient Boosting Regressor (GBR), and Random Forest (RF). Hyperparameters for these algorithms were fine-tuned using genetic algorithm (GA), particle swarm optimization (PSO), Grid Search, Random Search, and Bayesian Optimization to achieve optimal performance (R² close to 1).The ensemble method (DT, LR, KNN, GBR) achieved the highest prediction accuracy with R² = 0.969 and RMSE = 15.89. The K-Nearest Neighbors algorithm showed the least performance with an R² of 0.519. Effective hyperparameter tuning using various optimization techniques significantly improved model performance. The purpose of this article is to apply Grid Search, Random Search, Bayesian Optimization, Genetic Algorithm (GA), and Particle Swarm Optimization (PSO) to fine-tune the hyperparameters of an ensemble of machine learning (ML) models, thereby enhancing their predictive accuracy for mud loss. These methods offer a lower computational volume compared to deep learning techniques and simultaneously provide high execution speed.