Time sequence model implementation method and device based on multi-KPI clustering, electronic equipment and storage medium
Through the timing model implementation method based on multi-KPI clustering, the problem of large number of models and low prediction efficiency when deploying small timing models on the device side is solved, and an efficient prediction effect is achieved to adapt to KPI changes.
Patent Information
- Application Number
- CN202510299643.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-14
- Publication Date
- 2025-07-01
AI Technical Summary
When the prior art deploys a small timing model on the device side, the number of models is huge, the prediction efficiency is low, and the KPI changes cannot be effectively adapted to KPI changes, resulting in difficulty in practical application.
The time series model implementation method based on multi-KPI clustering is adopted, the KPI data is grouped through clustering analysis, the unified prediction historical data length and prediction length are set, a corresponding timing model is trained, and the mapping relationship is established based on the prediction effect during actual deployment, and if necessary, the online layer is allocated for poor prediction KPIs.
The number of models is reduced, the prediction efficiency is improved, the KPI changes can be adapted to the application of small timing models on the device side is significantly improved.
Smart Images

Figure CN120234637A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of computer technology and time series prediction technology, and in particular to a method, apparatus, electronic device and storage medium for implementing a time series model based on multi-KPI clustering. This method is applicable to the time series prediction scenario on the device side, can effectively process a large amount of KPI data, and provide accurate prediction results. Background Art
[0002] Time series algorithms are a series of statistical and machine learning techniques for analyzing and predicting time series data. Time series data are data points recorded in chronological order, which can be continuous, such as stock prices and temperature records, or discrete, such as monthly sales data. Common time series algorithms include: autoregressive integrated moving average (ARIMA), exponential smoothing (ES), seasonal and trend decomposition using Loess (STL), XGBoost / LightGBM, Prophet, and some deep learning models. The choice of which time series algorithm depends on the nature of the specific problem, the characteristics of the data, and the prediction goal. In practical applications, it may be necessary to try multiple algorithms and determine which algorithm performs best on a specific dataset through cross-validation.
[0003] Traditional time series algorithms include methods based on statistics, machine learning, or deep learning, etc. Among them, deep learning algorithms have better effects. They are usually algorithms based on CNN and RNN. However, these network structures cannot discover the long-term dependence characteristics between time series data points. Therefore, the long-term prediction effect is poor, and for each sequence, it is necessary to train first and then predict, resulting in low prediction efficiency. These all limit their practical applications to a certain extent.
[0004] In recent years, the emergence of Transformer technology has led to great progress in fields such as NLP and large models, and many scholars have also applied this technology to time series tasks. The self-attention mechanism of Transformer enables it to discover the regular patterns between time series data points and make better use of the long-term dependencies between data points. Therefore, many time series model algorithms based on this technology have achieved excellent prediction performance, far superior to traditional algorithms. For example, TimeGPT, TimesFM, GPT4TS, etc. These time series models have a huge number of parameters, are trained based on extensive and massive time series data, have excellent Zero-Shot capabilities, and at the same time, the inference efficiency is about a hundred times higher than that of traditional algorithms. However, due to the number of parameters, such large models can usually only be deployed on the cloud or the host side. Therefore, some time series models with fewer parameters are needed to meet the application requirements for deployment on the device side. Among them, the relatively excellent ones include: iTransformer, TimesNet, NonStationaryFormer, etc. Compared with the technology using Transformer, algorithms based on simple linear transformations have also been found to have good performance, even surpassing most open-source time series models. For example, the network structure of LTSFLinear is very simple. The network structures of these small time series models are relatively simple, with a small number of parameters, which is conducive to efficient deployment, and the prediction efficiency is also very high. However, it also severely limits their expressive ability, making their generalization ability very weak. At the same time, the size of its linear transformation is strictly limited to history length x prediction length. When the length of historical data or the prediction length changes, it must be retrained. Therefore, it is basically one-dataset-one-model, as Figure 1 shown. Moreover, due to the fact that the time series characteristics of the data during actual deployment change over time, it is necessary to retrain and load a new model every once in a while. The number of KPIs to be predicted on the device side may be very large. If small time series models are deployed and in the one-dataset-one-model manner, training a separate small time series model for each different KPI will result in a very large cost. In particular, customers may add some new KPIs for prediction. Since new time series models cannot be trained for them in a timely manner, this makes actual applications very difficult. Summary of the Invention
[0005] The purpose of the present invention is to provide a method, device, electronic device, and storage medium for implementing a time series model based on multi-KPI clustering. This method can reduce the number of models, improve the prediction efficiency, and adapt to changes in KPIs, aiming to solve the problems existing in these aspects in the prior art.
[0006] The present invention provides a method for implementing a time series model based on multi-KPI clustering, including:
[0007] (1) Perform clustering analysis on each KPI time series data on the device side, and change the application method of the time series small model from one-dataset-one-model to one-cluster-one-model, as Figure 2 shown;
[0008] (2) Analyze different KPI data and set a unified historical data length and prediction length required for prediction for them;
[0009] (3) Collect the KPI offline data of each cluster, clean and make training data, and train a corresponding time series model respectively;
[0010] (4) During actual deployment, it is necessary to establish a mapping relationship of the device according to the matching effect of the previous several predictions;
[0011] (5) Continuously evaluate the prediction results of each KPI time series data. If the prediction result of a certain KPI time series data is not good, assign an online layer to this KPI and continuously fine-tune this online layer, as Figure 3 shown.
[0012] The present invention provides an implementation device for a time series model based on multi-KPI clustering, including:
[0013] (1) A clustering analysis module, used to perform KPI data analysis on the input layer of the time series model based on multi-KPI clustering and perform clustering analysis on each KPI time series data on the device side.
[0014] (2) A model parameter setting module, used to analyze different KPI data on the input layer of the time series model based on multi-KPI clustering and set a unified historical data length and prediction length required for prediction for them.
[0015] (3) A time series model training module, used to collect the KPI offline data of each cluster, clean and make training data, and train a corresponding time series model respectively.
[0016] (4) A model deployment, inference prediction and online training module, which deploys the trained time series model based on KPI clustering, continuously evaluates the prediction results of each KPI time series data. If a certain KPI time series data is not good, assign an online layer to this KPI and continuously fine-tune this online layer.
[0017] An embodiment of the present invention further provides an electronic device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the computer program is executed by the processor, the steps of the above-mentioned implementation method of the time series model based on multi-KPI clustering are implemented.
[0018] An embodiment of the present invention further provides a computer-readable storage medium, on which an implementation program for information transmission is stored. When the program is executed by a processor, the steps of the above-mentioned implementation method of the time series model based on multi-KPI clustering are implemented.
[0019] By adopting the embodiment of the present invention, in view of these problems in the application of the time series small model on the device side, a method for implementing a time series small model based on multi-KPI clustering is proposed. Through this solution, we change the application mode of the time series small model from one-dataset-one-model to one-cluster-one-model, thus avoiding the huge overhead required for numerous KPIs; the historical data lengths and prediction lengths required for different KPI predictions are also different. By reasonably analyzing and setting unified parameters for them, the number of required models can be minimized to the greatest extent; the offline data of each cluster is used to train a corresponding time series model respectively. There is no fixed mapping relationship between this time series model and each KPI. During actual deployment, the mapping relationship of this device needs to be established according to the matching effect of the previous few predictions; the prediction results of each KPI time series data are continuously evaluated. If the prediction result of a certain KPI time series data is not good, an online layer is assigned to this KPI time series data, and the actual prediction effect of each KPI is ensured through the online layer. This solution has strong practicability and good prediction effect, and can well solve the problem of the application and implementation of the time series small model on the device side. Description of the Drawings
[0020] In order to more clearly illustrate the technical solutions in one or more embodiments of this specification or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments recorded in this specification. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0021] Figure 1 It is a schematic diagram of the model training scheme of the traditional one-dataset-one-model;
[0022] Figure 2 It is a schematic diagram of the one-cluster-one-model training scheme based on multi-KPI clustering according to the embodiment of the present invention;
[0023] Figure 3 It is a schematic diagram of the online fine-tuning network structure according to an embodiment of the present invention;
[0024] Figure 4 It is a flowchart of an implementation method of a multi-KPI time series model according to an embodiment of the present invention;
[0025] Figure 5 It is a schematic diagram of an implementation device of a multi-KPI time series model according to an embodiment of the present invention;
[0026] Figure 6 It is a schematic diagram of an electronic device according to an embodiment of the present invention. Specific embodiments
[0027] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the following will clearly and completely describe the technical solutions in one or more embodiments of this specification with reference to the accompanying drawings in one or more embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this document.
[0028] Method embodiments
[0029] According to an embodiment of the present invention, there is provided an implementation method of a time series model based on multi-KPI clustering, Figure 4 It is a flowchart of an implementation method of a time series model based on multi-KPI clustering according to an embodiment of the present invention. As Figure 4 shown, the implementation method of the time series model based on multi-KPI clustering according to an embodiment of the present invention specifically includes:
[0030] (1) Step S401: Perform clustering analysis on each KPI time series data on the device side, and change the application method of the time series small model from one-dataset-one-model to one-cluster-one-model, so as to avoid the huge overhead required by a large number of models.
[0031] There may be a large amount of KPI time series data to be predicted on the device side, and their data characteristics often vary greatly. Even for different devices, the same KPI also has significant differences. The traditional application method of time series small models is one-dataset-one-model, that is, a time series model is trained separately for each KPI time series data of each different device. For example, if there are 100 devices and each device has an average of 50 KPIs to be predicted, then 5000 time series models need to be trained in advance, which is extremely costly and obviously unrealistic. Our approach is to cluster these 5000 time series to obtain several clusters.
[0032] Time series clustering is an unsupervised learning method that groups time series data points with similar patterns or behaviors together. Its goal is to discover potential patterns in the data so that similar time series can be compared and analyzed. Here we use the Dynamic Time Warping (DTW) algorithm. DTW is a method for measuring the similarity between two time series. It allows time series to be locally stretched on the time axis, thus comparing time series with different lengths or speeds. The number of clusters can be specified in advance or automatically obtained using the Elbow Method.
[0033] (2) Step S402: The historical data lengths and prediction lengths required for different KPI predictions are also different. By reasonably analyzing and setting unified parameters for them, the number of required models can be minimized to the greatest extent.
[0034] The collection frequencies of different KPI time series data are different, usually 10s, 30s, 1min, 5min, 30min, 1hour, 1day, 1week, 1month, etc. The collection frequency on the device side is generally higher, and the common ones are 10s, 1min, 5min, 1hour, etc. Due to differences in characteristics such as collection frequency and periodic trends, the parameters such as the historical length and prediction length required for different KPI predictions often vary. Different parameters correspond to different time series models, which makes it necessary to have several different time series models for the KPIs within the same cluster, complicating the problem.
[0035] Through reasonable analysis, we set the historical length his_len of the time series model to 864 and the prediction length pred_len to 72. Correspondingly, when frequency = 5 min, it is 3 days of historical data for predicting 6 hours of future data; when frequency = 1 min, it is 14.4 hours of historical data for predicting 1.2 hours of future data; when frequency = 10 s, it is 2.4 hours of historical data for predicting 12 minutes of future data. When the frequency is low, the prediction time is longer; when the frequency is high, the prediction time is shorter. This is more in line with the actual application requirements and is a relatively reasonable setting.
[0036] (3) Step S403: Collect the offline KPI data of each cluster, clean and make training data, and train a corresponding time series model respectively
[0037] Each cluster contains multiple KPI data from different devices. Clean the offline data of these KPIs to make the training data of this cluster, and train the corresponding time series sub-model accordingly. There is no specific limitation on the time series sub-model here. It can be DLinear, iTransformer, TimesNet, NonStationalFormer, etc. They adopt self-supervised learning (SSL, Self-Supervised Learning). By using the masking method, a part of the input sequence is covered, and an attempt is made to predict these masked parts. The model is trained in this way. We train a corresponding time series model for each cluster respectively.
[0038] (4) Step S404: There is no fixed mapping relationship between the time series model and each KPI. During actual deployment, it is necessary to establish the mapping relationship between them according to the matching effect of the previous few predictions
[0039] The time series model trained in the above way has no fixed mapping relationship with each KPI. That is, it is possible that KPI_1 of Device1 belongs to Cluster1, and KPI_1 of Device2 belongs to Cluster3. When deploying these sub-models on a certain device, it is first necessary to determine which time series sub-model should be used to process each KPI of this device, that is, to establish the corresponding relationship between each KPI and the time series model.
[0040] As mentioned earlier, each time series model requires a fixed history length his_len and prediction length pred_len. In actual prediction, we require the input data length to be >= his_len + pred_len. When making the first N predictions for each KPI (for example, set N=20), first use all time series models to process the first his_len data of the input data, and calculate the error between the obtained prediction results and the pred_len data immediately following the input (his_len) data, and then use the model with the smallest error to process the his_len data of the input data (the most recent one), and the calculated result is used as the prediction result for this time. Count the number of matches of each time series model in the first N predictions of the KPI, and record the time series model with the most matches, and use it as the time series model corresponding to the KPI. For subsequent predictions, the time series model will be used directly to process the input data of the KPI.
[0041] (5) Step S405: Continuously evaluate the prediction results of each KPI time series data. If the time series data of a KPI is not good, assign an online layer to the KPI and continuously fine-tune the online layer to further improve its prediction performance.
[0042] Through the previous N predictions of each KPI, a mapping relationship between each KPI and the time series model is established. Multiple KPIs will share a time series model. The prediction accuracy of these KPIs may be accurate or have large errors. It is necessary to take further measures for KPIs with poor accuracy. Here, the prediction results of each KPI time series data are continuously evaluated. Since we require that the input length of each prediction is not less than the data length>=his_len+pred_len, according to a certain probability, we calculate the prediction error of his_len data before the input data to evaluate the KPI prediction effect. If a KPI time series data is not good, an online layer is assigned to the KPI. The online layer is defined as a linear mapping of size pred_len x pred_len. It takes the output of the time series model as input, undergoes linear mapping, and outputs the same size of output as the new prediction data. Similarly, since the input length of each prediction is>=his_len+
[0043] For pred_len, we can use the first his_len + pred_len data of the input as a training sample data. When the batch size for one training is reached, training can be carried out. During training, the parameters of the time series model are fixed, and only the parameters of this online layer are adjusted. This way enables the model to be adaptively trained for different KPIs, thereby further improving its prediction performance. Further, the system will regularly iterate and update the model parameters according to the continuous evaluation results of the model to ensure that the model can adapt to new data and changes, establish a feedback mechanism, compare the prediction results with the actual data, and continuously optimize the model performance.
[0044] Device Embodiment 1
[0045] According to an embodiment of the present invention, there is provided an implementation device for a time series model based on multi-KPI clustering. Figure 5 is a schematic diagram of an implementation device for a time series model based on multi-KPI clustering according to an embodiment of the present invention, as Figure 5 shown, the implementation device for a time series model based on multi-KPI clustering according to an embodiment of the present invention specifically includes:
[0046] (1) A clustering analysis module 50, configured to add a KPI data analysis module to the input layer of the time series model based on multi-KPI clustering, and perform clustering analysis on the time series data of each KPI on the device side.
[0047] (2) A model parameter setting module 52, configured to analyze different KPI data in the input layer of the time series model based on multi-KPI clustering, and set a unified historical data length and prediction length required for prediction for them.
[0048] (3) A time series model training module 54, configured to collect the offline data of each clustered KPI, clean and make training data, and train a corresponding time series model respectively.
[0049] (4) A model deployment, inference prediction and online training module 56, which deploys the trained time series model based on KPI clustering, continuously evaluates the prediction results of the time series data of each KPI. If the time series data of a certain KPI is not good, an online layer is assigned to this KPI, and the online layer is continuously fine-tuned. Fix the other parameters of the time series model, and only train the online adaptation layer to complete the fine-tuning training of the time series model.
[0050] The device further includes:
[0051] A data processing module, which is used to process the prediction result or historical data by means of multi-step prediction and / or length truncation when the length of the historical data of the prediction task and the prediction length do not match the input and output lengths of the time series model based on multi-KPI clustering. Specifically, the data processing module is used for:
[0052] When the prediction length of the prediction task is greater than the preset length of the algorithm, a multi-step prediction method is used to process the prediction result;
[0053] When the prediction length of the prediction task is less than or equal to the preset length of the algorithm, directly intercept the data of the required length from the front to the back in the prediction result;
[0054] When the length of the historical data of the prediction task is greater than or equal to the length of the historical data of the algorithm, directly intercept the data of the required length from the back to the front in the historical data;
[0055] When the length of the historical data of the prediction task is less than the length of the historical data of the algorithm, calculate the mean value of the historical data, supplement the length of the historical data with the mean value, and add it in front of the original historical data.
[0056] The embodiment of the present invention is a device embodiment corresponding to the above method embodiment. The specific operations of each module can be understood with reference to the description of the method embodiment, and will not be elaborated here.
[0057] Device Embodiment II
[0058] The embodiment of the present invention provides an electronic device, as Figure 6 shown, including: a memory 60, a processor 62, and a computer program stored on the memory 60 and executable on the processor 62. When the computer program is executed by the processor 62, the steps described in the method embodiment are implemented.
[0059] Device Embodiment III
[0060] The embodiment of the present invention provides a computer-readable storage medium, on which an implementation program for information transmission is stored. When the program is executed by the processor 62, the steps described in the method embodiment are implemented.
[0061] The computer-readable storage medium described in this embodiment includes, but is not limited to: ROM, RAM, magnetic disk, optical disk, etc.
[0062] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for implementing a time series model based on multi-key performance indicator (KPI) clustering, characterized in that: The following steps are involved: (1) Perform cluster analysis on the KPI time series data on the device side to form several clusters; (2) Setting uniform historical data length and prediction length parameters for each cluster; (3) Collect offline KPI data of each cluster, clean the data and produce training data; (4) Using the offline data generated in (3) to perform offline training data, train the corresponding time series model; Deploy the trained time series model on the device side and select the best matching time series model for each KPI based on the previous N prediction results of each KPI. The prediction results of each KPI time series data are continuously evaluated, and an online layer is assigned to the KPI with poor prediction effect and fine-tuned.
2. The method according to claim 1, characterized in that The cluster analysis adopts the Dynamic Time Warping (DTW) algorithm.
3. The method according to claim 1 or 2, characterized in that: The unified historical data length and forecast length parameters are set with reference to the collection frequency of the KPI.
4. The method according to claim 1, 2 or 3, characterized in that: The online layer is a linear mapping of size pred_len x pred_len, which is used to further adjust the output of the time series model, where pred_len represents the size of the "prediction length" parameter.
5. The method according to claim 1, 2, 3 or 4, characterized in that: The continuous evaluation includes calculating the prediction error of his_len (indicating the size of the "historical data length" parameter) data before the input data to determine whether to allocate an online layer for the KPI, and dynamically adjusting the parameters of the online layer according to the prediction error.
6. A device-side timing prediction system, characterized in that: include: (1) a cluster analysis module, configured to perform the cluster analysis described in claim 2; (2) a training data preparation module, configured to perform the data cleaning and training data production as described in claim 3; (3) a timing model training module, configured to perform the timing model training described in claim 4; (4) A model deployment, inference prediction and online training module, used to perform the model deployment, inference prediction and online layer fine-tuning described in claim 5.
7. A computer-readable storage medium having a computer-executable program stored thereon, the program comprising instructions for executing the method according to any one of claims 1 to 6.
8. An electronic device comprising a processor and a memory, wherein the memory stores a computer execution program, and the processor is configured to execute the program to implement the method according to any one of claims 1 to 6.