Training method and device for time series prediction model

Through the training method of time series prediction model that dynamically adjusts the sampling rate and weight ratio, the discontinuous, irregular and multi-time scale problems of time series prediction in the prior art are solved, and the accuracy and generalization ability of prediction are improved.

CN120030301APending Publication Date: 2025-05-23XIAN SECLOVER INFORMATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510060283.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-15
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

When the prior art directly applies large language models (LLMs) to time series prediction, it faces the problem of time series discontinuity, irregularity and multiple time scales that cannot be considered, and has weak generalization ability.

Method used

A training method for a time series prediction model is proposed. By obtaining historical time series samples and dividing them into multiple historical sample fragments, local volatility and trend change rate are determined, overall volatility and trend change rate are calculated, sampling rate and weight ratio are dynamically adjusted, downsampling and prediction processing are performed, and the target time series prediction model is finally trained.

Benefits of technology

This method can more effectively capture details and trends in time series, improve prediction accuracy and generalization capabilities, adapt to different data sets and business scenarios, and has high independence and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120030301A_ABST
    Figure CN120030301A_ABST
Patent Text Reader

Abstract

The invention discloses a training method and device for a time sequence prediction model. The method comprises the following steps: dividing a historical time sequence sample into a plurality of historical sample fragments according to a first sliding window; determining the local volatility and the local trend change rate of each historical sample fragment, and determining the overall volatility and the overall trend change rate of the historical time sequence sample; dividing the historical time sequence sample according to N sliding windows of different sizes, and performing down-sampling on historical sample fragments obtained through division; selecting the most accurate target prediction result from the prediction results; and taking the target sliding window, the target sampling rate and the target weight ratio as parameters of the initial time sequence prediction model to obtain a target time sequence prediction model. According to the scheme, a self-adaptive sampling strategy and a weight strategy are adopted, and the intelligent degree is high for different data sets and service scenes. The model can be conveniently migrated to a plurality of scenes for use, and has strong generalization ability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine learning, and in particular to a training method and device for a time series prediction model. Background Art

[0002] In recent years, large language models (LLMs) have made significant progress in the field of natural language processing and have a wide range of application scenarios. However, due to the significant differences in the characteristics of time series data and text data, directly applying LLMs to time series prediction still faces many challenges. Time series prediction has important application value in many fields such as finance, energy management, and healthcare. Therefore, it is of great practical significance to study and try to solve these challenges.

[0003] Traditional forecasting models, such as ARIMA and exponential smoothing, often face limitations when dealing with complex nonlinear and non-stationary real-world time series data. Deep learning models, such as CNN and RNN, have shown excellent performance in time series forecasting tasks, but are still insufficient in capturing long-term dependencies.

[0004] Although LLMs have won the rapid growth of application scenarios with their powerful multimodal knowledge integration and complex reasoning capabilities, if LLMs are directly used for time series prediction, they still face problems such as discontinuous time series, continuous but irregular time series, and time series with multiple time scales that cannot be taken into account. Although recent solutions such as LLM-Mixer have solved these problems to a certain extent, they still have shortcomings.

[0005] For example:

[0006] The sampling frequency is fixed. The LLM-Mixer and other solution frameworks introduce multi-scale time series decomposition to solve the continuous and irregular patterns that time series data usually presents, but their sampling frequency is relatively fixed, and the effect is good but the adaptability is poor for different data sets and business scenarios.

[0007] Information cannot be distinguished between important and unimportant. Solutions such as LLM-Mixer treat all information equally and cannot distinguish important information.

[0008] Weak generalization ability. Solutions such as LLM-Mixer are highly dependent on the data set and may have the problem of overfitting specific data sets, so the generalization ability is weak. Summary of the invention

[0009] The present invention aims to at least solve the technical problems existing in the prior art. To this end, the first aspect of the present invention proposes a training method for a time series prediction model, the method comprising:

[0010] S1: Obtain historical time series samples of a scene to be predicted, and divide the historical time series samples into a plurality of historical sample segments according to a first sliding window; each of the historical sample segments includes a first number of samples;

[0011] S2: Determine the local volatility and the local trend change rate of each of the historical sample segments, and determine the overall volatility and the overall trend change rate of the historical time series samples based on the local volatility and the local trend change rate;

[0012] S3: obtaining a preset weight data set, wherein the weight data set includes multiple combinations of volatility weight initial values ​​and trend weight initial values, and determining the ratio of the volatility weight initial value to the trend weight initial value in each combination to obtain multiple ratios, and obtaining a minimum ratio and a maximum ratio from the multiple ratios;

[0013] S4: Determine a first initial sampling rate corresponding to the minimum ratio and a second initial sampling rate corresponding to the maximum ratio according to the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio and the maximum ratio, the overall volatility, the overall trend change rate, and a preset sampling rate calculation formula;

[0014] S5: determining a target sampling rate of the historical sample segment based on the sampling rate range defined by the first initial sampling rate and the second initial sampling rate, substituting the target sampling rate into the sampling rate calculation formula to obtain a ratio of the volatility weight to the trend weight, and using the ratio as a target weight ratio;

[0015] S6: downsampling the historical time series samples using the target sampling rate to obtain a first sub-historical time series sample;

[0016] S7: dividing the historical time series samples according to N sliding windows of different sizes, and downsampling the divided historical sample fragments according to the methods of S2-S6 to obtain N sub-historical time series samples;

