Time sequence prediction method, electronic equipment and storage medium

By performing historical samples screening and splicing on time series data, the problem of low time series prediction accuracy in the prior art is solved, and higher prediction accuracy and accuracy are achieved.

CN119622481AInactive Publication Date: 2025-03-14INSPUR SUZHOU INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202510153472.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-12
Publication Date
2025-03-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, the accuracy of time series prediction is low, and it is difficult to ensure the accuracy of the prediction results, mainly because the fixed historical observation window length cannot take into account global trends and detailed information, and the optimal window length cannot be determined.

Method used

By obtaining the historical time series of time series to be predicted, it is divided into a historical sample set and a current prediction set according to the order in which the data occurs, the samples with the similarity between the target historical sample and the current data to be predicted meet the preset conditions, and splicing them to generate the target data to be predicted, and finally predict based on the target data to be predicted.

Benefits of technology

This method effectively utilizes historical information by screening similar historical samples and splicing them, thereby enhancing the prediction characteristics of the target data to be predicted, thereby improving the prediction accuracy of the time series and the accuracy of the prediction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119622481A_ABST
    Figure CN119622481A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and discloses a time sequence prediction method, electronic equipment and a storage medium, and the method comprises the steps: obtaining a historical time sequence data set of a to-be-predicted time sequence; dividing the historical time sequence data set into a historical sample set and a current prediction set according to a data generation sequence; wherein the data generation time of the historical sample set is earlier than the data generation time of the current prediction set; determining current to-be-predicted data according to the current prediction set; screening a target historical sample in the historical sample set according to the current to-be-predicted data; splicing the current to-be-predicted data and the target historical sample to obtain target to-be-predicted data; and determining a prediction result of the to-be-predicted time sequence according to the target to-be-predicted data. According to the method, similar historical samples are screened for splicing prediction, historical information is effectively utilized, the prediction features of the target to-be-predicted data are enhanced, the prediction precision of the time sequence is improved, and then the accuracy of a prediction result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a time series prediction method, electronic device and storage medium. Background Art

[0002] At present, time series forecasting is crucial in the fields of economy, energy, meteorology, etc. Various industries use it for demand planning, such as power companies use it to optimize power generation scheduling, meteorological departments use it to conduct weather forecasts, etc., providing key support for decision-making.

[0003] In related technologies, time series prediction is usually implemented using a neural network model, which generates prediction results based on a fixed historical observation window length. For example, when the fixed historical observation window length is two days, tomorrow's data is predicted each time based on the data from the previous two days.

[0004] However, if the fixed historical observation window length is too small, the global trend cannot be grasped; if the fixed historical observation window length is too large, details will be missed, resulting in information loss. At present, it is still impossible to determine the optimal value of the fixed historical observation window length, resulting in low prediction accuracy of related technologies for time series, and it is difficult to guarantee the accuracy of the prediction results. Summary of the invention

[0005] The present application provides a time series prediction method, an electronic device and a storage medium to solve the defects of the related technology such as low prediction accuracy of time series and difficulty in ensuring the accuracy of prediction results.

[0006] The first aspect of the present application provides a time series prediction method, comprising: Obtain the historical time series data set of the time series to be predicted; According to the order of data occurrence, the historical time series data set is divided into a historical sample set and a current prediction set; wherein the data occurrence time of the historical sample set is earlier than the data occurrence time of the current prediction set; Determining current data to be predicted based on the current prediction set; According to the current data to be predicted, a target historical sample is screened in the historical sample set; wherein the similarity between the target historical sample and the current data to be predicted satisfies a preset screening condition; splicing the current data to be predicted and the target historical samples to obtain target data to be predicted; The prediction result of the time series to be predicted is determined according to the target data to be predicted.

[0007] In an optional implementation, dividing the historical time series data set into a historical sample set and a current prediction set according to the order in which the data occurred includes: According to a preset prediction window length, the historical time series data set is divided into a plurality of historical time series data segments; According to the data occurrence sequence represented by the data occurrence time of each of the historical time series data segments, the multiple historical time series data segments are divided into a historical sample set and a current prediction set.

[0008] In an optional implementation, determining the current data to be predicted according to the current prediction set includes: Determining current prediction requirements according to the data type information of the time series to be predicted; According to the current forecast demand, basic forecast data that meets the current forecast demand is selected from the current forecast set; According to the basic prediction data, current data to be predicted is determined.

[0009] In an optional implementation, the step of screening target historical samples from the historical sample set according to the current data to be predicted includes: Performing vectorized coding on each historical sample in the historical sample set to obtain a sample vector coding corresponding to each historical sample; Performing vector coding on the current data to be predicted to obtain a current prediction vector code corresponding to the current data to be predicted; Determining the similarity between the current data to be predicted and each of the historical samples according to the similarity between the current prediction vector code and the sample vector code corresponding to each of the historical samples; According to the similarity between the current data to be predicted and each of the historical samples, a target historical sample is screened in the historical sample set.

[0010] In an optional implementation, performing vectorized encoding on each historical sample in the historical sample set to obtain a sample vector encoding corresponding to each historical sample includes: For any of the historical samples, analyzing the historical data content of the historical sample and the data occurrence time of the historical data content; According to the historical data content of the historical samples and the data occurrence time of the historical data content, the historical samples are vector-encoded to obtain the sample vector codes corresponding to each of the historical samples.

