The stock market, as a highly complex, unstable and dynamically changing system, is affected by a wide range of factors, such as political, economic, social and technological, in terms of price changes. Therefore, stock price prediction is a challenging problem, but also a problem of great importance. In order to provide a more accurate and reliable method for stock closing price prediction, this paper aims to reduce investment risk and improve investment returns by comparing the prediction effects of different regression models for investors to make investment strategies and decisions. In this paper, Open, High, Low, and Adj Close are used as input parameters, Close is used as the target parameter, the final closing price of the stock is determined from the various stock data, the training set, validation set, and test set are divided in accordance with 6:2:2, and the predictive effect of the model is evaluated using the parameters of MSE, RMSE, MAE, MAPE, and R2. After the comparison of multiple machine learning algorithms, XGBoost regression model and Random Forest Regression model perform the best in the prediction of stock closing price, and their MSEs are 0.061 and 0.072 respectively; followed by LightGBM regression model and decision tree regression model, the MSEs of the two models are 0.113 and 0.299 respectively, but the prediction results of BP neural network regression are poor. By comparing the prediction results of different regression models, it can provide investors with a more accurate and reliable method to predict the closing price of stocks, help investors better formulate investment strategies and decisions, reduce investment risks and improve investment returns. This is of great significance to both individual and institutional investors.