[0017] S8: respectively inputting the first sub-historical time series sample and the N sub-historical time series samples into a preset initial time series prediction model for prediction processing, and obtaining prediction results corresponding to each of the sub-historical time series samples; and selecting the most accurate target prediction result from the prediction results;

[0018] S9: Obtain a target sliding window, a target sampling rate, and a target weight ratio corresponding to the target prediction result, use the target sliding window, the target sampling rate, and the target weight ratio as parameters of the initial time series prediction model, train the initial time series prediction model, and obtain a target time series prediction model.

[0019] Optionally, determining the local volatility and the local trend change rate of each of the historical sample segments includes:

[0020] Determine the standard deviation of the historical sample segment according to the first data value of the first sample in the historical sample segment, the average value of each sample in the historical sample segment, and the number of samples in the historical sample segment;

[0021] Determine the trend slope of the historical sample segment according to the timestamp and data value of the historical sample segment and the timestamp and data value of a previous historical sample segment adjacent to the historical sample segment;

[0022] Determining the local volatility of the historical sample segment according to the standard deviation of the historical sample segment and the standard deviation of the previous historical sample segment;

[0023] The local trend change rate of the historical sample segment is determined according to the trend slope of the historical sample segment and the trend slope of the previous historical sample segment.

[0024] Optionally, determining the trend slope of the historical sample segment according to the timestamp and data value of the historical sample segment and the timestamp and data value of a previous historical sample segment adjacent to the historical sample segment includes:

[0025] Obtaining a first timestamp and a first data value of a first sample in the historical sample segment, and a second timestamp and a second data value of a last sample in the historical sample segment;

[0026] determining a first slope of the historical sample segment based on the first timestamp, the second timestamp, the first data value, and the second data value;

[0027] Acquire a second slope of a previous historical sample segment adjacent to the historical sample segment;

[0028] The absolute value of the difference between the first slope and the second slope is used as the trend slope of the historical sample segment.

[0029] Optionally, determining the overall volatility and the overall trend change rate of the historical time series samples according to the local volatility and the local trend change rate includes:

[0030] The sum of the local volatility of each of the historical sample segments is taken as the overall volatility of the historical time series sample;

[0031] The sum of the local trend change rates of each of the historical sample segments is taken as the overall trend change rate of the historical time series samples.

[0032] Optionally, the determining a first initial sampling rate corresponding to the minimum ratio and a second initial sampling rate corresponding to the maximum ratio according to the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio and the maximum ratio, the overall volatility, the overall trend change rate, and a preset sampling rate calculation formula, respectively, includes:

[0033] Substituting the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio, as well as the overall volatility and the overall trend change rate, into a preset sampling rate calculation formula to obtain a first sampling rate corresponding to the minimum ratio;

[0034] The initial value of the volatility weight and the initial value of the trend weight corresponding to the maximum ratio, as well as the overall volatility and the overall trend change rate are substituted into the preset sampling rate calculation formula to obtain a second sampling rate corresponding to the maximum ratio.

[0035] Optionally, determining the target sampling rate of the historical sample segment based on the sampling rate range defined by the first initial sampling rate and the second initial sampling rate includes:

[0036] Get the preset minimum sampling rate threshold and maximum sampling rate threshold;

[0037] Taking the larger value between the first initial sampling rate and the minimum sampling rate threshold as the first target sampling rate;

[0038] Taking the smaller value between the second initial sampling rate and the maximum sampling rate threshold as the second target sampling rate;

[0039] The target sampling rate of the historical sample segment is determined based on the first target sampling rate, the sampling rate range defined by the second target sampling rate, and a preset target sampling rate calculation formula.

[0040] Optionally, after obtaining the target time series prediction model, the following is further included:

[0041] The current time series data is input into the target time series prediction model, the current time series samples are divided and downsampled using the target sliding window, the target sampling rate and the target weight ratio in the model, and the processed time series data is predicted to obtain the prediction result of the current time series data.

[0042] A second aspect of the present invention provides a training device for a time series prediction model, the device comprising:

[0043] A sample division module, used for obtaining historical time series samples of a scene to be predicted, and dividing the historical time series samples into a plurality of historical sample segments according to a first sliding window; each of the historical sample segments includes a first number of samples;

[0044] A change rate determination module, used to determine the local volatility and local trend change rate of each of the historical sample segments, and determine the overall volatility and overall trend change rate of the historical time series samples based on the local volatility and the local trend change rate;

[0045] A ratio acquisition module, used to acquire a preset weight data set, wherein the weight data set includes multiple combinations of volatility weight initial values ​​and trend weight initial values, and determine the ratio of the volatility weight initial value to the trend weight initial value in each combination to obtain multiple ratios, and acquire a minimum ratio and a maximum ratio from the multiple ratios;

[0046] An initial sampling rate determination module, used to determine a first initial sampling rate corresponding to the minimum ratio and a second initial sampling rate corresponding to the maximum ratio according to the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio and the maximum ratio, the overall volatility, the overall trend change rate, and a preset sampling rate calculation formula;

[0047] A weight ratio determination module, configured to determine a target sampling rate of the historical sample segment based on the sampling rate range defined by the first initial sampling rate and the second initial sampling rate, and substitute the target sampling rate into the sampling rate calculation formula to obtain a ratio of the volatility weight to the trend weight, and use the ratio as a target weight ratio;