[0011] In an optional implementation, the vectorized encoding of the current data to be predicted to obtain a current prediction vector encoding corresponding to the current data to be predicted includes: Analyze the data content to be predicted of the current data to be predicted and the data occurrence time of the data content to be predicted; According to the content of the current data to be predicted and the data occurrence time of the content of the data to be predicted, the current data to be predicted is vectorized and encoded to obtain a current prediction vector code corresponding to the current data to be predicted.

[0012] In an optional implementation manner, the step of concatenating the current data to be predicted and the target historical samples to obtain the target data to be predicted includes: When the target historical sample is not unique, performing feature fusion on all the target historical samples to obtain a target fused sample; The current data to be predicted and the target fusion sample are concatenated to obtain the target data to be predicted.

[0013] In an optional implementation, determining the prediction result of the time series to be predicted according to the target data to be predicted includes: Obtaining a target prediction model; Inputting the target data to be predicted into the target prediction model, so as to perform block processing on the target data to be predicted based on the target prediction model, so as to divide the target data to be predicted into a plurality of target prediction blocks; Converting the target prediction block into a target temporal word-gram; The prediction result of the time series to be predicted is determined according to the target time series word-grams corresponding to each of the target prediction blocks.

[0014] In an optional implementation, the acquiring the target prediction model includes: Obtain the prediction model to be trained and the time-series word sample set; Each time-series word-unit sample in the time-series word-unit sample set is used as input data and input into the prediction model to be trained, and the prediction model to be trained performs forward propagation according to the time-series word-unit sample to obtain a prediction distribution; Based on a preset loss function and according to the prediction distribution, determining a current prediction loss value of the prediction model to be trained; According to the current prediction loss value of the prediction model to be trained, the model parameters of the prediction model to be trained are iteratively optimized to obtain a target prediction model.

[0015] In an optional implementation, the determining the current prediction loss value of the prediction model to be trained based on the preset loss function and according to the prediction distribution includes: Based on the following preset loss function, the current prediction loss value of the prediction model to be trained is determined according to the prediction distribution:

[0016] in, represents the current prediction loss value of the prediction model to be trained, represents the current model parameters of the prediction model to be trained, Indicates the preset prediction window length, represents the target vocabulary size of the prediction model to be trained, represents the indicator function, when hour, ,when hour, , Indicates the Cth time sequence word sample The true value of the position, represents the predicted distribution, which represents the sequence information determined according to the Cth time sequence word sample under the current model parameters of the training model to be predicted , determine the next position in the Cth time-sequential word sample Value for probability.

[0017] In an optional embodiment, the method further includes: Classifying the time-series word unit sample set to divide the continuous data in the time-series word unit sample set into a plurality of discrete intervals; Adding the index number of each discrete interval of the category to the initialization vocabulary of the prediction model to be trained to obtain the target vocabulary of the prediction model to be trained; The number of index numbers included in the target vocabulary is taken as the target vocabulary size.

[0018] In an optional implementation, determining the prediction result of the time series to be predicted according to the target time series word corresponding to each target prediction block includes: Performing feature extraction and semantic understanding on the target time-series word-units corresponding to each of the target prediction blocks to obtain target prediction features and target prediction semantic information; Determining basic inputs of the target prediction model according to the target prediction features and the target prediction semantic information; The target prediction model performs inference calculation on the basic input to obtain a prediction result of the time series to be predicted.

[0019] A second aspect of the present application provides a time series prediction device, comprising: The acquisition module is used to obtain the historical time series data set of the time series to be predicted; A division module, used to divide the historical time series data set into a historical sample set and a current prediction set according to the order in which the data occurred; wherein the data occurrence time of the historical sample set is earlier than the data occurrence time of the current prediction set; A determination module, used to determine the current data to be predicted according to the current prediction set; A screening module, used to screen a target historical sample in the historical sample set according to the current data to be predicted; wherein the similarity between the target historical sample and the current data to be predicted satisfies a preset screening condition; A splicing module, used for splicing the current data to be predicted and the target historical samples to obtain target data to be predicted; The prediction module is used to determine the prediction result of the time series to be predicted according to the target data to be predicted.

[0020] A third aspect of the present application provides an electronic device, comprising: at least one processor and a memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method described in the first aspect and various possible designs of the first aspect.

[0021] A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the method described in the first aspect and various possible designs of the first aspect are implemented.

[0022] A fifth aspect of the present application provides a computer program product, including computer instructions, which are used to enable a computer to execute the method described in the first aspect and various possible designs of the first aspect.

[0023] The technical solution of this application has the following advantages: The present application provides a time series prediction method, electronic device and storage medium, the method comprising: obtaining a historical time series data set of a time series to be predicted; dividing the historical time series data set into a historical sample set and a current prediction set according to the order of data occurrence; wherein the data occurrence time of the historical sample set is earlier than the data occurrence time of the current prediction set; determining the current data to be predicted according to the current prediction set; screening target historical samples in the historical sample set according to the current data to be predicted; wherein the similarity between the target historical samples and the current data to be predicted meets the preset screening conditions; splicing the current data to be predicted and the target historical samples to obtain the target data to be predicted; determining the prediction result of the time series to be predicted according to the target data to be predicted. The method provided by the above scheme effectively utilizes historical information by screening similar historical samples for splicing prediction, enhances the prediction characteristics of the target data to be predicted, thereby improving the prediction accuracy of the time series, and further improving the accuracy of the prediction results. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technical descriptions. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.

