Maximum Dry Density (MDD) and Optimum Moisture Content (OMC) are two important parameters of soil filling, which affect the soil stability and bearing capacity, and thus the reliability and durability of facilities such as highways and bridges. Therefore, it is important to make reasonable predictions of OMC and MDD. Four machine learning algorithms, namely, Support Vector Machine (SVM), Artificial Neural Network (ANN), Random Forest (RF), and Extreme Gradient Boosting Tree (XGBoost), are adopted in this paper to establish MDD and OMC prediction models. After training and testing, the best models of the four algorithms are compared. The results show that, as an ensemble learning algorithm, XGBoost is the best model for predicting MDD and OMC, with an R2 of 0.9234 for OMC, and an R2 of 0.9098 for MDD. Finally, the feature importance analysis concludes that the plastic limit (PL) and the liquid limit (LL) are the two features that affect OMC and MDD the most. The prediction of soil compaction parameters using machine learning models, especially ensemble learning, can significantly reduce the amount of laboratory work and improve the efficiency of optimizing design for soil resource utilization in engineering construction.