[0048] A first downsampling module, configured to downsample the historical time series samples using the target sampling rate to obtain a first sub-historical time series sample;

[0049] The second downsampling module is used to divide the historical time series samples according to N sliding windows of different sizes, and downsample the divided historical sample fragments according to methods S2-S6 to obtain N sub-historical time series samples;

[0050] A prediction module, used to input the first sub-historical time series sample and the N sub-historical time series samples into a preset initial time series prediction model for prediction processing, to obtain prediction results corresponding to each of the sub-historical time series samples; and to select the most accurate target prediction result from the prediction results;

[0051] A training module is used to obtain a target sliding window, a target sampling rate and a target weight ratio corresponding to the target prediction result, and use the target sliding window, the target sampling rate and the target weight ratio as parameters of the initial time series prediction model to train the initial time series prediction model to obtain a target time series prediction model.

[0052] The third aspect of the present invention provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the training method of the time series prediction model as described in the first aspect.

[0053] A fourth aspect of the present invention provides a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method of the time series prediction model as described in the first aspect.

[0054] The embodiments of the present invention have the following beneficial effects:

[0055] In an embodiment of the present invention, for samples with higher volatility, a higher sampling rate is maintained to capture details; for samples with lower volatility, the sampling rate is reduced to save storage resources and computing resources. For samples with significant trend changes, a higher sampling rate is maintained to capture trend changes. For samples with gentle trend changes, the sampling rate is reduced to save storage resources and computing resources. In addition, by adopting an adaptive sampling strategy and an adaptive weight strategy, the most suitable downsampling strategies can be efficiently screened out for different data sets and business scenarios, and the degree of intelligence is high. In addition, this model has high independence, can be easily migrated to a variety of scenarios for use, and has strong generalization ability. This model integrates an adaptive weight mechanism, which can focus on the main information in the time series, and occupy a higher weight in subsequent predictions, so that the subsequent calculation process can focus on key points, thereby improving efficiency. This model is designed for general time scale series data, and can be pre-trained and trained for data sets in different scenarios, without changing the model too much, and has good scalability. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 It is a flowchart of the steps of a training method for a time series prediction model provided by an embodiment of the present invention;

[0057] Figure 2 A schematic diagram of a model building process provided by an embodiment of the present invention;

[0058] Figure 3 It is a structural block diagram of a training device for a time series prediction model provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0060] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, the use of "based on" or "according to" means openness and inclusiveness, because the process, steps, calculations or other actions "based on" or "according to" one or more of the conditions or values ​​may be based on additional conditions or values ​​beyond the described values ​​in practice.

[0061] Figure 1 It is a flowchart of the steps of a training method for a time series prediction model provided by an embodiment of the present invention.

[0062] like Figure 1 As shown, the method comprises the following steps:

[0063] S1: Obtain historical time series samples of a scene to be predicted, and divide the historical time series samples into multiple historical sample segments according to a first sliding window; each of the historical sample segments includes a first number of samples.

[0064] Time series refers to a series of values ​​of the same statistical indicator arranged in the order of their occurrence. The main purpose of time series data forecasting is to predict the future based on existing historical data.

[0065] In the field of network security, network traffic time series data is used to monitor changes in network traffic, and user behavior is monitored and analyzed in real time. In the field of marketing, sales performance changes with time series, which can be used to analyze marketing behavior and product effectiveness evaluation. In the field of industrial manufacturing and the Internet of Things, sensors record time series data to detect abnormal conditions of Internet of Things devices. In the field of medical health, electrocardiogram and electroencephalogram time series are used to monitor and analyze heart and brain information. In the field of meteorological forecasting, time series such as temperature and rainfall are analyzed to predict future weather conditions.

[0066] In this solution, the scenario to be predicted can be any of the above scenarios. The historical time series data can be the time series data of the scenario to be predicted in any historical time period. For example, the historical time series data is the network traffic time series data of the target IP address in the historical time period, and the object to be predicted is the network traffic time series data of the next time period corresponding to the historical time period.

[0067] After obtaining the historical time series data, data preprocessing is performed to obtain historical time series samples. Data preprocessing mainly includes: data cleaning and feature engineering. Data cleaning includes processing missing values, outliers, and noise, etc. Feature engineering includes extracting features that may be useful to the model, such as trends, seasonality, etc.

[0068] After obtaining the historical time series samples, the samples are divided according to the first sliding window to obtain multiple historical sample segments. The size of the first sliding window is a first number of samples, and each historical sample segment includes the first number of samples.

[0069] S2: Determine the local volatility and the local trend change rate of each of the historical sample segments, and determine the overall volatility and the overall trend change rate of the historical time series samples based on the local volatility and the local trend change rate.

[0070] The historical sample segments are analyzed from the two aspects of volatility and trend change. To calculate the local volatility of the historical sample segments, the standard deviation of the data values ​​in the first sliding window can be used as a measure of volatility. To calculate the local trend change rate, the slope change of the data values ​​in the first sliding window can be used as a measure of trend change.

[0071] Based on the local volatility and local trend change rate of each historical sample segment, the overall volatility and overall trend change rate of the entire sample are determined.

[0072] By calculating the overall volatility and overall trend change rate of the entire sample, for samples with higher volatility, a higher sampling rate is maintained to capture details; for samples with lower volatility, the sampling rate is reduced to save storage and computing resources. For samples with significant trend changes, a higher sampling rate is maintained to capture trend changes. For samples with gentle trend changes, the sampling rate is reduced to save storage and computing resources.