[0025] Figure 1 This is a schematic diagram of the structure of the time series prediction system based on the embodiment of the present application; Figure 2 A schematic diagram of a time series prediction method provided in an embodiment of the present application; Figure 3 A schematic diagram of a flow chart of an exemplary time series prediction method provided in an embodiment of the present application; Figure 4 A schematic diagram of the structure of a time series prediction device provided in an embodiment of the present application; Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0026] The above drawings have shown clear embodiments of the present application, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0028] In addition, the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the description of the following embodiments, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.

[0029] Time series modeling and analysis are crucial in many practical applications, such as demand planning, anomaly detection, power load forecasting, and weather forecasting. However, the characteristics of time series data, such as high dimensionality, nonlinearity, sparsity, and distribution drift, significantly increase the difficulty of prediction. To address the challenges in these time series prediction tasks, rich professional domain knowledge and specially designed neural network architectures are generally required. In recent years, basic pre-trained large language models (LLMs) have strong generalization and logical reasoning capabilities, and have impressive results on many downstream natural language processing tasks, which provides new ideas for building time-series foundation models (TSFMs). These basic models can quickly adapt to new tasks and perform well with the help of few sample instances or domain fine-tuning.

[0030] In the related technologies, the application of basic TSFM in the field of time series modeling (such as classification, anomaly detection, prediction and missing value filling) is still in the stage of being explored and has great potential. This method is different from the existing time series models designed separately according to the task, and can handle various time series modeling tasks at the same time. However, it is challenging to apply TSFM, which originally handles general time series modeling tasks, to time series prediction tasks in specific fields. This is due to the lack of corresponding field background knowledge. TSFM may lack the ability to identify and explore the seasonality, periodicity or burstiness contained in time series data. The existing large models designed and trained based on time series data mainly generate prediction results based on a fixed historical observation window length. This modeling scheme may cause information loss of complex time series patterns, thereby affecting the accuracy of modeling. This is because in this scheme, a smaller window length can capture local patterns, but lacks the perception of global trends, while a larger window length can capture more contextual information, but may ignore detailed information. At present, it is still impossible to determine the optimal value of the fixed historical observation window length, resulting in low prediction accuracy of related technologies for time series, and it is difficult to ensure the accuracy of prediction results.

[0031] In response to the above problems, the embodiments of the present application provide a time series prediction method, electronic device and storage medium, the method comprising: obtaining a historical time series data set of a time series to be predicted; dividing the historical time series data set into a historical sample set and a current prediction set according to the order of data occurrence; wherein the data occurrence time of the historical sample set is earlier than the data occurrence time of the current prediction set; determining the current data to be predicted according to the current prediction set; screening target historical samples in the historical sample set according to the current data to be predicted; wherein the similarity between the target historical samples and the current data to be predicted meets the preset screening conditions; splicing the current data to be predicted and the target historical samples to obtain the target data to be predicted; determining the prediction result of the time series to be predicted according to the target data to be predicted. The method provided by the above scheme effectively utilizes historical information by screening similar historical samples for splicing prediction, enhances the prediction characteristics of the target data to be predicted, thereby improving the prediction accuracy of the time series, and further improving the accuracy of the prediction results.

[0032] The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.

[0033] First, the structure of the time series prediction system on which this application is based is described: The time series prediction method, electronic device and storage medium provided in the embodiments of the present application are suitable for predicting the future value of time series data. Figure 1The figure is a schematic diagram of the structure of the time series prediction system based on the embodiment of the present application, which mainly includes a prediction object, a data acquisition device and a time series prediction device. The prediction object can be a device such as an electric energy meter or a server, and the data acquisition device can be a sensor, etc. The data acquisition device collects the time series data of the prediction object and sends the collected data as a historical time series data set to the time series prediction device. The time series prediction device predicts the future series data of the prediction object based on the obtained data to obtain the prediction result of the time series to be predicted.

[0034] The embodiment of the present application provides a time series prediction method for predicting the future value of time series data. The execution subject of the embodiment of the present application is an electronic device, such as a server, a desktop computer, a laptop computer, a tablet computer, and other electronic devices that can be used for time series prediction.

[0035] like Figure 2 FIG. 1 is a flow chart of a time series prediction method provided by an embodiment of the present application, and the method includes: Step 201, obtaining a historical time series data set of a time series to be predicted.

[0036] It should be noted that the historical time series data set contains time series data arranged in chronological order over a period of time in the past. Time series data can come from a variety of data sources, such as data recorded by sensors and meteorological data.

[0037] Step 202, divide the historical time series data set into a historical sample set and a current prediction set according to the order in which the data occurred.

[0038] Among them, the data occurrence time of the historical sample set is earlier than the data occurrence time of the current prediction set, and the historical sample set can be stored in a preset time series database.

