To address the problem of predicting machining quality for critical features in the manufacturing process of mechanical products, a method that combines information entropy and XGBoost (version 2.1.1) hyperparameter optimization is proposed. Initially, machining data of mechanical products are analyzed based on information entropy theory to identify critical quality characteristics. Subsequently, a quality prediction model for these critical features is established using the XGBoost machine learning framework. The model’s hyperparameters are then optimized through Bayesian optimization. This method is applied as a case study to a medium-speed marine diesel engine piston. After the critical quality characteristics in the machining process are identified, the machining quality of these vital characteristics is predicted, and the results are compared with those obtained from a machine learning model without hyperparameter optimization. The findings demonstrate that the proposed method effectively predicts the machining quality of mechanical products.