[0073] As an optional embodiment, determining the local volatility and the local trend change rate of each of the historical sample segments includes:

[0074] S21: determining a standard deviation of the historical sample segment according to a first data value of a first sample in the historical sample segment, an average value of each sample in the historical sample segment, and the number of samples in the historical sample segment;

[0075] S22: determining the trend slope of the historical sample segment according to the timestamp and data value of the historical sample segment and the timestamp and data value of the previous historical sample segment adjacent to the historical sample segment;

[0076] S23: determining the local volatility of the historical sample segment according to the standard deviation of the historical sample segment and the standard deviation of the previous historical sample segment;

[0077] S24: Determine the local trend change rate of the historical sample segment according to the trend slope of the historical sample segment and the trend slope of the previous historical sample segment.

[0078] In S21-S24, the standard deviation is calculated for each historical sample segment using the formula:

[0079]

[0080] Among them, σ is the standard deviation of the historical sample segment, x i is the first data value of the first sample in the historical sample segment, is the average value of each sample in the historical sample segment, and N is the number of samples in the historical sample segment.

[0081] The calculation formula of the local volatility m1(i) of the historical sample segment is:

[0082]

[0083] Among them, σ1 and σ2 represent the standard deviation of the historical sample segment and the previous historical sample segment respectively. The trend slope calculation formula for each historical sample segment is:

[0084] Δm(i)=│k i2 -ki │

[0085] Among them, Δm(i) represents the trend slope, k i and k i2 They are the slope values ​​of the current historical sample segment and the adjacent previous historical sample segment respectively.

[0086] The calculation formula of the local trend change rate m2(i) of the historical sample segment is:

[0087]

[0088] Among them, Δm1 and Δm2 represent the trend slope of the historical sample segment and the trend slope of the previous historical sample segment respectively.

[0089] As an optional embodiment, S22 includes:

[0090] S221: Acquire a first timestamp and a first data value of a first sample in the historical sample segment, and a second timestamp and a second data value of a last sample in the historical sample segment;

[0091] S222: Determine a first slope of the historical sample segment according to the first timestamp, the second timestamp, the first data value, and the second data value;

[0092] S223: Obtaining a second slope of a previous historical sample segment adjacent to the historical sample segment;

[0093] S224: Using the absolute value of the difference between the first slope and the second slope as the trend slope of the historical sample segment.

[0094] In S221-S224, the calculation formula of the first slope k of the historical sample segment is:

[0095]

[0096] Among them, y2 and y1 respectively represent the second data value of the last sample and the first data value of the first sample of the historical sample segment, and x2 and x1 respectively represent the second timestamp of the last sample and the first timestamp of the first sample of the historical sample segment.

[0097] The calculation formula for the trend slope Δm(i) of the historical sample segment is:

[0098] Δm(i)=│k i2 -k i │

[0099] Among them, Δm(i) represents the trend slope, k i and k i2They are respectively the first slope of the current historical sample segment and the second slope of the adjacent previous historical sample segment.

[0100] As an optional embodiment, determining the overall volatility and the overall trend change rate of the historical time series sample according to the local volatility and the local trend change rate includes:

[0101] S25: taking the sum of the local volatility of each of the historical sample segments as the overall volatility of the historical time series sample;

[0102] S26: taking the sum of the local trend change rates of each of the historical sample segments as the overall trend change rate of the historical time series samples.

[0103] In S25-S26, the sum of the local volatility of each historical sample segment is calculated to obtain the overall volatility of the historical time series sample; the sum of the local trend change rate of each historical sample segment is calculated to obtain the overall trend change rate of the historical time series sample.

[0104] S3: Obtain a preset weight data set, which includes multiple combinations of volatility weight initial values ​​and trend weight initial values, and determine the ratio of the volatility weight initial value to the trend weight initial value in each combination to obtain multiple ratios, and obtain the minimum ratio and the maximum ratio from the multiple ratios.

[0105] When building a strategy, the volatility indicator weight w1 and the trend indicator weight w2 are two very important parameters, and their relative sizes directly affect the sampling effect. The initial values ​​are generally given by experts, but they need to be adjusted and corrected in real time for different scenarios.

[0106] Therefore, it is necessary to obtain a preset weight data set and adjust and correct the weight combination of the volatility indicator weight w1 and the trend indicator weight w2 in the weight data set.

[0107] Since the effects of two weights are reflected by relative sizes, and the ratio of the two weights can reflect the relative sizes, the ratio of the two weights in each combination is obtained: a=w1 / w2, and the minimum ratio and the maximum ratio are selected from multiple ratios to form a ratio interval [a1, a2].

[0108] The minimum ratio indicates the situation where the difference between the values ​​of the two weights is the largest, and the maximum ratio indicates the situation where the difference between the values ​​of the two weights is the smallest.

[0109] S4: Determine a first initial sampling rate corresponding to the minimum ratio and a second initial sampling rate corresponding to the maximum ratio according to the initial volatility weight value and the initial trend weight value corresponding to the minimum ratio and the maximum ratio, the overall volatility, the overall trend change rate, and a preset sampling rate calculation formula.

[0110] The preset sampling rate calculation formula is as follows:

[0111]