[0039] Specifically, the acquired historical time series data set can be divided according to the order in which the data occurred. The historical sample set contains data that occurred earlier and can be regarded as existing historical information; the current prediction set contains relatively new data, which is the basic data for the current prediction. This division helps to clearly distinguish between historical information and key information required for current prediction.

[0040] For example, taking the historical time series data set including the monitoring data of the past 7 days as an example, the data of days 1 to 5 can be used as the historical sample set, and the data of the most recent two days (days 6 and 7) can be used as the current prediction set.

[0041] Specifically, when dividing the historical sample set and the current prediction set, they can also be divided in proportion. For example, the historical time series data set can be divided into the historical sample set and the current prediction set in a ratio of 8:2, and the divided historical sample set is standardized so that the mean of the historical sample set is 0 and the variance is 1, which is convenient for subsequent processing.

[0042] Step 203: determine the current data to be predicted based on the current prediction set.

[0043] Specifically, according to specific prediction tasks and business requirements, the data portion that needs to be predicted can be extracted from the current prediction set, and this portion of data can be used as the current data to be predicted.

[0044] Step 204: Filter target historical samples from the historical sample set according to the current data to be predicted.

[0045] Among them, the similarity between the target historical sample and the current data to be predicted meets the preset screening conditions.

[0046] Specifically, the similarity between the current predicted data and each historical sample in the historical sample set can be calculated by similarity calculation methods such as Euclidean distance, and then based on the similarity calculation result, at least one target historical sample whose similarity with the current data to be predicted meets the preset screening conditions is screened in the historical sample set.

[0047] Step 205, concatenate the current data to be predicted and the target historical samples to obtain the target data to be predicted.

[0048] Specifically, by splicing the current data to be predicted and the target historical samples, the current data and historical data with high correlation are integrated, so that the target prediction data obtained has strong prediction features, laying the foundation for improving the prediction accuracy of time series and the accuracy of prediction results.

[0049] Specifically, in one embodiment, when the target historical samples are not unique, feature fusion can be performed on all target historical samples to obtain target fused samples; and current data to be predicted and the target fused samples can be concatenated to obtain target data to be predicted.

[0050] Specifically, feature fusion includes mean calculation. When the target historical samples are not unique, the mean calculation can be performed on all target historical samples, and the mean calculation result is used as the target fusion sample. Then, the target data to be predicted is obtained by splicing the current data to be predicted and the target fusion sample.

[0051] Step 206: Determine the prediction result of the time series to be predicted according to the target data to be predicted.

[0052] Specifically, the spliced ​​target data to be predicted is input into the prediction model or algorithm to obtain the final prediction result of the time series to be predicted based on the prediction model or algorithm reasoning. The prediction model or algorithm can analyze the change pattern and trend of the time series to be predicted based on the comprehensive information represented by the target data to be predicted, so as to make a prediction of the future value of the time series to be predicted.

[0053] The time series to be predicted may be the voltage value of the server processor at each hour in the past day, and the voltage prediction value of at least one hour in the future of the time series to be predicted.

[0054] Based on the above embodiment, as an implementable manner, in one embodiment, the historical time series data set is divided into a historical sample set and a current prediction set according to the order in which the data occurs, including: Step 2021, dividing the historical time series data set into a plurality of historical time series data segments according to a preset prediction window length; Step 2022, according to the data occurrence sequence represented by the data occurrence time of each historical time series data segment, divide the multiple historical time series data segments into a historical sample set and a current prediction set.

[0055] Among them, the preset prediction window length represents how often a prediction is made, that is, it represents the time span of the current data to be predicted. When the data collection frequency is fixed, the preset prediction window length can also be expressed by the data length, such as the preset prediction window length is 512 bits.

[0056] Specifically, by dividing the historical time series data set according to the preset prediction window length, multiple historical time series data segments are obtained, which can make the data organization more structured and orderly, and facilitate subsequent processing. Furthermore, these historical time series data segments are divided into historical sample sets and current prediction sets according to the order of occurrence, which helps to clearly distinguish historical information from the information currently available for prediction, and provide a clear data basis for subsequent prediction operations.

[0057] Among them, the historical sample set can be used as a reserve of historical experience to provide rich reference information for prediction. The current prediction set focuses on newer data, so that the prediction process can combine the latest data trends and patterns. This division method enables the prediction to make full use of the data characteristics of different time periods, improve the pertinence of the prediction, and thus improve the accuracy and reliability of the prediction.

[0058] Based on the above embodiment, as an implementable manner, in one embodiment, according to the current prediction set, determining the current data to be predicted includes: Step 2031, determining the current prediction requirement according to the data type information of the time series to be predicted; Step 2032, based on the current forecast demand, filter the basic forecast data that meets the current forecast demand in the current forecast set; Step 2033, determining the current data to be predicted based on the basic prediction data.

[0059] Among them, the data type information includes the source, nature and application scenarios of the data. Based on this information, the prediction target and direction can be clarified, such as predicting short-term fluctuations, long-term trends or changes under the influence of specific events. For example, in the power load time series prediction scenario, if the data type is the power load data during the peak power consumption period in a certain area in summer. Due to the high temperature in summer and the large-scale use of refrigeration equipment such as air conditioners, the power load fluctuates greatly and is significantly affected by weather factors. At this time, based on this data type information, it is determined that the current prediction demand can be to predict the power load changes every hour in the next 24 hours.

