Stock prediction method based on time convolution network fusion channel attention mechanism
By introducing time convolution network and channel attention mechanism into the stock price prediction model, the generalization ability and stability problems of traditional models in complex stock price data are solved, and more accurate prediction results are achieved.
Patent Information
- Application Number
- CN202411454818.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-01-14
AI Technical Summary
When facing complex and random stock price data, the traditional stock price prediction model has poor generalization ability and stability, and is prone to overfitting when processing daily frequency trading, resulting in poor prediction results.
Using a stock prediction model (TCN-SE) based on the time convolution network (TCN) fusion channel attention mechanism, the feature capture capability is enhanced by adding a channel attention module at the tail of each TCN residual block, and the feature capture capability is enhanced through expansion convolution and Residual connection captures historical time series relationships, and combines the channel attention mechanism to improve prediction accuracy.
It significantly improves the ability to capture the timing relationship of stock prices, achieves more accurate stock price prediction, reduces the generalization ability and stability of the model, and improves the overfitting problem through methods such as regularization and Dropout.
Smart Images

Figure CN119313467A_ABST
Abstract
Description
Technical field:
[0001] The present invention belongs to the field of stock prediction and time series trend prediction, and in particular relates to a stock prediction method based on a temporal convolutional network fusion channel attention mechanism. Background technology:
[0002] Stock prediction is of great significance and importance in the financial market. With the development of economic globalization, the stock market has become increasingly popular among investors, and the prediction of stock price trends has become the focus of academic and industry circles. However, the fluctuation of the stock market is affected by many internal and external factors, which are difficult to quantify, and the processing of massive stock data is a large engineering workload. Therefore, traditional non-artificial intelligence methods often have limited effects on stock price prediction. However, with the rapid development of big data, artificial intelligence and deep learning, many scholars have confirmed the predictability of stock prices, especially the prediction methods based on nonlinear models have more potential. In this context, the trend of combining quantitative technology with finance has become more and more obvious, and investors have an increasingly urgent need for a model that can accurately predict stock price trends. Accurate predictions not only help investors formulate effective investment strategies and reduce investment risks, but also provide strong support for the healthy development of the financial market. Therefore, studying stock prediction has important practical significance and far-reaching social impact.
[0003] Early stock price prediction methods were all based on time series prediction models designed based on statistical knowledge, including moving average model (MA), autoregressive moving average model (ARMA), autoregressive integrated moving average model (ARIMA), etc. The above methods are difficult to capture the nonlinearity and uncertainty of stock price time series data, especially when dealing with random interference factors, the prediction ability of these models will be significantly reduced.
[0004] Therefore, machine learning models have gradually replaced the traditional time series prediction models designed based on statistics, and transformed the time series prediction task into a supervised learning task. Machine learning time series prediction algorithms such as support vector regression (SVR), K-nearest neighbor algorithm (KNN), support vector machine (SVM) and random forest regression are proposed. These models can handle simple time series tasks with high efficiency.
[0005] With the development of science and technology, deep learning has developed rapidly. Various neural networks have emerged, such as convolutional neural networks, recurrent neural networks, etc., and have been applied in various fields. Many scholars and experts have trained these neural networks to predict stocks. In particular, the long short-term memory network (LSTM) is an improvement based on the recurrent neural network (RNN). This network uses additional gating structures to control the flow of information flow and has certain advantages in stock prediction.
[0006] The attention mechanism originates from the study of human vision. In cognitive science, due to the bottleneck of information processing, humans selectively focus on part of all information while ignoring other visible information. In order to make rational use of limited visual information processing resources, humans need to select a specific part of the visual area and then focus on it. In neural networks, the attention mechanism is usually an additional neural network that can rigidly select certain parts of the input or assign different weights to different parts of the input. The attention mechanism can filter out important information from a large amount of information. In recent years, the attention mechanism has developed rapidly and has been widely used in various fields, which has significantly improved the performance of the model. At the same time, some scholars have applied it to stock prediction and achieved good results.
[0007] Temporal Convolutional Network (TCN) is a neural network model that combines convolution operations and residual connections. It performs well in processing time series data. Compared with traditional convolutional networks, TCN has strong causality and will not leak future information. It is of great significance for processing time series prediction problems. In addition, TCN uses dilated convolution to better capture the relationship between historical time series. It can use fewer convolution kernels to obtain a larger receptive field and capture local dependencies.
[0008] However, when facing the task of stock prediction, the TCN network will have poor generalization ability and stability due to the strong randomness and volatility complexity of stocks. At the same time, when dealing with daily stock trading, the model will overfit due to the small amount of daily trading data. Most scholars tend to use regularization or Dropout methods to improve model performance when facing such problems, but the prediction results are not satisfactory. Summary of the invention:
[0009] Based on this, the present invention provides a stock prediction model (TCN-SE) based on a temporal convolutional network fused with a channel attention mechanism. TCN-SE has a stronger ability to capture temporal relationships when facing complex and highly random stock price data, and can more accurately predict stock prices. The channel attention module is added to the end of each TCN residual block to strengthen the channel features and further improve the prediction ability of the entire model.
[0011] To achieve the above object, the present invention provides a stock prediction method based on a temporal convolutional network fused channel attention mechanism, comprising the following steps:
[0012] S1: Determine the characteristics of the target stock to be predicted and obtain the stock historical characteristic data sequence;
[0013] S2: Divide the stock historical feature data sequence obtained in step S1 into a training set and a test set, normalize the data in the training set and the test set, and generate a two-dimensional data sequence;
[0014] S3: performing time step division processing on the two-dimensional data sequence generated in step S2, and generating corresponding feature labels to obtain three-dimensional data sequences of training set and test set;
[0015] S4: Perform TCN residual block processing and channel attention weighting on the three-dimensional data sequence of the training set generated in step S3. The stock prediction model has three layers, the first layer is an expansion causal convolution layer, a relu layer, a dropout layer, a residual layer, and a channel attention. The second layer is an expansion causal convolution layer, a relu layer, a dropout layer, a residual layer, and a channel attention. The third layer is an expansion causal convolution layer, a relu layer, a dropout layer, a residual layer, and a channel attention. The optimization target of the stock prediction model is constructed and it is iteratively and alternately trained;
[0016] S5: For the stock prediction model trained in step S4, the data of the test set is input into the model to evaluate and verify the stock prediction model and optimize its parameters.
[0017] Furthermore, the stock historical feature sequence in step S1 includes the opening price, closing price, highest price, lowest price, total trading volume, total transaction amount, turnover rate and rise and fall of each trading day.
[0018] Furthermore, the stock historical characteristic data sequence described in step S2 is normalized.
[0019] The historical feature data is normalized by the following formula:
[0020]
[0021] Where x is the input value and y is the normalized value. max is the maximum value of the sample, x min is the minimum value of the sample.
[0022] Furthermore, the two-dimensional data sequence generated in step S3 is processed by dividing the historical window data into steps of 20, and generating corresponding feature labels to obtain three-dimensional data with 32 data per batch, and the data shape is (batch size, feature, time step).
[0023] The historical window data step size of 20 means using the stock trading records of the past 20 days, including the opening price, closing price, highest price, lowest price, total trading volume, total transaction amount, turnover rate and price increase or decrease of the trading day, to predict the stock closing price of the next day.
[0024] Further, the expansion factor of the TCN residual block in step S4 is 1 in the first layer, the number of input channels is, the number of output channels is, the second layer is 2, the number of input channels is, the number of output channels is, the third layer is 4, the number of input channels is, the number of output channels is, and the expansion formula is:
[0025]
[0026] Stock price sequence X = {x t ,x t-1 …x1,x0} and convolution kernel f:{0,1,...,k-1}→R, where k is the convolution kernel size, td·n is the historical data, and d is the expansion factor. The expansion factor is usually set to increase exponentially with the depth of the network, that is, d=2 m , m is the number of layers in the network.
[0027] Furthermore, the channel attention described in step S4 includes: using a 1-dimensional adaptive average pooling operation, a first fully connected layer, a relu function, a second fully connected layer, a sigmoid function, and a compression ratio reduction of 16.
[0028] The loss function used in the stock prediction model is mean square error MSE, the optimization algorithm is Adam, the model uses 200 epochs, the size of each batch is 32, and the dropout value is 0.5.
[0029] The stock prediction method based on the temporal convolutional network fusion channel attention mechanism is characterized in that: after the stock prediction model is trained, the stock prediction model is stored in a model folder and saved as a pt file, so that the stock prediction model file saved in the folder can be directly loaded when used, thereby saving time for training the model.
[0030] Further, the evaluation verification described in step S5 includes:
[0031] The test data in the test set is input into the trained stock prediction model to obtain the prediction result.
[0032] Based on the comparison between the predicted value and the true value, four evaluation indicators are used, MAE, MAPE, RMSE and R^2. The first three evaluation indicators represent the error between the predicted value and the true value. The smaller the value of the three indicators, the more accurate the prediction result.
[0033] The last indicator represents the predictive ability of the model. The higher the score of the indicator, the better the predictive ability of the model.
[0034] The evaluation index of the stock prediction model is calculated by the following formula:
[0035]
[0036]
[0037]
[0038]
[0039] The beneficial effects of the present invention are:
[0040] 1) The present invention uses a temporal convolutional network combined with a channel attention mechanism to predict stocks. The temporal convolutional network can follow causality and use a smaller convolution kernel to capture a larger range of historical information without using future information. The channel attention mechanism combined with the temporal convolutional network can further enhance the feature information captured by the temporal convolutional network, improve the highlighting of important information, and better learn the laws of stock characteristics.
[0041] 2) In order to better predict stocks, the present invention improves the channel attention applied to images and replaces the two-dimensional convolution with a one-dimensional one, which can better cooperate with the temporal convolutional network and has a better effect on processing such time series prediction tasks. Description of the drawings:
[0042] Figure 1 An operation flow chart of a stock prediction method based on a temporal convolutional network fused channel attention mechanism provided by the present invention;
[0043] Figure 2 Schematic diagram of causal convolution of TCN neural network model;
[0044] Figure 3 Schematic diagram of dilated convolution for TCN neural network model;
[0045] Figure 4 Schematic diagram of the residual block of the TCN neural network model;
[0046] Figure 5 Schematic diagram of the SENet model;
[0047] Figure 6 It is a residual schematic diagram of the TCN-SE neural network model;
[0048] Figure 7 A schematic diagram of the prediction results of the SSE 50 Index stocks by a stock prediction method based on a temporal convolutional network fused channel attention mechanism provided by the present invention. Specific implementation method:
[0049] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0050] like Figure 1 The stock prediction method based on the temporal convolutional network fusion channel attention mechanism of this embodiment includes the following steps:
[0051] S1: Determine the characteristics of the target stock to be predicted and obtain the stock's historical characteristic data sequence.
[0052] This embodiment takes the closing price of the target stock as an example, and the feature data of the stock are selected as: the opening price, closing price, highest price, lowest price, total trading volume and total trading amount, turnover rate, and price increase or decrease of each trading day in history. This embodiment selects these eight-dimensional feature data as input features to predict the future closing price of the stock.
[0053] S2: Divide the stock historical feature data sequence obtained in step S1 into a training set and a test set, normalize the data in the training set and the test set, and generate a two-dimensional data sequence.
[0054] In this embodiment, the acquired stock historical feature data is divided into 80% training set and 20% test set, the training set data length is 0.8*N, and the test set data length is 0.2*N. The divided training set and test set are normalized.
[0055] N is the total length of the stock’s historical feature data.
[0056] The historical feature data is normalized by the following formula:
[0057]
[0058] Where x is the input value and y is the normalized value. max is the maximum value of the sample, x min is the minimum value of the sample.
[0059] The generated two-dimensional data has the first dimension of the training set being the length of the historical feature data of the training set, 0.7*N, and the second dimension being the number of input features, 8. The first dimension of the test set is the length of the historical feature data of the test set, 0.3*N, and the second dimension being the number of input features, 8.
[0060] The two-dimensional data sequence generated in step S2 is divided into time steps, and corresponding feature labels are generated to obtain the three-dimensional data sequences of the training set and the test set.
[0061] The predicted value y of the stock closing price in this embodiment t+1 With stock historical input data {xt ,x t-1 …x1,x0} form a mapping relationship, the formula is:
[0062] y t+1 =f(x t ,x t-1 …x1,x0) (2)
[0063] f is the mapping function.
[0064] In the stock prediction of this embodiment, "time step" refers to the time interval between one trading day and the next trading day in the stock sequence data. It defines the sampling frequency and time scale of the stock sequence data. The time step is set to 20, that is, the stock historical data of the previous 20 trading days predicts the stock closing price of the next day. The stock sequence of 20 trading days X = {x 20 ,x 19 …x2,x1}, and the closing price of the 21st trading day is x 21close As a label, each division is only one step sliding.
[0065] The three-dimensional data generated by the training set has the first dimension of , the second dimension of time step, and the third dimension of stock input features. The first dimension of the label of the training set is , and the second dimension is the closing price of time step + 1. The test set is the same as above.
[0066] The three-dimensional data sequence of the training set generated in step S3 is processed by TCN residual block and channel attention weighting. The stock prediction model has three layers, the first layer is an expansion causal convolution layer, a relu layer, a dropout layer, a residual layer, and a channel attention. The second layer is an expansion causal convolution layer, a relu layer, a dropout layer, a residual layer, and a channel attention. The third layer is an expansion causal convolution layer, a relu layer, a dropout layer, a residual layer, and a channel attention. The optimization target of the stock prediction model is constructed and it is iteratively trained.
[0067] In traditional neural networks, the connection of neurons in each layer violates the basic constraint of time sequence, because the neurons at the previous moment of output are connected to the neurons at the next moment of input, that is, using future information to predict the current result, which should not be allowed. Then, we can use the mask method to block the future information in the network layer and only use the current or previous information for prediction, so that the network meets the principle of time sequence dependency, such as Figure 2 As shown in the figure, the causal convolutional network follows the above principles and maintains the basic chronological dependencies when modeling data.
[0068] Since the coverage of historical information by causal convolution is not large, in order to ensure that historical information can be captured longer without adding too many parameters, dilated convolution is used on the basis of causal convolution, such as Figure 3 As shown in the figure, after the expansion, the perception field of the next layer of neurons in the causal neural network about the historical data of the previous neurons is greatly expanded, which also improves the modeling ability of the causal convolutional network for time series inference tasks that require longer memory.
[0069] The convolution kernel size is k, and the dilated convolution input sequence is X = {x t ,x t-1 …x1,x0} at time t is:
[0070]
[0071] Where td·n is the historical data, d is the expansion factor, and the expansion factor is usually set to increase exponentially with the depth of the network, that is, d = 2 m , m is the number of layers in the network.
[0072] In this embodiment, the expansion factor of the first layer is d=1, the second layer is d=2, and the third layer is d=4.
[0073] In order to better complete the task of time series prediction, TCN introduces a residual connection structure based on the dilated causal convolutional network, such as Figure 4 As shown in the figure. By introducing skip connections inside the module to directly pass the input information to the subsequent layers, the network can learn the residual part more easily. Residual connections can solve the problem of gradient vanishing and exploding: In deep networks, gradient vanishing and exploding is a common problem that makes the network unable to be trained effectively. By introducing residual connections, the gradient can be more easily propagated to the shallower layers, thus solving the problem of gradient vanishing and exploding.
[0074] The residual connection weightedly fuses the model input x into the model output F(x) to obtain the final TCN output O, which is calculated as shown in the formula:
[0075] O=Acticvation[x+F(x)] (4)
[0076] As a mechanism used by humans to process information, the attention mechanism can help the model better learn the relationship between different attributes and prevent the neural network from assigning the same weight to each predictor during the training process and ignoring important information. This paper introduces the channel attention mechanism, which fully mines important time series feature information in the feature channel dimension by calculating the vector weights of the output of each hidden layer in the time series convolutional neural network, and extracts more hierarchical and discriminative features, such as Figure 5 As shown in the figure. Since the time series input to the network are complex and diverse, it is generally difficult to extract significant information through traditional TCN. In order to make the network model more like the human perception system with the ability to extract high-value, significant information, it is of great significance to incorporate the attention mechanism into the model.
[0077] The channel attention mechanism (SENet) is usually divided into three parts:
[0078] The first step is the squeeze operation, which compresses features along the spatial dimension. The compression uses adaptive average pooling to convert each two-dimensional feature channel into a real number. This real number has a global receptive field to some extent, and the output dimension matches the number of input feature channels. It represents the global distribution of responses on the feature channel, and enables the layer close to the input to obtain the global receptive field, which is very useful in many tasks. For example, the formula:
[0079]
[0080] Among them, c is the c-th feature input of the channel attention, is the c-th feature output after the time convolution network, H×W represents the height and width of the input feature, O=[o1,o2,...,o C ], C represents the number of feature channels, also known as the number of convolution kernels, c Represents the output result after compression operation.
[0081] The second step is the excitation operation, which uses the information gathered in the compression operation to perform fully nonlinear interactive learning to capture multiple channel dependencies. As shown in the formula:
[0082] s=F ex (z,W)=σ(g(z,W)=σ(W2δ(W1z)) (6)
[0083] δ represents the Relu activation function, r represents the compression ratio, and σ is the Sigmoid activation function.
[0084] The last step is the reweighting operation, which regards the weight of the Excitation output as the importance of each feature channel after feature selection, and then weights it to the previous features channel by channel through multiplication to complete the recalibration of the original features in the channel dimension. For example, the formula:
[0085]
[0086] and F scale (o c ,s c ) is a scalar s c and feature map u c The product of .
[0087] The above is the channel attention for image tasks. In order to better perform stock prediction tasks, this paper adopts a one-dimensional adaptive average pooling operation, as shown in the following formula:
[0088]
[0089] L represents the time step.
[0090] like Figure 6 As shown in the figure, this paper designs a TCN-SE residual block model for stock prediction. The number of residual block layers of this model is set to 3, the size of the convolution kernel is 2, the number of neurons in each layer is 32, and the reduction ratio is set to 8.
[0091] The Dropout rate is 0.5 and the Learning Rate is set to 0.001.
[0092] The MSE (Mean Squared Error) loss function is used, and the Adam optimization algorithm is used.
[0093] The stock prediction model is connected sequentially according to the Sequential module built into PyTorch.
[0094] A Sequential model was built with a window sequence (time step) length of 20. The model was trained for 200 epochs and the size of each batch was 32.
[0095] After training the TCN-SE model and selecting the model with the lowest loss for saving, we start predicting the test set and evaluate and verify the prediction results, including:
[0096] The first indicator MAE (mean absolute error) is the average of the absolute differences between all predicted values and true values. The smaller the MAE, the closer the model prediction value is to the true value and the higher the prediction accuracy.
[0097] The calculation formula of MAE is as follows:
[0098]
[0099] The second indicator, MAPE (mean percentage error), is the average of the percentage errors between all predicted values and the true values. It is an important indicator to measure the accuracy of the predicted values. It expresses the average percentage of the relative error between the predicted value and the actual value in percentage form. The value range of MAPE is [0, +∞). The smaller the value, the higher the accuracy of the prediction model.
[0100] The calculation formula of MAPE is as follows:
[0101]
[0102] The third metric, RMSE (mean squared absolute error), is the square root of the average of the squares of the differences between the predicted values and the true values. RMSE is very sensitive to large errors because it calculates the squares of the differences. Therefore, if even just one or a few predicted values differ greatly from the actual values, the RMSE will increase significantly. This makes RMSE a good metric to penalize large prediction errors.
[0103] The calculation formula of RMSE is as follows:
[0104]
[0105] The fourth indicator R2 (coefficient of determination) indicates the proportion of the change in the variable predicted by the model to the change in the real variable. The value of R2 is between 0 and 1. The closer R2 is to 1, the better the model fits the data; 2 The closer it is to 0, the worse the predictive ability of the model.
[0106] The calculation formula of R2 is as follows:
[0107]
[0108] In this embodiment, the stock prediction model of the stock prediction method based on the time convolution network fusion channel attention mechanism provided by the present invention is evaluated and verified by taking the daily data of the Shanghai Stock Exchange 50 Index from January 1, 2012 to December 31, 2023 as an example for research, and the closing price increase and decrease trend of the next day is predicted by using the previous 20 days. The data feature attributes are closing price, opening price, highest price, lowest price, trading volume, transaction amount, turnover rate and increase and decrease amount. The data is normalized, the aforementioned TCN-SE model is established, and a comparative experiment is conducted with the LSTM and CNN models.
[0109] There are 2 daily data of Shanghai Stock Exchange 50 Index from January 1, 2010 to December 31, 2022, of which 80% is used as training data and 20% is used as test data. The model is experimented with the above parameter settings. The experimental results are shown in Table 1: After multiple averaging, the values of various evaluation indicators of the TCN-SE model are higher than those of the LSTM and CNN models. It can be seen that the prediction effect of the improved TCN model in this paper is better than that of other models.
[0110] Table 1 Comparison of evaluation indicators of different models
[0111]
[0112] After multiple parameter adjustments and optimizations, such as Figure 7 As shown, Figure 7 A schematic diagram of the prediction results of the SSE 50 Index stocks by a stock prediction method based on a temporal convolutional network fused channel attention mechanism provided by the present invention.
[0113] In this embodiment, after the stock prediction model is trained, the stock prediction model is stored in a model folder and saved as a pt file, so that the stock prediction model file saved in the folder can be directly loaded when used, thereby saving time for training the model.
Claims
1. A stock prediction method based on temporal convolutional network fusion channel attention mechanism, characterized in that: The method steps are as follows: S1: Determine the characteristics of the target stock to be predicted and obtain the stock historical characteristic data sequence; S2: Divide the stock historical feature data sequence obtained in step S1 into a training set and a test set, normalize the data in the training set and the test set, and generate a two-dimensional data sequence; S3: performing time step division processing on the two-dimensional data sequence generated in step S2, and generating corresponding feature labels to obtain three-dimensional data sequences of training set and test set; S4: Perform TCN residual block processing and channel attention weighting on the three-dimensional data sequence of the training set generated in step S3. The stock prediction model has three layers, the first layer is an expansion causal convolution layer, a relu layer, a dropout layer, a residual layer, and a channel attention. The second layer is an expansion causal convolution layer, a relu layer, a dropout layer, a residual layer, and a channel attention. The third layer is an expansion causal convolution layer, a relu layer, a dropout layer, a residual layer, and a channel attention. The optimization target of the stock prediction model is constructed and iterative alternating training is performed on it; S5: For the stock prediction model trained in step S4, the data of the test set is input into the model to evaluate and verify the stock prediction model and optimize its parameters.
2. The method according to claim 1, characterized in that The stock historical feature sequence in step S1 includes the opening price, closing price, highest price, lowest price, total trading volume, total transaction amount, turnover rate and rise and fall of each trading day.
3. The method according to claim 1, characterized in that The normalization process of the stock historical characteristic data sequence described in step S2 includes: The historical feature data is normalized by the following formula: Where x is the input value and y is the normalized value. max is the maximum value of the sample, x min is the minimum value of the sample.
4. The method according to claim 1, characterized in that: The two-dimensional data sequence generated in step S3 is divided into data steps with a historical window data step length of 20, and corresponding feature labels are generated to obtain three-dimensional data with 32 in each batch, and the data shape is (batch size, feature, time step).
5. The method according to claim 4, characterized in that The historical window data step size of 20 means using the stock trading records of the past 20 days, including the opening price, closing price, highest price, lowest price, total trading volume, total transaction amount, turnover rate and price increase or decrease of the trading day, to predict the stock closing price of the next day.
6. The method according to claim 1, characterized in that: The expansion factor of the TCN residual block described in step S4 is 1 in the first layer, the number of input channels is, the number of output channels is, the second layer is 2, the number of input channels is, the number of output channels is, the third layer is 4, the number of input channels is, the number of output channels is, and the expansion formula is: Stock price sequence X = {x t ,x t-1 ...x1,x0} and convolution kernel f:{0,1,...,k-1}→R, where k is the convolution kernel size, td·m is the historical data, and d is the expansion factor. The expansion factor is usually set to increase exponentially with the depth of the network, that is, d=2 n , n is the number of layers in the network.
7. The method according to claim 1, characterized in that: The channel attention described in step S4 includes: using a 1-dimensional adaptive average pooling operation, a first fully connected layer, a relu function, a second fully connected layer, a sigmoid function, and a compression ratio reduction of 16: The loss function used in the stock prediction model is mean square error MSE, the optimization algorithm is Adam, the model uses 200 epochs, the size of each batch is 32, and the dropout value is 0.
5.
8. The stock prediction method based on the temporal convolutional network fusion channel attention mechanism according to claim 5 is characterized in that : After training the stock prediction model, save the stock prediction model in the model folder and save it as a pt file so that the stock prediction model file saved in the folder can be directly loaded when used, thereby saving the time of training the model.
9. The method according to claim 1, characterized in that: The evaluation verification described in step S5 includes: The test data in the test set is input into the trained stock prediction model to obtain the prediction result. Based on the comparison between the predicted value and the true value, four evaluation indicators are used, namely MAE, MAPE, RMSE and R^2. The first three evaluation indicators represent the error between the predicted value and the true value. The smaller the value of the three indicators, the more accurate the prediction result. The last indicator represents the predictive ability of the model. The higher the score of the indicator, the better the predictive ability of the model.
10. The method according to claim 8, characterized in that The evaluation index of the stock prediction model is calculated by the following formula: in is the number of samples, y i is the true value, is the predicted value, is the average of the true values.
Citation Information
Cited By
New energy power price management method and system based on artificial intelligence
CN119941448A