[0112] Among them, ver_type represents the sampling rate, w1 represents the initial value of volatility weight, w2 represents the initial value of trend weight, m1 represents the overall volatility, and m2 represents the overall trend change rate.

[0113] As an optional embodiment, S4 includes:

[0114] S41: Substituting the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio, as well as the overall volatility and the overall trend change rate, into a preset sampling rate calculation formula to obtain a first sampling rate corresponding to the minimum ratio;

[0115] S42: Substitute the initial value of the volatility weight and the initial value of the trend weight corresponding to the maximum ratio, as well as the overall volatility and the overall trend change rate, into a preset sampling rate calculation formula to obtain a second sampling rate corresponding to the maximum ratio.

[0116] In S41-S42, the initial value of the volatility weight and the initial value of the trend weight corresponding to the minimum ratio are substituted into the sampling rate calculation formula to obtain the first sampling rate V1.

[0117] Substitute the initial value of volatility weight and the initial value of trend weight corresponding to the maximum ratio into the sampling rate calculation formula to obtain the second sampling rate V2.

[0118] S5: Based on the sampling rate range defined by the first initial sampling rate and the second initial sampling rate, determine the target sampling rate of the historical sample segment, and substitute the target sampling rate into the sampling rate calculation formula to obtain the ratio of the volatility weight to the trend weight, and use the ratio as the target weight ratio.

[0119] Based on the sampling rate range (V1, V2), the optimal sampling rate, ie, the target sampling rate V0, is determined.

[0120] Substitute the target sampling rate V0 into the sampling rate calculation formula to obtain the ratio of w1 and w2, that is, the target weight ratio.

[0121] As an optional embodiment, determining the target sampling rate of the historical sample segment based on the sampling rate range defined by the first initial sampling rate and the second initial sampling rate includes:

[0122] S51: Obtaining a preset minimum sampling rate threshold and a maximum sampling rate threshold;

[0123] S52: taking the larger value between the first initial sampling rate and the minimum sampling rate threshold as the first target sampling rate;

[0124] S53: taking the smaller value between the second initial sampling rate and the maximum sampling rate threshold as the second target sampling rate;

[0125] S54: Determine the target sampling rate of the historical sample segment based on the first target sampling rate, the sampling rate range defined by the second target sampling rate, and a preset target sampling rate calculation formula.

[0126] In S51-S54, the preset minimum sampling rate threshold value ver_type1 and the maximum sampling rate threshold value ver_type2 are obtained. The larger value of the first initial sampling rate v1 and ver_type1 is taken to obtain the first target sampling rate V 01 , that is, V 01 =max(ver_type1,v1).

[0127] Take the smaller value of the second initial sampling rate V2 and ver_type2 to get the second target sampling rate V 02 , that is, V 02 =min(ver_type2,v2).

[0128] Thus, the sampling rate range (V 01 , V 02 ).

[0129] The target sampling rate formula is as follows:

[0130] V 0 =V 01 +0.618*(V 02 -V 01 )

[0131] Among them, V 0 represents the target sampling rate, V 01、 V 02 Represent the first target sampling rate and the second target sampling rate respectively.

[0132] V 0 Substitute into the sampling rate calculation formula to get the ratio of w1 and w2, that is, the target weight ratio a 0 .

[0133] S6: Down-sampling the historical time series samples using the target sampling rate to obtain a first sub-historical time series sample.

[0134] Using the target sampling rate V 0 The historical time series samples are downsampled to obtain the first sub-historical time series samples.

[0135] S7: Divide the historical time series samples according to N sliding windows of different sizes, and downsample the divided historical sample segments according to the methods of S2-S6 to obtain N sub-historical time series samples.

[0136] The N sliding windows of different sizes include different numbers of samples. For example, the first sliding window includes 5 samples, the second sliding window includes 10 samples, and the third sliding window includes 30 samples.

[0137] For example, the historical time series samples are divided according to the second sliding window to obtain multiple second sub-historical time series sample fragments, and the historical time series samples are divided according to the third sliding window to obtain multiple third sub-historical time series sample fragments.

[0138] S8: respectively inputting the first sub-historical time series sample and the N sub-historical time series samples into a preset initial time series prediction model for prediction processing to obtain prediction results corresponding to each of the sub-historical time series samples; and selecting the most accurate target prediction result from the prediction results.

[0139] Input multiple first sub-historical time series sample fragments into the preset initial time series prediction model to obtain a first prediction result; input multiple second sub-historical time series sample fragments into the preset initial time series prediction model to obtain a second prediction result; input multiple third sub-historical time series sample fragments into the preset initial time series prediction model to obtain a third prediction result. Until N sub-historical time series sample fragments are input into the initial time series prediction model to obtain N prediction results.

[0140] The N prediction results are compared with the preset true values ​​respectively, and the prediction result with the smallest difference with the true value is taken as the most accurate target prediction result.

[0141] Get the sliding window size corresponding to the target prediction result and obtain the target sliding window.

[0142] The initial time series prediction models available include VAE (Variational Autoencoder), GAN (Generative Adversarial Network), etc.

[0143] VAE is suitable for learning low-dimensional representations of data and can capture the potential structure of data; GAN is suitable for generating high-quality, high-resolution data representations and can capture the complex distribution of data. Decision basis: Choose a suitable model based on the characteristics of time series data and application requirements. For example, if the data has obvious periodicity and trends, VAE may be more suitable; if the data has a complex distribution, GAN may be more suitable.