[0060] Specifically, based on the determined current forecasting needs, matching data can be found in the current forecasting set and used as basic forecasting data. These data should be able to directly or indirectly reflect information related to the forecasting target, thereby providing a basis for the subsequent determination of the data to be forecasted.

[0061] Among them, in response to the above power load forecasting needs, data is filtered in the current forecast set. Assume that the current forecast set contains power load data recorded every 15 minutes in the past week. In order to predict the power load of each hour in the next 24 hours, the power load data at every hour in the past 24 hours is filtered out. Environmental data such as weather temperature and humidity in the same period that may affect the power load can also be filtered out. These data together constitute the basic forecast data.

[0062] Specifically, the screened basic forecast data can be sorted, processed or further processed, and the corresponding forecast indicators can be calculated. For example, the total power load within 24 hours can be determined based on the power load data at every hour of the past 24 hours provided by the basic forecast data. Finally, the total power load is used as the current data to be predicted as input into the forecast model to predict the total power load within the next 24 hours.

[0063] Based on the above embodiment, as an implementable manner, in one embodiment, according to the current data to be predicted, the target historical sample is screened in the historical sample set, including: Step 2041, performing vector coding on each historical sample in the historical sample set to obtain a sample vector code corresponding to each historical sample; Step 2042, performing vector coding on the current data to be predicted to obtain a current prediction vector code corresponding to the current data to be predicted; Step 2043, determining the similarity between the current data to be predicted and each historical sample according to the similarity between the current prediction vector code and the sample vector code corresponding to each historical sample; Step 2044, based on the similarity between the current data to be predicted and each historical sample, select the target historical sample from the historical sample set.

[0064] Specifically, the model can be vectorized based on time series data , for the historical sample set pre-stored in the database Each historical sample and the current data to be predicted Perform vectorized encoding to obtain the sample vector encoding corresponding to each historical sample and the current prediction vector encoding , , and then calculate the current prediction vector encoding Sample vector encoding corresponding to each historical sample The similarity between them is calculated and the target historical samples are filtered. The specific filtering implementation formula is as follows:

[0065] in, Represents the index value of the target historical sample, Represents a historical sample set Middle A historical sample, Indicates the current prediction vector encoding With historical sample sets Middle The sample vector encoding corresponding to the historical samples The distance between them is inversely proportional to the similarity, that is, the smaller the distance, the higher the similarity, and the larger the distance, the lower the similarity.

[0066] Specifically, the index value of the target historical sample can be , in the historical sample set Extract the corresponding target history samples , specifically, the current prediction vector encoding At least one historical sample with the highest similarity (smallest distance) is used as the target historical sample.

[0067] Specifically, in one embodiment, for any historical sample, the historical data content of the historical sample and the data occurrence time of the historical data content can be analyzed; based on the historical data content of the historical sample and the data occurrence time of the historical data content, the historical sample is vector encoded to obtain the sample vector encoding corresponding to each historical sample.

[0068] Accordingly, in one embodiment, the data content to be predicted and the data occurrence time of the data content to be predicted of the current data to be predicted can be analyzed; according to the data content to be predicted and the data occurrence time of the data content to be predicted of the current data to be predicted, the current data to be predicted is vectorized encoded to obtain the current prediction vector encoding corresponding to the current data to be predicted.

[0069] It should be noted that by adding the time when the data occurred to the vectorized encoding, the historical samples and the current data to be predicted can be more completely represented. In the encoding process, in addition to considering the content of the data itself, the time information becomes part of the data characteristics, making the data representation richer and more accurate, and helping the subsequent prediction model or algorithm to more comprehensively understand the spatiotemporal characteristics of the data.

[0070] In the process of screening target historical samples, since the code includes the time when the data occurred, the data occurring at the same or similar time point can be accurately found as the target historical samples. For example, when looking for historical samples similar to the current data to be predicted, data occurring at the same time can be given priority, such as data at 4 pm every day, because these data have higher relevance and comparability in the time dimension.

[0071] Based on the above embodiments, Figure 3 As shown, it is a flow chart of an exemplary time series prediction method provided in an embodiment of the present application. As an implementable method, in one embodiment, according to the target data to be predicted, the prediction result of the time series to be predicted is determined, including: Step 2061, obtaining a target prediction model; Step 2062, inputting the target data to be predicted into the target prediction model, so as to perform block processing on the target data to be predicted based on the target prediction model, so as to divide the target data to be predicted into a plurality of target prediction blocks; Step 2063, converting the target prediction block into a target temporal word; Step 2064: Determine the prediction result of the time series to be predicted according to the target time series word-grams corresponding to each target prediction block.

[0072] Among them, the target data to be predicted obtained by the time series data enhancement solution based on similar pattern retrieval provided in the embodiment of the present application enables the target prediction model to have context learning capabilities, thereby improving the model's ability to predict complex time series data.

[0073] Specifically, the prediction result of the time series to be predicted output by the target prediction model can be expressed based on the following formula:

