A sliding window based time series classification method and apparatus
Patent Information
- Application Number
- CN202410096522.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-24
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2044-01-24
AI Technical Summary
然而,由于变量关联度不强,捕捉相互依赖特征成为MTSC的关键挑战
[0053]本发明的一种基于滑动窗口的时序分类方法,首先检测多变量之间的相关性,然后利用时序对齐方法处理嘈杂数据,同时通过PAA和SAX联合降维来进行形状子序列去重,从而能够有效地利用高质量的形状子序列shapelets进行分类器训练。此外,该方法采用相关性分析选择多变量数据中密切相关的变量信息进行全面建模,从而将多变量时间序列数据分成组件,用于对不相关单元进行建模和对密切相关的多变量变量进行建模。提高了分类器的准确性。本发明的时序分类方法在多个关键领域展现了出色的性能,为处理复杂时序数据提供了一种高效、准确的解决方案。本发明的方法可广泛应用于医学、金融、工业等领域,为解决实际应用中的时序分类问题提供了创新性的技术支持。
Smart Images

Figure CN117909793B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of efficient time series classification technology based on sliding windows, and particularly relates to a time series classification method and apparatus based on sliding windows. Background Technology
[0002] Time series are numerical sequences arranged in chronological order. Time series classification (TSC) is one of the three key tasks in time series analysis, as important as time series forecasting and anomaly detection. This method aims to assign predefined labels or categories to each time series data point, thereby revealing underlying patterns and temporal dynamics within the data and supporting intelligent decision-making.
[0003] In the field of biomedical science, time series classification has a wide range of applications. By analyzing electrocardiogram (ECG), electroencephalogram (EEG), and respiratory data, it helps doctors identify diseases such as heart disease, epileptic seizures, and sleep disorders. In financial market analysis, time series classification of stock prices, foreign exchange market data, and other financial indicators enables investors to accurately identify market trends, predict price changes, and thus make strategic trading decisions. Environmental monitoring also benefits from time series classification. By analyzing meteorological data, air quality data, and other environmental factors, it helps to understand climate change, predict weather conditions, and monitor environmental pollution, thereby providing strong support for the development of effective environmental protection measures.
[0004] Most existing time series classification solutions focus on univariate time series data (i.e., UTS), while multivariate time series (i.e., MTS) classification can break down the MTS into multiple UTS for classification tasks. However, such a simple split can lead to poor performance in terms of accuracy and efficiency because it ignores the characteristics of MTS data (e.g., the correlations between multiple variables).
[0005] Patent document CN111814897A discloses a time series data classification method based on multi-level shapelets, including: preprocessing of time series data: performing dimensionality reduction on the original time series using the SAX method; obtaining initial subsequences of the time series: extracting a set of subsequences from the time series using a sliding window method, indirectly controlling the extraction length of subsequences by changing and adjusting the window size; discovery and extraction of multi-level shapelet candidate sets: filtering and merging the candidate sets using the proposed multi-level shapelet framework, selecting shapelets with high information gain as candidate sets; shapelet transformation and classifier construction. This method distinguishes between univariate and multivariate data, while ignoring the correlation between multiple variables, resulting in poor classification accuracy and efficiency.
[0006] To address the aforementioned issues, deep learning models are used to consider the relationships between all variables. However, not all variables in MTS data are correlated with each other, and modeling all variables is time-consuming. Therefore, few frameworks or models perform well on both UTS and MTS classification tasks. Against this backdrop, developing a classification system that supports both UTS and MTS while considering the characteristics of different time series data to improve overall performance (including accuracy and efficiency) is of paramount importance.
[0007] Although existing technologies have been researched for time series classification methods, they have at least three problems:
[0008] Q1: How can high classification performance be achieved in terms of both efficiency and accuracy? Classification methods are mainly based on the shape of time series data, but shape-based methods have high computational complexity, making it difficult to achieve high levels of accuracy and efficiency. Furthermore, time series alignment strategies improve computational efficiency but still suffer from classification accuracy issues.
[0009] Q2: How to optimize the quality of training data in classification tasks? Traditional methods are based on time series shapes, resulting in high computational complexity. Compared to traditional methods, deep learning models can achieve higher accuracy. However, it is important to note that deep learning methods require large labeled datasets for model training and fine-tuning. Therefore, achieving high performance with limited data is a challenging task.
[0010] Q3: How to effectively capture the features of multivariate time series data? Multivariate time series classification methods are divided into extended univariate methods and deep learning-based methods. The former obtains representative representations by searching or aligning multiple variables through shaped subsequences, while the latter uses vector representations to improve classification accuracy. However, due to the weak correlation between variables, capturing interdependent features has become a key challenge for MTSC. Summary of the Invention
[0011] To address the shortcomings of existing technologies, the purpose of this application is to provide a sliding window-based temporal classification method and apparatus to improve the performance of both UTS and MTS classification tasks.
[0012] According to a first aspect of this application, a time-series classification method based on a sliding window is provided, comprising:
[0013] S1. Detect the correlation between multiple variables and classify the multiple variables into correlated variables and uncorrelated variables based on the correlation results;
[0014] S2. Use the CFDTAN model to align the time series data corresponding to uncorrelated variables in univariate and multivariate models; supplement the loss function of the CFDTAN model according to the correlated variables, and use the supplemented CFDTAN model to align the time series data corresponding to the correlated variables in multivariate models.
[0015] S3. Using the sliding window technique, extract time series data features from aligned univariate and multivariate time series data, create candidate shape subsequences, and use PAA and SAX techniques to reduce the dimensionality and represent each candidate shape subsequence, removing duplicate candidate shape subsequences.
[0016] S4. The classification model is optimized and trained using the deduplicated candidate shape subsequences. The classification model includes the Bi-GRU model and the GCN-GRU model. The Bi-GRU model is trained using candidate shape subsequences corresponding to univariate data and irrelevant variable data in multivariate data. The GCN-GRU model is trained using candidate shape subsequences corresponding to relevant variable data in multivariate data.
[0017] S5. Extract subsequences from the time series data to be detected, remove duplicates, and input them into the trained classification model for classification to obtain the aggregated result.
[0018] This invention provides a sliding window-based temporal classification method that supports classification tasks for unit-based temporal series (UTS) and multivariate-based temporal series (MTS) data. The method includes: correlation analysis, temporal alignment, shapelet capture, shapelet deduplication, and temporal classification. The correlation analysis examines the direct correlations between different indicators in the multivariate data, splitting the multivariate indicators into related and irrelevant components. The temporal alignment uses an optimized CFDAN network to align unit and multivariate data. Shapelets capture key temporal shape features, better reflecting the essence of the temporal data; different sliding windows are used to prune the original sequence, obtaining shapelets of varying lengths. Shapelet deduplication utilizes PAA and SAX techniques to reduce dimensionality and remove duplicates from all shapelets, retaining the most representative ones. Based on the deduplicated shapelets, Bi-GRU and GCN-GRU models are designed according to the characteristics of unit and multivariate data respectively to achieve better classification results. This method can be widely applied in medicine, finance, industry, and other fields, providing innovative technical support for solving practical temporal classification problems.
[0019] Further, step S1 includes:
[0020] S11. Randomly sample from the time series data using a specified sampling ratio, calculate the Pearson correlation coefficient between variables in the sampled dataset, and accumulate and record variables whose correlation coefficients exceed a predefined threshold to form a correlation matrix.
[0021] S12. Based on the correlation matrix, construct an adjacency matrix, where the positions of the correlation data exceeding the threshold in the adjacency matrix are set to 1, and the remaining positions are 0;
[0022] S13. Analyze the adjacency matrix to find the largest complete subgraph in the graph;
[0023] S14. Based on the maximum complete subgraph, the variables are segmented into relevant variables and unrelated variables.
[0024] Furthermore, in step S2, the loss function of the CFDTAN model... for:
[0025]
[0026] In a single category, i.e., k=1, the goal of CFDTAN is to minimize the distortion function. The variance of the transformed time series data, at this time It is expressed as follows:
[0027]
[0028] Where X i X j These represent the i-th and j-th data points in the time series dataset X, respectively. Distribution representation for X i X j Alignment distortion function; θ i θ j These are the vectorized parameters of the twist function; This represents the combination of functions; X represents i X j In the twist function The result after the action; ||·||2 represents L2 normal form;
[0029] In the case of multiple classes, the model objective is to minimize the within-class variance of all classes. It is expressed as follows:
[0030]
[0031] Where k is the index of the class; K is the number of classes; N k It is the time series number of the k-th class; This represents the first to nth time series data X in the k-th class of the time series dataset. i y i X represents i The class tag; y k This represents the k-th class; X represents the first to nth time series data. i ;
[0032] This represents the regularization term for the first to nth time series data in the time series dataset:
[0033]
[0034] ΣCPA represents the inverse of the covariance matrix in the CPA space, where ΣCPA has two parameters: λ var Controlling overall variance and λ smooth Controlling the smoothness of the velocity field; θ i It is a twist function The vector representation of , It is θ i The transpose of .
[0035] Furthermore, in step S2, the method for supplementing the loss function of the CFDTAN model based on relevant variables is as follows: In the original CFDTAN model loss function... Add a supplementary item to the item, which represents a comparison of the correlation between variables before and after alignment, expressed by the following formula:
[0036]
[0037] in X represents the loss function before and after alignment of the correlation variables in the k-th class; i Represents the i-th multivariate time series vector; Indicates facing X i With θ i The distortion function is defined by parameters; n represents the number of data points in the k-th class. X represents i In the alignment distortion function The result after the action; Corr(X) represents the correlation coefficient after alignment of related variables. i ) represents the correlation coefficient before the relevant variables are aligned.
[0038] Further, step S3 includes:
[0039] S31. Using the sliding window technique, subsequences of different lengths are extracted from aligned univariate time series data and multivariate time series data, and labeled with the labels of the original data to create candidate shape subsequences;
[0040] S32. Use PAA and SAX methods to reduce the dimensionality of candidate shape subsequences, convert the source data into a symbol list, and use the SAX method to convert the symbol list into a two-dimensional array for deduplication.
[0041] Furthermore, after step S32, the method also includes: adjusting the scale of the sliding window and the parameters used in PAA and SAX to flexibly optimize the overall method to adapt to specific datasets and classification objectives.
[0042] Furthermore, in step S4, for the Bi-GRU model, Time2Vec is used for data processing, and training is performed using the cross-entropy loss function and the Adam optimizer.
[0043] Furthermore, in step S4, for the GCN-GRU model, a weighted adjacency matrix is constructed using the correlation matrix from step S11. The weighted adjacency matrix and the correlation variable data are input into the GCN network for data processing. The ReLU activation function is used, and the GRU network is used for training.
[0044] According to a second aspect of this application, a high-efficiency time-series classification apparatus based on a sliding window is provided for implementing the aforementioned time-series classification method, comprising:
[0045] Multivariate Correlation Detection Module: Used to detect the correlation between multiple variables and classify the multivariate into correlated and uncorrelated variables based on the correlation results;
[0046] Time series alignment module: used to align time series data corresponding to uncorrelated variables in univariate and multivariate models; supplements the loss function of the CFDTAN model according to the correlated variables, and uses the supplemented CFDTAN model to align the time series data corresponding to the correlated variables in multivariate models;
[0047] Candidate shape subsequence acquisition module: used to extract time series data features from aligned univariate and multivariate time series data, create candidate shape subsequences, perform dimensionality reduction and representation on each candidate shape subsequence using PAA and SAX techniques, and remove duplicate candidate shape subsequences;
[0048] Classification model training module: Optimizes and trains the classification model, which includes Bi-GRU model and GCN-GRU model. The Bi-GRU model is trained using candidate shape subsequences corresponding to univariate data and irrelevant variable data in multivariate data, and the GCN-GRU model is trained using candidate shape subsequences corresponding to relevant variable data in multivariate data.
[0049] Detection module: Extracts subsequences from the time series data to be detected, removes duplicates, and inputs them into a trained classification model for classification to obtain aggregated results.
[0050] According to a third aspect of this application, a computer device is provided, including a processor and a memory for storing a processor-executable program, characterized in that, when the processor executes the program stored in the memory, it implements the timing classification method.
[0051] According to a fourth aspect of this application, a computer-readable storage medium is provided, storing a program, characterized in that, when the program is executed by a processor, it implements the timing classification method.
[0052] Compared with the prior art, the present invention has the following beneficial effects:
[0053] This invention presents a sliding window-based time series classification method. First, it detects the correlation between multiple variables. Then, it uses a time series alignment method to process noisy data. Simultaneously, it employs PAA and SAX joint dimensionality reduction to remove duplicate shapelets, thereby effectively utilizing high-quality shapelets for classifier training. Furthermore, this method uses correlation analysis to select closely related variables in the multivariate data for comprehensive modeling, thus dividing the multivariate time series data into components for modeling unrelated units and closely related multivariate variables. This improves the accuracy of the classifier. The time series classification method of this invention demonstrates excellent performance in several key areas, providing an efficient and accurate solution for processing complex time series data. This method can be widely applied in fields such as medicine, finance, and industry, providing innovative technical support for solving time series classification problems in practical applications. Attached Figure Description
[0054] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It should be understood that the foregoing general description and the following detailed description are exemplary and illustrative only and are not intended to limit the scope of this application.
[0055] Figure 1 This is a flowchart illustrating a time-series classification method based on a sliding window, as shown in the embodiment.
[0056] Figure 2 This is a flowchart illustrating a time-series classification method based on a sliding window, as shown in the embodiment.
[0057] Figure 3 This is a flowchart illustrating the detection of correlations between multivariate variables, as shown in the embodiment.
[0058] Figure 4 This is a flowchart illustrating time series data alignment in an embodiment.
[0059] Figure 5 This is a flowchart illustrating the generation of high-quality shapelets in an embodiment.
[0060] Figure 6 This is a flowchart illustrating the unit and multi-dimensional data classification process in the embodiment.
[0061] Figure 7 This is an efficient time-series classification device based on a sliding window, as shown in the embodiment. Detailed Implementation
[0062] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application.
[0063] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed films.
[0064] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0065] like Figure 1 and Figure 2 As shown in the figure, the time series classification method based on a sliding window illustrated in this embodiment includes the following steps:
[0066] S1. Detect the correlation between multiple variables and classify the multiple variables into correlated variables and uncorrelated variables based on the correlation results;
[0067] S2. Use the CFDTAN model to align the time series data corresponding to uncorrelated variables in univariate and multivariate models; supplement the loss function of the CFDTAN model according to the correlated variables, and use the supplemented CFDTAN model to align the time series data corresponding to the correlated variables in multivariate models.
[0068] S3. Using the sliding window technique, extract time series data features from aligned univariate and multivariate time series data, create candidate shape subsequences, and use PAA and SAX techniques to reduce the dimensionality and represent each candidate shape subsequence, removing duplicate candidate shape subsequences.
[0069] This embodiment uses a sliding window to generate candidate shapelets to better capture the features of time series data. To improve the quality of the training dataset, PAA and SAX techniques are used to efficiently represent each shapelet through dimensionality reduction, followed by further removal of duplicates.
[0070] S4. The classification model is optimized and trained using the deduplicated candidate shape subsequences. The classification model includes the Bi-GRU model and the GCN-GRU model. The Bi-GRU model is trained using candidate shape subsequences corresponding to univariate data and irrelevant variable data in multivariate data. The GCN-GRU model is trained using candidate shape subsequences corresponding to relevant variable data in multivariate data.
[0071] This embodiment designs a classification model based on the unique features present in the UTS and MTS datasets. A Bi-GRU model is designed for single-cell data, and a GCN-GRU model is designed for multivariate data. The classification model is trained using deduplicated shapelets.
[0072] S5. Extract subsequences from the time series data to be detected, remove duplicates, and input them into the trained classification model for classification to obtain the aggregated result.
[0073] This application provides a sliding window-based time series classification method. First, it detects the correlation between multiple variables. Then, it uses a time series alignment method to process noisy data. Simultaneously, it employs PAA and SAX joint dimensionality reduction to remove duplicate shapelets, thus effectively utilizing high-quality shapelets for classifier training. Furthermore, this method uses correlation analysis to select closely related variables in the multivariate data for comprehensive modeling, thereby dividing the multivariate time series data into components for modeling unrelated units and closely related multivariate variables. This method improves the accuracy of the classifier.
[0074] In the specific implementation of step S1, the correlation between multivariate variables is first detected. Before this, the data will be preprocessed, such as filling missing values with the mean. These variables are then divided into two categories: correlated variables and uncorrelated variables. Uncorrelated variables are subsequently treated similarly to UTS during the modeling process.
[0075] Specifically, such as Figure 3 As shown, this step may include the following sub-steps:
[0076] Step S11: Construct the correlation matrix. In this step, random samples are taken from the time series data according to a specified sampling ratio, and then the Pearson correlation coefficients between the variables in the sampled dataset are calculated. Variables with correlation coefficients exceeding a predefined threshold are recorded to form the correlation matrix.
[0077] Step S12: Based on the correlation matrix, construct an adjacency matrix, where the positions of relevant data exceeding a threshold are set to 1, and the remaining positions are set to 0. The goal of this step is to reveal the relationships between variables in the dataset.
[0078] In its implementation, the input consists of multivariate time series data D, a sampling ratio (sample_ratio), a correlation coefficient threshold (corr_val), the number of data points (n), and the data dimension (c). First, the algorithm randomly samples TS data based on the specified sampling ratio (represented by the number of selections), and simultaneously obtains the sampled TS data according to the sampling ratio. Second, the algorithm initializes two matrices, corr_mat and adj_mat, with c rows and columns. For each TS data point in the sampled dataset, the algorithm calculates the Pearson correlation coefficient between its variables. The algorithm identifies the indices corresponding to the variables with correlation coefficients exceeding a predefined threshold (corr_val) and increments the values of the correlation matrix at these positions. Based on this, the algorithm creates an adjacency matrix (represented as adj_mat), where the positions corresponding to the proportion of correlated data exceeding the threshold in the total sampled dataset are set to 1, and all other positions are set to 0. The diagonal values in the adjacency matrix are always set to 0.
[0079] Step S13: Perform maximum complete subgraph analysis. Analyze the adjacency matrix obtained in the previous step to find the maximum complete subgraph in the graph. A maximum complete subgraph is a set of nodes in a graph where every two nodes are connected by an edge. This indicates the existence of a highly correlated set of variables in the data, forming the maximum complete subgraph. This process helps identify association patterns and clusters in the data.
[0080] Step S14: Variable segmentation. By analyzing the correlation matrix, the variables in the data are divided into two groups: correlated variables and uncorrelated variables. This is achieved by aggregating correlated variables and separating uncorrelated variables. This segmentation allows for a deeper understanding of the data structure, identifying which variables are closely related and which are relatively independent, providing a foundation for further analysis and modeling.
[0081] In the specific implementation of step S2, to mitigate the negative impact of sampling frequency and outliers, an advanced time series alignment (TTN) model is used to process the UTS and MTS. When processing the MTS, the loss function is optimized for the relevant variables of the MTS.
[0082] Specifically, such as Figure 4 As shown, this step may include the following sub-steps:
[0083] Step S21: For the time series data corresponding to the UTS data and the uncorrelated variables in the multivariate dataset, the CFDTAN method was used to align the time series data;
[0084] Specifically, within a single category (k=1), the goal of CFDTAN is to minimize the distortion function. Variance of the transformed time series data:
[0085]
[0086] Where X i X j These represent the i-th and j-th data points in the time series dataset X, respectively. Distribution representation for X i X j Alignment warp function (where θ) i θ j (These are the vectorized parameters of the twist function); This represents the combination of functions, therefore X represents i X j In the twist function The result after the action; ||·||2 represents the L2 normal form.
[0087] In the case of multiple classes, the model objective is to minimize the within-class variance of all classes.
[0088]
[0089] Where k is the index of the class, K is the number of classes, and N is the number of classes. k It is the time series number of the k-th class, for This represents the first to nth time series data X in the k-th class of the time series dataset. i y i X represents i The class tag, y k This represents the k-th class. X represents the first to nth time series data. i .
[0090] The regularization term of the distortion function applies to both multi-class and single-class applications:
[0091]
[0092] in This represents the regularization term for the first to nth time series data in the time series dataset; ΣCPA represents the inverse of the covariance matrix in the CPA (Continuous Piecewise Affine) space, where ΣCPA has two parameters: λ var Controlling overall variance and λ smooth Controlling the smoothness of the velocity field; θ i It is a twist function The vector representation of , It is θ i The transpose of .
[0093] The overall loss function is:
[0094]
[0095] Step S22: For the relevant variable data in the MTS data, the loss function of the CDTAN model is expanded and enhanced by integrating the relationships between variables. The supplementary term in the loss function considers the dependencies and interactions between relevant variables, thereby improving the alignment of time series data corresponding to relevant variables in the MTS data.
[0096] Specifically, for MTS data, considering the dependencies and interactions between relevant variables, this embodiment adds a supplementary loss function term to enhance the alignment process of multi-time series (MTS) data. The supplementary loss function term represents a comparison of the correlations between variables before and after alignment:
[0097]
[0098] Where X i Represents the i-th multivariate time series vector; Indicates facing X i With θ i The distortion function is defined by parameters; n represents the number of data in the k-th class. This represents the loss function before and after alignment of the correlation variables in the k-th class; X represents i In the alignment distortion function The result after the action; Corr(X) represents the correlation coefficient after alignment of related variables. i The ) represents the correlation coefficient before the relevant variables are aligned.
[0099] Therefore, the loss function It was added to the original basis. This item:
[0100]
[0101] In the specific implementation of step S3, the sliding window technique is used to extract features from the time series data and create shapelets. Simultaneously, PAA and SAX techniques are employed to reduce the dimensionality of each shapelet, effectively representing and removing duplicates.
[0102] Specifically, such as Figure 5 As shown, this step may include the following sub-steps:
[0103] Step S31: Generate candidate shape subsequences using a sliding window technique. Extract subsequences of different lengths from the aligned UTS and MTS data and label them with the labels from the original data.
[0104] Specifically, firstly, by using sliding windows of different scales, we extract subsequences of varying lengths from aligned UTS and MTS data and label them with the original data labels. For example, the StandWalkJump dataset includes twelve sets of MTS training data. Each set includes four observation channels, with 2500 data points per channel (i.e., dimensions 12*2500*4). The four channels in the StandWalkJump dataset include two relevant channels and two irrelevant channels. To generate shape subsequence candidates, we used sliding windows with scales of 0.6, 0.4, and 0.2. Through this process, we obtained 90 shape subsequence candidates with dimensions of 10*1500*2, 10*1000*2, 10*500*2, 20*1500*1, 20*1000*1, and 20*500*1, respectively.
[0105] Step S32: Dimensionality reduction and representation using PAA and SAX methods. PAA and SAX techniques are used to reduce the dimensionality of the time series data and convert the source data into a list of symbols. The data represented by SAX is organized into a two-dimensional array, where each row represents a data segment; PAA and SAX techniques are used to remove duplicate extracted candidate shape subsequences to improve computational efficiency.
[0106] Furthermore, after step S32, the method also includes: adjusting parameters, adjusting the scale of the sliding window and the parameters used in PAA and SAX, to flexibly optimize the overall method to adapt to specific datasets and classification objectives.
[0107] In the specific implementation of step S4, the classification model is trained using the deduplicated shape subsequences. A Bi-GRU model is designed to handle univariate data, and a GCN-GRU model is designed to handle multivariate data, including:
[0108] Specifically, such as Figure 6 As shown, this step may include the following sub-steps:
[0109] S41: For candidate shape subsequences corresponding to univariate data and uncorrelated variable data in multivariate data, a dedicated Bi-GRU model is used, with Time2Vec for data processing, and training is performed using the cross-entropy loss function and the Adam optimizer.
[0110] Specifically, n shape subsequence candidates of different lengths are taken as input and padded to the maximum length t of all shape subsequences. Next, Time2Vec is used to embed the padded data into a vector space, generating data of dimension [n, t, h], where h represents the size of the embedding space. After padding, the embedded data may contain many irrelevant padding values that could potentially affect model performance. To mitigate this effect, both padded and unpadded data are used to pack these redundant padding values. The data is then processed and fed into a bidirectional gated recurrent unit (Bi-GRU) network. This network is equipped with hidden states in both the forward and backward directions, enabling it to capture contextual information from the input sequence. The bidirectional hidden outputs (i.e., dimension [n, 2h]) are merged into a ReLU layer, and then the model's output is generated using fully connected layers (i.e., Linear). This output is further converted into a probability distribution using a softmax function. Finally, the classifier is trained by applying a cross-entropy loss function and the Adam optimizer.
[0111] S42: For candidate shape subsequences corresponding to the relevant variable data in multivariate data, a dedicated GCN-GRU model is used. A weighted adjacency matrix is constructed using the Pearson correlation matrix, the data is processed through the GCN network, the ReLU activation function is used, and finally the GRU network is used for training.
[0112] Specifically, GCN-GRU constructs a weighted adjacency matrix using the Pearson correlation matrix among multiple variables built in S21. It samples a certain proportion of data from the dataset, calculates a correlation coefficient for each data point, sets a correlation threshold, and uses the proportion of variables whose correlation coefficients exceed the threshold as weights. This weight, along with the correlated variable data, is then used as input to the Graph Convolutional Network (GCN) model, similar to Time2Vec used in UTS classifiers. If the input is [n,c,t] dimensional data (where c represents the dimension of the correlated variables), the output encoded data is [n,t,h] dimensional, where h represents the size of the vector space generated by GCN encoding. GCN-GRU better serves the TSC task by integrating multivariate data, extracting richer information. A ReLU activation function is applied after the encoder GCN to introduce non-linear properties. Next, similar to the Bi-GRU model, padding data is applied before feeding the data into the GRU network to avoid the effects of padding. This invention uses a multi-layer GRU network to obtain a more complex representation of multivariate data, where the number of layers is an adjustable parameter.
[0113] The time series classification method in this embodiment demonstrates excellent performance in several key areas, providing an efficient and accurate solution for processing complex time series data. It can be widely applied in fields such as medicine, finance, and industry, and provides innovative technical support for solving time series classification problems in practical applications.
[0114] Taking the medical field as an example, when observing a disease, multiple indicators are typically measured for changes. For instance, in Alzheimer's disease, sensors are used to detect changes in the hippocampus, amygdala, anterior lobe, prefrontal cortex, and parietal lobe over a period of time. These data changes are used to determine whether someone has Alzheimer's disease. This problem can be addressed using the time-series classification method proposed in this embodiment. Specifically: First, data from the hippocampus, amygdala, anterior lobe, prefrontal cortex, and parietal lobe are collected from the brains of different patients every week for one year to construct a dataset; then, the data in the dataset is processed, including the following steps:
[0115] (a) First, use correlation detection methods to determine which parts are closely related and which parts are unrelated. For example, the hippocampus and amygdala are strongly correlated, but they are not strongly correlated with the anterior lobe;
[0116] (b) Based on the results of correlation detection, the correlated variables (hippocampus and amygdala) and the uncorrelated variables (data from other parts) are time-aligned to avoid the influence of some noisy data on the overall sequence.
[0117] (c) The aligned data is cropped and deduplicated using sliding windows of different proportions;
[0118] (d) Finally, the Bi-GRU model and the GCN-GRU model are used for training.
[0119] In application, for new patient data, data from a certain period of time is cropped, deduplicated, and finally classified using Bi-GRU and GCN-GRU models. The aggregated results are used to comprehensively determine whether the patient has Alzheimer's disease, thus providing a comprehensive and effective method for the diagnosis of Alzheimer's disease.
[0120] To verify the effectiveness of the classification model of this invention, this embodiment compares it with 11 classification models on 20 UCR unit time-series datasets and 16 UEA multivariate time-series datasets. These datasets are divided into training and test sets. The model is trained using the training set, and then the classification performance is compared using the test set. The classification accuracy and training time of the model are calculated.
[0121] The method in this embodiment was compared with mainstream unit classification models and multivariate classification models in terms of classification accuracy for both unit time-series and multivariate time-series data. Table 1 shows the results on 20 unit time-series datasets, and Table 2 shows the results on 16 multivariate time-series datasets. For unit time-series data, this embodiment outperformed all other classification models on 9 out of 20 datasets. Furthermore, in 1-on-1 comparisons, the method in this embodiment showed superior performance compared to other classification models on more than half of the datasets. For multivariate time-series data, Table 2 shows that this embodiment demonstrated a clear advantage on 8 out of 16 datasets. Similarly, in 1-on-1 comparisons, the method in this embodiment showed better performance than other classification models on more than half of the datasets. These comparative results demonstrate the significant advantages of the method in this embodiment when handling time-series data classification tasks, whether for unit or multivariate time-series data.
[0122] The method in this embodiment is compared with mainstream unit classification models and multivariate classification models in terms of model training time for both unit time-series and multivariate time-series data. Table 3 shows the comparison results of the training time (mimute) between the method described in this embodiment and mainstream unit classification models. It can be seen that the training time of the method proposed in this embodiment is shorter than that of mainstream classification models on most datasets. Table 4 shows the comparison results of the training time (mimute) between the method described in this embodiment and mainstream multivariate classification models. Similarly, it can be seen that the training time of the method proposed in this embodiment is shorter than that of models such as ShapeNet, MLSTM, and TapNet on most datasets. Although it is weaker than those models designed for efficiency, such as TST and DSN, the method proposed in this embodiment has an advantage in accuracy.
[0123] This embodiment also provides an efficient time-series classification device based on a sliding window, used to implement the above-mentioned time-series classification method, such as... Figure 7 As shown, it includes the following modules:
[0124] Multivariate Correlation Detection Module: Used to detect the correlation between multiple variables and classify the multivariate into correlated and uncorrelated variables based on the correlation results;
[0125] Time series alignment module: used to align time series data corresponding to uncorrelated variables in univariate and multivariate models; supplements the loss function of the CFDTAN model according to the correlated variables, and uses the supplemented CFDTAN model to align the time series data corresponding to the correlated variables in multivariate models;
[0126] Candidate shape subsequence acquisition module: used to extract time series data features from aligned univariate and multivariate time series data, create candidate shape subsequences, perform dimensionality reduction and representation on each candidate shape subsequence using PAA and SAX techniques, and remove duplicate candidate shape subsequences;
[0127] Classification model training module: Optimizes and trains the classification model, which includes Bi-GRU model and GCN-GRU model. The Bi-GRU model is trained using candidate shape subsequences corresponding to univariate data and irrelevant variable data in multivariate data, and the GCN-GRU model is trained using candidate shape subsequences corresponding to relevant variable data in multivariate data.
[0128] Detection module: Extracts subsequences from the time series data to be detected, removes duplicates, and inputs them into a trained classification model for classification to obtain the aggregated result.
[0129] This embodiment also provides a computer device, including a processor and a memory for storing processor-executable programs, characterized in that, when the processor executes the program stored in the memory, it implements the timing classification method.
[0130] This embodiment also provides a computer-readable storage medium storing a program, characterized in that, when the program is executed by a processor, it implements the time-series classification method.
[0131] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0132] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.
[0133] Table 1 compares the classification accuracy of the model in this embodiment with that of mainstream unit classification models.
[0134]
[0135] Table 2 compares the classification accuracy of the model in this embodiment with mainstream multivariate classification models.
[0136]
[0137] Table 3 compares the training time (mimute) of the model in this embodiment with that of mainstream unit classification models.
[0138] ElectricDevices 109.29 5.36 43.933 — 7.96 FordA 67.83 26.8 18.6 1034.85 9.766 ShapeletSim 5.95 0.58 0.816 14.42 0.98 BeetleFly 2.29 0.22 0.8333 14.33 1.21 FaceAll 11.25 1.03 2.867 183.29 2.81 WormsTwoClass 5.67 1.12 1.4833 62.96 2.06 Yoga 20.98 7.05 1.416 90.93 12.01 ECG200 2.38 1.2 0.85 33.88 2.61 Small Kitchen Appliances 11.62 2.68 2.517 122.33 11.37
[0139] Table 4 compares the training time (mimute) of the model in this embodiment with that of mainstream multi-class classification models.
[0140] AtrialFibrillation 20.383 13.2 0.16 0.83 0.966 0.71 FingerMovements 973.12 4.4 0.11 4.97 1.6688 24.54 SelfRegulationSCP2 1540.56 15.6 1.3 39.97 3.378 59.83 BasicMotions 38.23 3.3 0.05 1.27 0.8559 1.25 Cricke 805.126 14.7 0.83 23.69 1.9544 22.98 Epilepsy — 6.8 0.25 4.55 1.0344 2.59 MotorImager — 54.1 2.03 — 2.1043 —
Claims
1. A time-series classification method based on a sliding window, characterized in that, Includes the following steps: S1. Detect the correlation between multiple variables and classify the multiple variables into correlated variables and uncorrelated variables based on the correlation results; S2. Use the CFDTAN model to align the time series data corresponding to uncorrelated variables in univariate and multivariate variables; The loss function of the CFDTAN model is supplemented based on relevant variables, and the supplemented CFDTAN model is used to align the time series data corresponding to the relevant variables in the multivariate model. The loss function of the CFDTAN model for: Within a single category, the goal of CFDTAN is to minimize the error through the twist function. The variance of the transformed time series data, at this time It is expressed as follows: in , These represent time series datasets. X The Middle , Data items; , Distribution representation for , Alignment distortion function; , These are the vectorized parameters of the twist function; This represents the combination of functions; , express , In the twist function , The result after the action; ||·||2 represents L2 normal form; In multiple categories, the model objective is to minimize the within-class variance of all classes. It is expressed as follows: in It is the index subscript of the class; K It is the number of classes; It is the first The number of time series in each class; Represents the first time series dataset The first to the second of each class Time series data , express Class tags; Indicates the first Each class; Indicates the first to the second Time series data ; Represents the first to the last in the time series dataset Regularization terms for time series data: represent CPA The inverse of the covariance matrix in space, where There are two parameters: Controlling overall variance and Controlling the smoothness of the velocity field; It is a twist function The vector representation of , yes Transpose of; The method for supplementing the loss function of the CFDTAN model based on relevant variables is as follows: In the original CFDTAN model's loss function... Add a supplementary item to the item, which represents a comparison of the correlation between variables before and after alignment, expressed by the following formula: in Indicates the first Loss functions before and after alignment of correlation variables in each class; Indicates the first A multivariate time series vector; Indicates orientation by A twist function with parameters; express In the alignment distortion function The result after the action; This represents the correlation coefficient after the relevant variables are aligned. This represents the correlation coefficient before the relevant variables were aligned; S3. Using the sliding window technique, extract time series data features from aligned univariate and multivariate time series data, create candidate shape subsequences, and use PAA and SAX techniques to reduce the dimensionality and represent each candidate shape subsequence, removing duplicate candidate shape subsequences. S4. The classification model is optimized and trained using the deduplicated candidate shape subsequences. The classification model includes the Bi-GRU model and the GCN-GRU model. The Bi-GRU model is trained using candidate shape subsequences corresponding to univariate data and irrelevant variable data in multivariate data. The GCN-GRU model is trained using candidate shape subsequences corresponding to relevant variable data in multivariate data. S5. Extract subsequences from the time series data to be detected, remove duplicates, and input them into the trained classification model for classification to obtain the aggregated result.
2. The time-series classification method according to claim 1, characterized in that, Step S1 includes: S11. Randomly sample from the time series data using a specified sampling ratio, calculate the Pearson correlation coefficient between variables in the sampled dataset, and accumulate and record variables whose correlation coefficients exceed a predefined threshold to form a correlation matrix. S12. Based on the correlation matrix, construct an adjacency matrix, where the positions of the correlation data exceeding the threshold in the adjacency matrix are set to 1, and the remaining positions are 0; S13. Analyze the adjacency matrix to find the largest complete subgraph in the graph; S14. Based on the maximum complete subgraph, the variables are segmented into relevant variables and unrelated variables.
3. The time-series classification method according to claim 1, characterized in that, Step S3 includes: S31. Using the sliding window technique, subsequences of different lengths are extracted from aligned univariate time series data and multivariate time series data, and labeled with the labels of the original data to create candidate shape subsequences; S32. Use PAA and SAX methods to reduce the dimensionality of candidate shape subsequences, convert the source data into a symbol list, and use the SAX method to convert the symbol list into a two-dimensional array for deduplication.
4. The time-series classification method according to claim 1, characterized in that, In step S4: For the Bi-GRU model, Time2Vec is used for data processing, and training is performed using the cross-entropy loss function and the Adam optimizer.
5. The time-series classification method according to claim 2, characterized in that, In step S4: For the GCN-GRU model, a weighted adjacency matrix is constructed using the correlation matrix from step S11. The weighted adjacency matrix and the correlation variable data are input into the GCN network for data processing. The ReLU activation function is used, and the GRU network is used for training.
6. A high-efficiency time-series classification device based on a sliding window, used to implement the time-series classification method according to any one of claims 1-5, characterized in that, include: Multivariate Correlation Detection Module: Used to detect the correlation between multiple variables and classify the multivariate into correlated and uncorrelated variables based on the correlation results; Time series alignment module: used to align time series data corresponding to uncorrelated variables in univariate and multivariate datasets; The loss function of the CFDTAN model is supplemented based on relevant variables, and the supplemented CFDTAN model is used to align the time series data corresponding to the relevant variables in the multivariate model. Candidate shape subsequence acquisition module: used to extract time series data features from aligned univariate and multivariate time series data, create candidate shape subsequences, perform dimensionality reduction and representation on each candidate shape subsequence using PAA and SAX techniques, and remove duplicate candidate shape subsequences; Classification model training module: Optimizes and trains the classification model, which includes Bi-GRU model and GCN-GRU model. The Bi-GRU model is trained using candidate shape subsequences corresponding to univariate data and irrelevant variable data in multivariate data, and the GCN-GRU model is trained using candidate shape subsequences corresponding to relevant variable data in multivariate data. Detection module: Extracts subsequences from the time series data to be detected, removes duplicates, and inputs them into a trained classification model for classification to obtain aggregated results.
7. A computer device comprising a processor and a memory for storing a processor-executable program, characterized in that, When the processor executes the program stored in the memory, it implements the timing classification method according to any one of claims 1-5.
8. A computer-readable storage medium storing a program, characterized in that, When the program is executed by the processor, it implements the time-series classification method as described in any one of claims 1-5.
Citation Information
Patent Citations
Time series data classification method based on multi-level shape
CN111814897A