[0144] S9: Obtain a target sliding window, a target sampling rate, and a target weight ratio corresponding to the target prediction result, use the target sliding window, the target sampling rate, and the target weight ratio as parameters of the initial time series prediction model, train the initial time series prediction model, and obtain a target time series prediction model.

[0145] The target sliding window, target sampling rate and target weight ratio obtained in the above process are solidified to the relevant positions of the initial time series prediction model, that is, the pre-training process is completed and the target time series prediction model is obtained.

[0146] As an optional embodiment, after S9, the method further includes:

[0147] The current time series data is input into the target time series prediction model, the current time series samples are divided and downsampled using the target sliding window, the target sampling rate and the target weight ratio in the model, and the processed time series data is predicted to obtain the prediction result of the current time series data.

[0148] In an embodiment of the present invention, after the target sliding window, target sampling rate and target weight ratio are fixed in the target time series prediction model, the current time series data to be predicted is directly input into the model, and the model can be used to perform prediction processing on the data to obtain the prediction result.

[0149] Figure 2 It is a schematic diagram of a model building process provided by an embodiment of the present invention.

[0150] like Figure 2 As shown, in the process of model construction, this scheme specifies an adaptive sampling strategy and constructs an adaptive weight strategy. Parameters such as the target sliding window, target sampling rate, and target weight ratio are obtained through the adaptive sampling strategy and the adaptive weight strategy. The parameters are solidified in the model to build a prediction model.

[0151] After building the prediction model, the model is trained, evaluated, parameterized and packaged to obtain the target time series prediction model.

[0152] The innovative points of this solution are:

[0153] 1) Dynamic adaptive sampling strategy. In data sampling, the dynamic adaptive strategy can avoid traditional sampling problems such as single sampling frequency, inconsistent sampling scenarios, and rigid sampling methods. This adaptive strategy is based on multiple dimensions, uses adaptive algorithms, and dynamically and autonomously mines the best sampling frequency and path to improve the overall sampling effect.

[0154] 2) Adaptive weight strategy mechanism. By introducing the adaptive weight strategy mechanism into the model construction process, a small amount of data set can be used to balance the trade-offs between liquidity and trend without any manual intervention.

[0155] 3) Introduction of adaptive mechanism. For the two most important dimensions in time series, namely liquidity and trend, the idea of ​​automatic setting and training is adopted to make the calculation process and model construction adaptive and automatic. It enables the model to automatically adjust the processing strategy according to the actual characteristics of the data, improving the adaptability and flexibility of the model.

[0156] 4) Dynamically build the model in stages. When the model is built as a whole, a pre-training process is used to determine some parameters and indicators of the model. After the initial model is built, the model is trained using the training set to build a complete prediction model. Building the model in two stages effectively separates the creation and training of the model. Only a small amount of data set is required in the creation stage, which ensures that the model can effectively adapt to the current business scenario without requiring a large number of training sets and excessive resources. In the training stage, since some model parameters are fixed and no adjustment is required, the complexity of the model is reduced and the effect and efficiency of model training are improved.

[0157] In summary, in an embodiment of the present invention, a historical time series sample of a scene to be predicted is obtained, and the historical time series sample is divided into a plurality of historical sample segments according to a first sliding window; the local volatility and the local trend change rate of each of the historical sample segments are determined, and the overall volatility and the overall trend change rate of the historical time series sample are determined based on the local volatility and the local trend change rate; a preset weight data set is obtained, the weight data set includes a plurality of combinations of volatility weight initial values ​​and trend weight initial values, and the ratio of the volatility weight initial value to the trend weight initial value in each combination is determined to obtain a plurality of ratios, and a minimum ratio and a maximum ratio are obtained from the plurality of ratios; a first initial sampling rate corresponding to the minimum ratio and a second initial sampling rate corresponding to the maximum ratio are determined based on the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio and the maximum ratio, as well as the overall volatility, the overall trend change rate, and a preset sampling rate calculation formula; based on the sampling rate range defined by the first initial sampling rate and the second initial sampling rate, the historical scene is determined. The target sampling rate of the sample segment is obtained, and the target sampling rate is substituted into the sampling rate calculation formula to obtain the ratio of the volatility weight to the trend weight, and the ratio is used as the target weight ratio; the historical time series samples are downsampled using the target sampling rate to obtain a first sub-historical time series sample; the historical time series samples are divided according to N sliding windows of different sizes, and the historical sample segments obtained by the division are downsampled according to the methods S2-S6 to obtain N sub-historical time series samples; the first sub-historical time series sample and the N sub-historical time series samples are respectively input into the preset initial time series prediction model for prediction processing to obtain the prediction results corresponding to each of the sub-historical time series samples; the most accurate target prediction result is selected from the prediction results; the target sliding window, target sampling rate and target weight ratio corresponding to the target prediction result are obtained, and the target sliding window, target sampling rate and target weight ratio are used as parameters of the initial time series prediction model to train the initial time series prediction model to obtain the target time series prediction model. For samples with high volatility, this solution maintains a high sampling rate to capture details; for samples with low volatility, the sampling rate is reduced to save storage and computing resources. For samples with significant trend changes, a high sampling rate is maintained to capture trend changes. For samples with gentle trend changes, the sampling rate is reduced to save storage and computing resources. In addition, the use of adaptive sampling strategies and adaptive weight strategies can efficiently screen out the most suitable downsampling strategies for different data sets and business scenarios, with a high degree of intelligence. In addition, this model has a high degree of independence and can be easily migrated to a variety of scenarios for use, while also having strong generalization capabilities.This model integrates an adaptive weight mechanism, which can focus on the main information in the time series and give it a higher weight in subsequent predictions, so that the subsequent calculation process can focus on key points, thereby improving efficiency. This model is designed for general time scale series data, and can be pre-trained and trained for data sets in different scenarios without changing the model too much, and has good scalability.