[0074] in, Represents the prediction result of the time series to be predicted, Represents the target prediction model The input, that is represents the target data to be predicted, The target historical samples retrieved are Serving as the reference background for model prediction, the target prediction model divides the input time series (target data to be predicted) into blocks first, and preprocesses it into the form of time series tokens for reasoning, and predicts the value at the next moment, that is, obtains the prediction result of the time series to be predicted.

[0075] Specifically, in one embodiment, in order to obtain a target prediction model, a prediction model to be trained and a time-series word-unit sample set can be obtained; each time-series word-unit sample in the time-series word-unit sample set is used as input data and input into the prediction model to be trained, and the prediction model to be trained performs forward propagation according to the time-series word-unit samples to obtain a prediction distribution; based on a preset loss function, the current prediction loss value of the prediction model to be trained is determined according to the prediction distribution; according to the current prediction loss value of the prediction model to be trained, the model parameters of the prediction model to be trained are iteratively optimized to obtain a target prediction model.

[0076] It should be noted that the prediction model to be trained can use the common open source GPT-2 model in actual applications. GPT-2 is a large language model based on the Transformer architecture, which has demonstrated excellent performance in the field of natural language processing.

[0077] Specifically, each time-series word-unit sample in the time-series word-unit sample set is used as input data and input into the prediction model to be trained. The prediction model to be trained processes the input time-series word-unit sample and performs forward propagation calculation through its Transformer architecture. In this process, the input time-series word-unit will pass through multiple layers of multi-head attention mechanism and feedforward neural network, which will capture the complex relationships and patterns between word-units. Finally, a predicted distribution is obtained at the output layer.

[0078] Specifically, in one embodiment, the current prediction loss value of the prediction model to be trained may be determined according to the prediction distribution based on the following preset loss function:

[0079] in, Represents the current prediction loss value of the prediction model to be trained, Represents the current model parameters of the prediction model to be trained, Indicates the preset prediction window length, represents the target vocabulary size of the prediction model to be trained, represents the indicator function, when hour, ,when hour, , Indicates the Cth time sequence word sample The true value of the position, Represents the prediction distribution, which represents the sequence information determined by the Cth time-series word sample under the current model parameters of the training model to be predicted , determine the next position in the Cth time-sequential word sample Value for probability.

[0080] Specifically, in one embodiment, the time-series word unit sample set can be classified to divide the continuous data in the time-series word unit sample set into multiple category discrete intervals; the index number of each category discrete interval is added to the initialization vocabulary of the prediction model to be trained to obtain the target vocabulary of the prediction model to be trained; and the number of index numbers contained in the target vocabulary is used as the target vocabulary size.

[0081] Among them, one category discrete interval corresponds to one bucket.

[0082] It should be noted that in the time series prediction model, the target vocabulary is a collection of stored words, which are usually representations of the original time series data (such as continuous data divided into discrete intervals after classification processing), providing the model with basic elements for processing data and helping the model understand and process input data. The target vocabulary size refers to the number of words contained in the target vocabulary, reflecting the scope and ability of the model to process data.

[0083] Among them, the purpose of classification processing is to discretize the continuous data in the time series word sample set. In a time series, the original data may be a continuous value, such as a series of continuous temperature values ​​or power load data. In order to make these data easier to process and model learning, the embodiment of the present application divides them into multiple discrete intervals of categories. This can be achieved through different methods, such as equal-width bucketing (dividing the data range into multiple discrete intervals of equal width) or equal-frequency bucketing (ensuring that the amount of data in each discrete interval of a category is roughly equal).

[0084] Specifically, in one embodiment, feature extraction and semantic understanding can be performed on the target time series word units corresponding to each target prediction block to obtain target prediction features and target prediction semantic information; based on the target prediction features and target prediction semantic information, the basic input of the target prediction model is determined; the target prediction model performs inference calculation on the basic input to obtain the prediction result of the time series to be predicted.

[0085] Specifically, the target time-series word-meta can be first mapped to a word-meta vector, and then a deep learning architecture (such as the Transformer architecture) can be used to extract features from the mapped word-meta vector. Through structures such as multi-head attention mechanisms and feedforward neural networks, the relationship and potential features between each word-meta in the word-meta vector can be mined. In this process, for different word-meta vectors, information interaction can be performed based on their position and semantic relationship in the target vocabulary. Among them, in the multi-head attention mechanism, different heads will pay attention to different word-meta relationships, and the word-meta relationship depends on the semantic association of the word-meta in the target vocabulary, thereby extracting the target prediction features and target prediction semantic information in the target vocabulary.

[0086] Furthermore, the extracted target prediction features and target prediction semantic information are integrated to obtain the basic input of the target prediction model. The output layer of the target prediction model outputs the probability distribution according to the size of the target vocabulary. Finally, the maximum probability method (selecting the word with the highest probability) is used to determine the final prediction result according to the probability distribution.

[0087] Specifically, in one embodiment, in order to further ensure the accuracy of the prediction results, during the application of the target prediction model, the model parameters of the target prediction model may be dynamically optimized.

[0088] Specifically, when new time series data is collected, it is first integrated with the previously obtained historical data to form an extended data set. By analyzing the extended data set, the error between the current prediction value of the model (the prediction result obtained by the previous prediction) and the true value is calculated. The error can be measured by indicators such as mean square error or mean absolute error. Furthermore, based on error feedback, the preset dynamic optimization algorithm is used to iteratively update the model parameters to further optimize the target prediction model, thereby improving the accuracy of the prediction results.

