Abstract:Forecasting the stock market is a difficult and intricate task, as price series often display traits like significant noise, nonlinearity and non-stationarity. In order to improve the accuracy of predictions, a new method that combined the Fuzzy C-Means (FCM) clustering algorithm to identify and utilize local trend features in stock price prediction sequences was proposed. In the analysis, key market data of stocks, including opening price, highest price, lowest price, closing price, trading volume, and trading amount, was comprehensively considered as input features for the prediction model. Through experiments, an empirical analysis was conducted to compare the impact of different sliding window sizes (16, 32, 64) on the model’s predictive capability. It is found that the FCM-LSTM-Transformer method, which integrates FCM clustering with the LSTM-Transformer combination model, achieves higher prediction accuracy than both the standalone deep learning models and the LSTM-Transformer combination model. The evaluation metrics MAE, MAPE, MSE and RMSE reach their minimum errors, and the coefficient of determination R2 improved by 2.75%, 2.4% and 2.19%, respectively. These results indicate that this model has a significant advantage in handling the complexity of stock market data.