[0158] Figure 3 1 is a structural block diagram of a training device for a time series prediction model provided by an embodiment of the present invention. Figure 3 As shown, the device 200 includes:

[0159] The sample division module 201 is used to obtain historical time series samples of the scene to be predicted, and divide the historical time series samples into a plurality of historical sample segments according to a first sliding window; each of the historical sample segments includes a first number of samples;

[0160] A change rate determination module 202 is used to determine the local volatility and local trend change rate of each of the historical sample segments, and determine the overall volatility and overall trend change rate of the historical time series samples based on the local volatility and the local trend change rate;

[0161] The ratio acquisition module 203 is used to acquire a preset weight data set, wherein the weight data set includes multiple combinations of volatility weight initial values ​​and trend weight initial values, and determine the ratio of the volatility weight initial value to the trend weight initial value in each combination to obtain multiple ratios, and obtain a minimum ratio and a maximum ratio from the multiple ratios;

[0162] An initial sampling rate determination module 204 is used to determine a first initial sampling rate corresponding to the minimum ratio and a second initial sampling rate corresponding to the maximum ratio according to the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio and the maximum ratio, the overall volatility, the overall trend change rate, and a preset sampling rate calculation formula;

[0163] A weight ratio determination module 205 is used to determine a target sampling rate of the historical sample segment based on the sampling rate range defined by the first initial sampling rate and the second initial sampling rate, and substitute the target sampling rate into the sampling rate calculation formula to obtain a ratio of the volatility weight to the trend weight, and use the ratio as a target weight ratio;

[0164] A first downsampling module 206, configured to downsample the historical time series samples using the target sampling rate to obtain a first sub-historical time series sample;

[0165] The second downsampling module 207 is used to divide the historical time series samples according to N sliding windows of different sizes, and downsample the divided historical sample segments according to methods S2-S6 to obtain N sub-historical time series samples;

[0166] The prediction module 208 is used to input the first sub-historical time series sample and the N sub-historical time series samples into a preset initial time series prediction model for prediction processing, and obtain prediction results corresponding to each of the sub-historical time series samples; and select the most accurate target prediction result from the prediction results;

[0167] The training module 209 is used to obtain the target sliding window, target sampling rate and target weight ratio corresponding to the target prediction result, and use the target sliding window, target sampling rate and target weight ratio as parameters of the initial time series prediction model to train the initial time series prediction model to obtain the target time series prediction model.

[0168] Regarding the device in the above 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.

[0169] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0170] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that comply with the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0171] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A training method for a time series prediction model, characterized in that: The method comprises: S1: Obtain historical time series samples of a scene to be predicted, and divide the historical time series samples into a plurality of historical sample segments according to a first sliding window; each of the historical sample segments includes a first number of samples; S2: Determine the local volatility and the local trend change rate of each of the historical sample segments, and determine the overall volatility and the overall trend change rate of the historical time series samples based on the local volatility and the local trend change rate; S3: obtaining a preset weight data set, wherein the weight data set includes multiple combinations of volatility weight initial values ​​and trend weight initial values, and determining the ratio of the volatility weight initial value to the trend weight initial value in each combination to obtain multiple ratios, and obtaining a minimum ratio and a maximum ratio from the multiple ratios; S4: Determine a first initial sampling rate corresponding to the minimum ratio and a second initial sampling rate corresponding to the maximum ratio according to the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio and the maximum ratio, the overall volatility, the overall trend change rate, and a preset sampling rate calculation formula; S5: determining a target sampling rate of the historical sample segment based on the sampling rate range defined by the first initial sampling rate and the second initial sampling rate, substituting the target sampling rate into the sampling rate calculation formula to obtain a ratio of the volatility weight to the trend weight, and using the ratio as a target weight ratio; S6: downsampling the historical time series samples using the target sampling rate to obtain a first sub-historical time series sample; S7: dividing the historical time series samples according to N sliding windows of different sizes, and downsampling the divided historical sample fragments according to the methods of S2-S6 to obtain N sub-historical time series samples; S8: respectively inputting the first sub-historical time series sample and the N sub-historical time series samples into a preset initial time series prediction model for prediction processing, and obtaining prediction results corresponding to each of the sub-historical time series samples; and selecting the most accurate target prediction result from the prediction results; S9: Obtain a target sliding window, a target sampling rate, and a target weight ratio corresponding to the target prediction result, use the target sliding window, the target sampling rate, and the target weight ratio as parameters of the initial time series prediction model, train the initial time series prediction model, and obtain a target time series prediction model.