[0089] The time series prediction method provided by the embodiment of the present application obtains the historical time series data set of the time series to be predicted; divides the historical time series data set into a historical sample set and a current prediction set according to the order of data occurrence; wherein the data occurrence time of the historical sample set is earlier than the data occurrence time of the current prediction set; determines the current data to be predicted according to the current prediction set; selects the target historical sample in the historical sample set according to the current data to be predicted; wherein the similarity between the target historical sample and the current data to be predicted meets the preset screening condition; splices the current data to be predicted and the target historical sample to obtain the target data to be predicted; determines the prediction result of the time series to be predicted according to the target data to be predicted. The method provided by the above scheme effectively utilizes historical information by screening similar historical samples for splicing prediction, thereby improving the prediction accuracy of the time series and further improving the accuracy of the prediction result. Moreover, the above scheme is actually a time series prediction technology scheme based on retrieval enhancement, which is used for high-precision time series data prediction tasks. The scheme solves the distribution drift and non-stationarity problems in time series data prediction by retrieving relevant historical time series samples and incorporating them into the prediction process. Compared with related technologies, it effectively improves the accuracy of data prediction and has the ability to process complex and changeable time series data. This method has important scientific significance and potential application value in research on power load prediction, traffic flow prediction, weather forecast and other related fields.

[0090] An embodiment of the present application provides a time series prediction device, which is used to execute the time series prediction method provided by the above embodiment.

[0091] like Figure 4 , which is a schematic diagram of the structure of a time series prediction device provided by an embodiment of the present application. The time series prediction device 40 comprises: an acquisition module 401, a division module 402, a determination module 403, a screening module 404, a splicing module 405 and a prediction module 406.

[0092] Among them, the acquisition module is used to obtain the historical time series data set of the time series to be predicted; the division module is used to divide the historical time series data set into a historical sample set and a current prediction set according to the order of data occurrence; wherein the data occurrence time of the historical sample set is earlier than the data occurrence time of the current prediction set; the determination module is used to determine the current data to be predicted based on the current prediction set; the screening module is used to screen the target historical samples in the historical sample set based on the current data to be predicted; wherein the similarity between the target historical samples and the current data to be predicted meets the preset screening conditions; the splicing module is used to splice the current data to be predicted and the target historical samples to obtain the target data to be predicted; the prediction module is used to determine the prediction result of the time series to be predicted based on the target data to be predicted.

[0093] Regarding the time series prediction device in this embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0094] The time series prediction device provided in the embodiment of the present application is used to execute the time series prediction method provided in the above embodiment. Its implementation method and principle are the same and will not be repeated here.

[0095] An embodiment of the present application provides an electronic device for executing the time series prediction method provided in the above embodiment.

[0096] like Figure 5 FIG. 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 50 includes: at least one processor 51 and a memory 52.

[0097] The memory stores computer-executable instructions; at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the time series prediction method provided in the above embodiment.

[0098] The electronic device provided in the embodiment of the present application is used to execute the time series prediction method provided in the above embodiment. Its implementation method and principle are the same and will not be repeated here.

[0099] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the time series prediction method provided in any of the above embodiments is implemented.

[0100] The storage medium containing computer executable instructions provided in the embodiments of the present application can be used to store computer executable instructions of the time series prediction method provided in the aforementioned embodiments. The implementation method and principle are the same and will not be repeated here.

[0101] An embodiment of the present application provides a computer program product, including computer instructions, which are used to enable a computer to execute the time series prediction method provided in the aforementioned embodiment.

[0102] The embodiments of the present application provide a computer program product that can be used to execute computer instructions of the time series prediction method provided in the aforementioned embodiments. The implementation method and principle are the same and will not be repeated here.

[0103] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0104] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0105] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0106] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.

[0107] A part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.

[0108] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A time series prediction method, characterized in that: include: Obtain the historical time series data set of the time series to be predicted; According to the order of data occurrence, the historical time series data set is divided into a historical sample set and a current prediction set; wherein the data occurrence time of the historical sample set is earlier than the data occurrence time of the current prediction set; Determining current data to be predicted based on the current prediction set; According to the current data to be predicted, a target historical sample is screened in the historical sample set; wherein the similarity between the target historical sample and the current data to be predicted satisfies a preset screening condition; splicing the current data to be predicted and the target historical samples to obtain target data to be predicted; The prediction result of the time series to be predicted is determined according to the target data to be predicted.

2. The method according to claim 1, characterized in that The historical time series data set is divided into a historical sample set and a current prediction set according to the order in which the data occurred, including: According to a preset prediction window length, the historical time series data set is divided into a plurality of historical time series data segments; According to the data occurrence sequence represented by the data occurrence time of each of the historical time series data segments, the multiple historical time series data segments are divided into a historical sample set and a current prediction set.

3. The method according to claim 1, characterized in that The determining, according to the current prediction set, current data to be predicted includes: Determining current prediction requirements according to the data type information of the time series to be predicted; According to the current forecast demand, basic forecast data that meets the current forecast demand is selected from the current forecast set; According to the basic prediction data, current data to be predicted is determined.