2. The method according to claim 1, characterized in that Determining the local volatility and local trend change rate of each of the historical sample segments includes: Determine the standard deviation of the historical sample segment according to the first data value of the first sample in the historical sample segment, the average value of each sample in the historical sample segment, and the number of samples in the historical sample segment; Determine the trend slope of the historical sample segment according to the timestamp and data value of the historical sample segment and the timestamp and data value of a previous historical sample segment adjacent to the historical sample segment; Determining the local volatility of the historical sample segment according to the standard deviation of the historical sample segment and the standard deviation of the previous historical sample segment; The local trend change rate of the historical sample segment is determined according to the trend slope of the historical sample segment and the trend slope of the previous historical sample segment.

3. The method according to claim 2, characterized in that Determining the trend slope of the historical sample segment according to the timestamp and data value of the historical sample segment and the timestamp and data value of the previous historical sample segment adjacent to the historical sample segment includes: Obtaining a first timestamp and a first data value of a first sample in the historical sample segment, and a second timestamp and a second data value of a last sample in the historical sample segment; determining a first slope of the historical sample segment based on the first timestamp, the second timestamp, the first data value, and the second data value; Acquire a second slope of a previous historical sample segment adjacent to the historical sample segment; The absolute value of the difference between the first slope and the second slope is used as the trend slope of the historical sample segment.

4. The method according to claim 1, characterized in that Determining the overall volatility and the overall trend change rate of the historical time series sample according to the local volatility and the local trend change rate includes: The sum of the local volatility of each of the historical sample segments is taken as the overall volatility of the historical time series sample; The sum of the local trend change rates of each of the historical sample segments is taken as the overall trend change rate of the historical time series samples.

5. The method according to claim 1, characterized in that: The determining of a first initial sampling rate corresponding to the minimum ratio and a second initial sampling rate corresponding to the maximum ratio according to the initial volatility weight and the initial trend weight corresponding to the minimum ratio and the maximum ratio, the overall volatility, the overall trend change rate, and a preset sampling rate calculation formula, comprises: Substituting the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio, as well as the overall volatility and the overall trend change rate, into a preset sampling rate calculation formula to obtain a first sampling rate corresponding to the minimum ratio; The initial value of the volatility weight and the initial value of the trend weight corresponding to the maximum ratio, as well as the overall volatility and the overall trend change rate are substituted into the preset sampling rate calculation formula to obtain a second sampling rate corresponding to the maximum ratio.

6. The method according to claim 1, characterized in that The step of determining a target sampling rate of the historical sample segment based on a sampling rate range defined by the first initial sampling rate and the second initial sampling rate includes: Get the preset minimum sampling rate threshold and maximum sampling rate threshold; Taking the larger value between the first initial sampling rate and the minimum sampling rate threshold as the first target sampling rate; Taking the smaller value between the second initial sampling rate and the maximum sampling rate threshold as the second target sampling rate; The target sampling rate of the historical sample segment is determined based on the first target sampling rate, the sampling rate range defined by the second target sampling rate, and a preset target sampling rate calculation formula.

7. The method according to claim 1, characterized in that After obtaining the target time series forecasting model, it also includes: The current time series data is input into the target time series prediction model, the current time series samples are divided and downsampled using the target sliding window, the target sampling rate and the target weight ratio in the model, and the processed time series data is predicted to obtain the prediction result of the current time series data.

8. A training device for a time series prediction model, characterized in that: The device comprises: A sample division module, used for obtaining historical time series samples of a scene to be predicted, and dividing the historical time series samples into a plurality of historical sample segments according to a first sliding window; each of the historical sample segments includes a first number of samples; A change rate determination module, used to determine the local volatility and local trend change rate of each of the historical sample segments, and determine the overall volatility and overall trend change rate of the historical time series samples based on the local volatility and the local trend change rate; A ratio acquisition module, used to acquire a preset weight data set, wherein the weight data set includes multiple combinations of volatility weight initial values ​​and trend weight initial values, and determine the ratio of the volatility weight initial value to the trend weight initial value in each combination to obtain multiple ratios, and acquire a minimum ratio and a maximum ratio from the multiple ratios; An initial sampling rate determination module, used to determine a first initial sampling rate corresponding to the minimum ratio and a second initial sampling rate corresponding to the maximum ratio according to the volatility weight initial value and the trend weight initial value corresponding to the minimum ratio and the maximum ratio, the overall volatility, the overall trend change rate, and a preset sampling rate calculation formula; A weight ratio determination module, configured to determine a target sampling rate of the historical sample segment based on the sampling rate range defined by the first initial sampling rate and the second initial sampling rate, and substitute the target sampling rate into the sampling rate calculation formula to obtain a ratio of the volatility weight to the trend weight, and use the ratio as a target weight ratio; A first downsampling module, configured to downsample the historical time series samples using the target sampling rate to obtain a first sub-historical time series sample; The second downsampling module is used to divide the historical time series samples according to N sliding windows of different sizes, and downsample the divided historical sample fragments according to methods S2-S6 to obtain N sub-historical time series samples; A prediction module, used to input the first sub-historical time series sample and the N sub-historical time series samples into a preset initial time series prediction model for prediction processing, to obtain prediction results corresponding to each of the sub-historical time series samples; and to select the most accurate target prediction result from the prediction results; A training module is used to obtain a target sliding window, a target sampling rate and a target weight ratio corresponding to the target prediction result, and use the target sliding window, the target sampling rate and the target weight ratio as parameters of the initial time series prediction model to train the initial time series prediction model to obtain a target time series prediction model.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the instructions to implement the training method of the time series prediction model as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the training method for a time series prediction model as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Multi-target prediction method based on renewable energy sources and related equipment

    CN121188732A