4. The method according to claim 1, characterized in that The step of screening target historical samples from the historical sample set according to the current data to be predicted includes: Performing vectorized coding on each historical sample in the historical sample set to obtain a sample vector coding corresponding to each historical sample; Performing vector coding on the current data to be predicted to obtain a current prediction vector code corresponding to the current data to be predicted; Determining the similarity between the current data to be predicted and each of the historical samples according to the similarity between the current prediction vector code and the sample vector code corresponding to each of the historical samples; According to the similarity between the current data to be predicted and each of the historical samples, a target historical sample is screened in the historical sample set.

5. The method according to claim 4, characterized in that The vectorized encoding of each historical sample in the historical sample set to obtain a sample vector encoding corresponding to each historical sample includes: For any of the historical samples, analyzing the historical data content of the historical sample and the data occurrence time of the historical data content; According to the historical data content of the historical samples and the data occurrence time of the historical data content, the historical samples are vector-encoded to obtain the sample vector codes corresponding to each of the historical samples.

6. The method according to claim 4, characterized in that The vectorized encoding of the current data to be predicted to obtain a current prediction vector encoding corresponding to the current data to be predicted includes: Analyze the data content to be predicted of the current data to be predicted and the data occurrence time of the data content to be predicted; According to the content of the current data to be predicted and the data occurrence time of the content of the data to be predicted, the current data to be predicted is vectorized and encoded to obtain a current prediction vector code corresponding to the current data to be predicted.

7. The method according to claim 1, characterized in that The step of combining the current data to be predicted and the target historical samples to obtain the target data to be predicted includes: When the target historical sample is not unique, performing feature fusion on all the target historical samples to obtain a target fused sample; The current data to be predicted and the target fusion sample are concatenated to obtain the target data to be predicted.

8. The method according to claim 1, characterized in that The step of determining the prediction result of the time series to be predicted according to the target data to be predicted includes: Obtaining a target prediction model; Inputting the target data to be predicted into the target prediction model, so as to perform block processing on the target data to be predicted based on the target prediction model, so as to divide the target data to be predicted into a plurality of target prediction blocks; Converting the target prediction block into a target temporal word-gram; The prediction result of the time series to be predicted is determined according to the target time series word-grams corresponding to each of the target prediction blocks.

9. The method according to claim 8, characterized in that The obtaining of the target prediction model comprises: Obtain the prediction model to be trained and the time-series word sample set; Each time-series word-unit sample in the time-series word-unit sample set is used as input data and input into the prediction model to be trained, and the prediction model to be trained performs forward propagation according to the time-series word-unit sample to obtain a prediction distribution; Based on a preset loss function and according to the prediction distribution, determining a current prediction loss value of the prediction model to be trained; According to the current prediction loss value of the prediction model to be trained, the model parameters of the prediction model to be trained are iteratively optimized to obtain a target prediction model.

10. The method according to claim 9, characterized in that The determining, based on the preset loss function and according to the prediction distribution, the current prediction loss value of the prediction model to be trained comprises: Based on the following preset loss function, the current prediction loss value of the prediction model to be trained is determined according to the prediction distribution: in, represents the current prediction loss value of the prediction model to be trained, represents the current model parameters of the prediction model to be trained, Indicates the preset prediction window length, represents the target vocabulary size of the prediction model to be trained, represents the indicator function, when hour, ,when hour, , Indicates the Cth time sequence word sample The true value of the position, represents the predicted distribution, which represents the sequence information determined according to the Cth time sequence word sample under the current model parameters of the training model to be predicted , determine the next position in the Cth time-sequential word sample Value for probability.

11. The method according to claim 10, characterized in that The method further comprises: Classifying the time-series word unit sample set to divide the continuous data in the time-series word unit sample set into a plurality of discrete intervals; Adding the index number of each discrete interval of the category to the initialization vocabulary of the prediction model to be trained to obtain the target vocabulary of the prediction model to be trained; The number of index numbers included in the target vocabulary is taken as the target vocabulary size.

12. The method according to claim 8, characterized in that The step of determining the prediction result of the time series to be predicted according to the target time series word corresponding to each target prediction block includes: Performing feature extraction and semantic understanding on the target time-series word-units corresponding to each of the target prediction blocks to obtain target prediction features and target prediction semantic information; Determining a basic input of the target prediction model according to the target prediction feature and the target prediction semantic information; The target prediction model performs inference calculation on the basic input to obtain a prediction result of the time series to be predicted.

13. An electronic device, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method according to any one of claims 1 to 12.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the method according to any one of claims 1 to 12 is implemented.

15. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Power grid electricity sale quantity prediction method and electricity sale management system

    CN116562917A

  • Prediction method and device of time series data, storage medium and computer equipment

    CN118211711A

  • Short-term photovoltaic power generation power prediction method, system and equipment based on similar weather discovery and medium

    CN118213987A

  • Photovoltaic power generation prediction method and system based on data mining and microclimate information

    CN118520348A

  • Power system short-term load prediction method, device, equipment, medium and product

    CN119324451A

Cited By

  • Network quality prediction method and device for wide area network, equipment and medium

    CN120639644A