A local interpretation method for time series regression models based on Lime algorithm

Through the improved Lime algorithm, the timing data is sliced ​​and neighborhood data processed, feature weights are calculated and line charts are drawn, which solves the problem of interpreting the timing data regression model and improves the interpretability and production guidance capabilities of the model.

CN117909682BActive Publication Date: 2025-08-19ZHEJIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410028443.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-09
Publication Date
2025-08-19
Estimated Expiration
2044-01-09

AI Technical Summary

Technical Problem

Existing machine learning methods are difficult to effectively interpret the prediction results of time series data regression models, and cannot judge the characteristics and time periods that have the greatest impact.

Method used

The local interpretation method of the timing regression model improved by the Lime algorithm is drawn by slicing the timing data, generating neighborhood data, fitting the interpretation model, and calculating feature weights.

Benefits of technology

The interpretation and analysis of time series data is realized, which can guide the adjustment of production parameters and improve the interpretability and generalization ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117909682B_ABST
    Figure CN117909682B_ABST
Patent Text Reader

Abstract

The present invention discloses a local interpretation method for a time series regression model based on the Lime algorithm, which belongs to the field of machine learning technology. It includes: obtaining a time series data set and a label in a business scenario, wherein the time series data in the time series data set is multi-feature dimension data; using the time series data set in the business scenario to train a time series data regression model, the trained time series data regression model can output a prediction result based on the input time series data, and generate an explanation for the prediction result; the generation of an explanation for the prediction result refers to generating sub-features that have a greater impact on the prediction result, and generating features that have the greatest impact on the prediction result; drawing a positive and negative correlation line graph of the impact of the most influential feature on the prediction result at each time interval. The present invention can realize the interpretation and analysis of time series data, obtain the time period and its features that have the greatest impact on the prediction result, and can be used to guide the adjustment of production parameters in the corresponding business scenario.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of machine learning, and in particular relates to a local interpretation method of a time series regression model based on the Lime algorithm. Background Art

[0002] In recent years, people have put forward higher requirements for machine learning predictions. Not only high prediction accuracy is required, but model interpretability is also crucial. Interpretability can help understand how each feature affects the prediction results and then adjust the parameters. Interpretable machine learning is even more important for the industrial world that needs to adjust parameters to control yield.

[0003] Many methods have been proposed to explain machine learning model predictions, including Permutation Feature Importance, Partial Dependency Plots, Individual Conditional Expectation, Local Interpretable Model-Agnostic Explanation (LIME), and SHapley Additive Explanation (SHAP). However, most of these methods are currently limited to interpretable analysis of data without the added time dimension and are unable to explain the prediction results of time series data regression models. Summary of the Invention

[0004] To address the above problems, the present invention proposes a local interpretation method for time series regression models based on the Lime algorithm. It improves on the traditional lime method to achieve local interpretation of the time series data regression model, determine the features and time periods that have the greatest impact on the prediction results, and then guide parameter adjustment.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is as follows:

[0006] In a first aspect, the present invention proposes a local interpretation method for a time series regression model based on the Lime algorithm, comprising:

[0007] Obtain a time series data set and labels for a business scenario, where the time series data in the time series data set is multi-feature dimension data;

[0008] Use the time series data set in the business scenario to train the time series data regression model. The trained time series data regression model can output prediction results based on the input time series data and generate explanations for the prediction results.

[0009] Generating explanations for the prediction results refers to generating sub-features that have the greatest impact on the prediction results, and generating features that have the greatest impact on the prediction results; and drawing a positive and negative correlation line graph of the impact of the feature with the greatest impact on the prediction results at each time interval.

[0010] Furthermore, the generating of sub-features that have the greatest impact on the prediction results and the generating of features that have the greatest impact on the prediction results include:

[0011] 1) Selecting a time series data sample to be analyzed from the time series data set;

[0012] 2) Slice the selected time series data sample and generate some disturbed neighborhood data near the sliced time series data sample;

[0013] 3) Fitting an explanatory model using the generated neighborhood data;

[0014] 4) Using the trained fitting model to generate prediction results for the selected time series data samples;

[0015] 5) Calculate the sub-feature weights by comparing the true labels of the selected time series data samples with the predicted results generated by the interpretation model. The sub-feature weights refer to the weights of each feature in each slice.

[0016] 6) Normalize the multi-feature weights in all slices corresponding to the selected time series data samples, and select the first several sub-features in descending order of the absolute value of the weight, which are recorded as X i,j , represents feature j in the i-th slice; and, calculate the sum of the absolute values of the weights of each feature in each slice, and take the feature with the largest sum as the feature with the greatest impact on the prediction result.

[0017] Furthermore, the step 2) includes:

[0018] 2.1) Slicing the selected time series data samples;

[0019] 2.2) Randomly select one or more slices and replace the elements of the selected slices with the average value of the elements of the remaining unselected slices or random noise to generate the neighborhood data after a disturbance;

[0020] 2.3) Repeat step 2.2) several times to ensure that each slice is selected and generate some disturbed neighborhood data.

[0021] Furthermore, in step 3), the labels of the neighborhood data required for fitting the explanatory model are generated by the trained time series data regression model.

[0022] Furthermore, the explanatory model is a linear regression model.

[0023] Furthermore, the calculation of the sub-feature weights in step 5) is implemented based on the Lime algorithm, and the sub-feature weights are an N*M matrix, where N represents the number of slices of the selected time series data sample, and M represents the number of features of the selected time series data sample.

[0024] Furthermore, the drawing of a positive and negative correlation line graph showing the impact of the most influential feature on the prediction result at each time interval includes:

[0025] 7) For the feature that has the greatest impact on the prediction result, draw a first line graph based on its value in all slices of the selected time series data sample;

[0026] 8) Calculate the mean of the values of the most influential feature in the slices corresponding to the same time period of the unselected time series data samples, draw a second line graph, and superimpose it on the first line graph;

[0027] 9) According to the weight and positive / negative value of the most influential feature in all slices of the selected time series data sample, different time periods are marked with different colors. The colors are used to reflect the weight and positive / negative value, and a positive / negative correlation line graph is obtained to show the positive / negative correlation of the most influential feature on the prediction results at each time interval.

[0028] In a second aspect, the present invention proposes a local interpretation system for a time series regression model based on the Lime algorithm, comprising:

[0029] A data acquisition module is used to acquire time series data sets and labels in business scenarios. The time series data in the time series data sets are multi-feature dimension data.

[0030] The Lime-based time series data interpreter is used to train a time series data regression model using a business scenario's time series data set. The trained time series data regression model can output prediction results based on the input time series data and generate explanations for the prediction results.

[0031] The mapping module is used to map the explanation of the prediction results to the corresponding time period and features, and draw a positive and negative correlation line chart of the impact of the most influential features on the prediction results at each time interval.

[0032] Furthermore, the Lime-based time series data interpreter includes:

[0033] The perturbation unit is used to slice the selected time series data samples, randomly select one or more slices, replace the elements of the selected slices with the average value of the elements of the remaining unselected slices or random noise, and generate the perturbed neighborhood data. This is repeated several times to ensure that each slice is selected, and generate the perturbed neighborhood data.

[0034] A regressor training unit, which is used to fit the explanatory model using the generated neighborhood data, and generate prediction results for the selected time series data samples using the trained fitting model;

[0035] The weight calculation unit is used to calculate the sub-feature weight by comparing the true label of the selected time series data sample and the difference between the prediction result generated by the explanation model. The sub-feature weight refers to the weight of each feature in each slice.

[0036] The beneficial effects of the present invention are as follows: the local interpretation method of the time series regression model proposed in the present invention can realize the interpretation and analysis of time series data, obtain the time period and its characteristics that have the greatest impact on the prediction results, and can be used to guide the adjustment of production parameters in corresponding business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 Schematic diagram of the framework structure of a local interpretation method for a time series regression model based on the Lime algorithm according to an embodiment of the present invention;

[0038] Figure 2 1 is a flow chart of a local interpretation method for a time series regression model based on the Lime algorithm according to an embodiment of the present invention;

[0039] Figure 3 is a weight graph according to a specific example shown in an embodiment of the present invention;

[0040] Figure 4 It is a maximum characteristic curve diagram under a specific example shown in an embodiment of the present invention. DETAILED DESCRIPTION

[0041] The following description is provided to disclose the present invention so that those skilled in the art can implement the present invention.

[0042] The accompanying drawings are merely schematic illustrations of the present invention and are not necessarily drawn to scale. Some of the blocks shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0043] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all steps. For example, some steps may be decomposed, while some steps may be combined or partially combined, so the actual execution order may change according to actual circumstances.

[0044] like Figure 1As shown, the present invention improves on the traditional lime method and creates a Lime-based time series data interpreter and mapper, wherein the Lime-based time series data interpreter is used to interpret the prediction results of the time series data regression model and provide local interpretable results of the prediction results.

[0045] Specifically, the functions of the Lime-based time series data interpreter include: initializing the Lime-based time series data interpreter object according to the given exponential kernel width, whether to print the local prediction value of the linear model, the category name list, the feature selection method, the signal name list and other parameters. When interpreting time series data, the exponential kernel is used to calculate the feature weight (traditional Lime method) to determine the importance of each feature to the prediction result. The Lime-based time series data interpreter The Lime-based time series data interpreter can also include other parameters related to time series data analysis according to specific needs, such as the number of slices for each signal, whether it is multivariate, etc. The Lime-based time series data interpreter mainly includes the following important components:

[0046] (1) Initialization module, which is used to initialize the Lime-based time series data interpreter object, set parameters such as the exponential kernel width, whether to print the local prediction value of the linear model, the category name list, the feature selection method and the signal name list.

[0047] The initialization module is included in the traditional Lime method and will not be described here.

[0048] (2) The perturbation unit first determines the dimension and length of the time series data, and then calculates the number of data points contained in each slice based on the specified number of slices. Then, the slices to be removed from the time series data are randomly selected and the channels to be perturbed are selected. For each time series data, the elements at the corresponding positions are set to 0 based on the randomly selected slices and channels to simulate removing the slices from the time series data. For the removed slices (i.e., the slices with elements set to 0), the values of these slices are replaced with random noise or the average value of the entire sequence.

[0049] (3) A regressor training unit, which is used to fit the explanatory model using the generated neighborhood data after generating the neighborhood data, and to generate prediction results for the selected time series data samples using the trained fitting model.

[0050] (4) A weight calculation unit, which is used to calculate the sub-feature weight by comparing the true label of the selected time series data sample and the difference between the prediction result generated by the explanation model. The sub-feature weight refers to the weight of each feature in each slice.

[0051] In summary, the Lime-based time series data interpreter generates neighborhood data related to the prediction results of a given time series data by randomly removing slices in the time series and replacing them with replacement values. This neighborhood data will be used in the subsequent interpretation process.

[0052] The mapper maps the interpretation results of the Lime-based time series data interpreter back to the corresponding feature names of the time series data. Specifically, the mapper maps the interpretation of the prediction result to the corresponding time period and feature, and draws a line chart showing the positive and negative correlation between the most influential feature and the prediction result at each time interval.

[0053] In summary, the Lime-based time series data interpreter is used to interpret and explain the prediction results of time series data. The mapper, on the other hand, maps the interpretation results back to the feature names of the time series data. The introduction of the Lime-based time series data interpreter and mapper enables the Lime model to be used in time series data regression models, significantly improving the generalization ability of the Lime model.

[0054] like Figure 1 As shown, in a specific implementation of the present invention, the above method is described and its operation results are disclosed using a time series data set of sensors in a manufacturing cabin in an integrated circuit manufacturing scenario.

[0055] First, a random time series dataset X is generated from the sensor timing within the manufacturing chamber in an integrated circuit manufacturing scenario. Its size is (100, 4, 30), representing 100 time series data samples, 30 sampling points per time series data sample, and 4 sampling features (four types of sensor data). Each sample is given a label and named y, representing the deposition thickness after the deposition process. The four features are named "chan_0," "chan_1," "chan_2," and "chan_3," respectively.

[0056] Next, the time series data regression model is packaged using the Pipeline structure and named clf. This model consists of two key components: a preprocessing component and a regression component. The preprocessing component obtains the initial dataset and pre-processes it into a format compatible with the regression component. This component is used before passing the time series data to the regression component. The regression component uses a time series forest regressor.

[0057] Then, based on the time series data set X and its sample labels, the time series data regression model is trained, and the trained model results are saved as clf itself, named testlime function, which can perform interpretable analysis on the trained model and the selected points to be analyzed and output relevant image results. At the same time, the time series data sample X[0] to be analyzed is selected, that is, the first of the 100 sample data, and the neighborhood data after disturbance is generated near the selected sample. Based on the neighborhood data after disturbance, an explanatory model is fitted, and the explanatory model usually selects an interpretable linear model (such as a linear regression model). The labels required for fitting the explanatory model are generated by the trained regression model, that is, the neighborhood data after disturbance is input into the trained regression model, and the regression results are used as labels for fitting the explanatory model.

[0058] Then, the fitted explanatory model is used to predict the original time series data to obtain the prediction results of the corresponding explanatory model. The weight of each sub-feature is calculated by comparing the difference between the true label of the original time series data and the prediction results generated by the explanatory model. The implementation process of obtaining feature weights based on the difference between labels and prediction results can be based on the traditional Lime implementation, which will not be repeated here. The final weight matrix is an n*4 matrix, where 4 represents the number of features and n represents the number of slices of a time series data sample. In this embodiment, n=20. The calculated feature weights are normalized to map them to the range of 0 to 1, and the weight image is drawn, as shown in the figure. Figure 3 As shown in the figure, the top 15 sub-features are selected in descending order of absolute value. Figure 3 The resulting graph is briefly explained. For example, the element "11-chan_3" with the largest weight value indicates that, of the 15 features being analyzed, the fourth feature has the greatest impact on the regression results at the 12th time slice. A negative value indicates that an increase in that feature leads to a decrease in the regression prediction value, i.e., a negative correlation, while a positive value indicates a positive correlation.

[0059] Next, we expect to obtain a certain feature, for which the sum of the absolute values of the weights brought by it is the largest. This means that in the production process, the feature with the greatest influence can be obtained, and whether the feature is properly controlled will directly affect the final production results and quality. In order to achieve the above goals, for the 20*4 weight matrix, the columns represent features and the rows represent the corresponding time intervals. For this example, the 12th column represents the 12th time interval. After finding the absolute value of the entire weight matrix, sum the rows, and then find the row corresponding to the maximum sum value to find the feature with the greatest influence on the regression prediction results. In this example, the feature with the greatest influence on the regression prediction results is the fourth feature, namely "chan_3". For this feature, the data curve of the sample to be analyzed is drawn. Figure 4The blue line is shown in the middle, and the mean of the feature in other samples is plotted as a green line.

[0060] In order to more clearly demonstrate the positive and negative correlation of the most influential feature on the prediction results at each time interval, this embodiment uses the axvspan function in the matplotlib (a library function for drawing images in the Python language) library (axvspan is a function in the Matplotlib library used to draw vertical color blocks on a graph. A vertical color block refers to a horizontal area drawn in the x-axis direction of the graph, which can be used to highlight a specific area. One of the important parameters is alpha, which is used to set the transparency of the vertical color block. The default value is 1) to draw it as the background. If the background is red, it means that the time interval of the feature has a negative correlation with the regression prediction result. If the background is green, it means that the time interval of the feature has a positive correlation with the regression prediction result. It is worth mentioning that in order to make the image more prominent, when setting the alpha in the axvspan function, it is modified to 10 times the weight to make the image contrast more obvious.

[0061] Finally, it is not difficult to find that through the local interpretation method of the time series regression model based on the Lime algorithm proposed in this invention, the entire time series data is divided into a certain number of time slices, which can determine the impact of which feature in which specific time period on the regression result. At the same time, by combining the weight matrices based on different time periods, the most important features corresponding to the time series data can be intuitively plotted. Then, based on the most important features, a curve chart of the specific data can be drawn. Not only can the specific positive and negative correlations brought about by each time interval on the most important feature be intuitively seen through the colors, but the degree of correlation can also be reflected through the depth of the colors.

[0062] The above examples are merely specific embodiments of the present invention. Obviously, the present invention is not limited to the above examples, and many variations are possible. All variations that can be directly derived or imagined by a person skilled in the art from the disclosure of the present invention should be considered to be within the scope of protection of the present invention.

Claims

1. A local interpretation method for time series regression models based on the Lime algorithm, characterized in that: include: Obtain a time series data set and labels for a business scenario, where the time series data in the time series data set is multi-feature dimension data; The time series data set in the business scenario is a time series data set of sensors in a manufacturing cabin in an integrated circuit manufacturing scenario; Use the time series data set in the business scenario to train the time series data regression model. The trained time series data regression model can output prediction results based on the input time series data and generate explanations for the prediction results. Generating explanations for the prediction results refers to generating sub-features that have the greatest impact on the prediction results, and generating features that have the greatest impact on the prediction results; Draw a positive and negative correlation line chart of the most influential features' impact on the prediction results at each time interval; including: 1) Selecting a time series data sample to be analyzed from the time series data set; 2) Slice the selected time series data samples and generate some disturbed neighborhood data near the sliced time series data samples; during the disturbance, randomly select one or more slices, replace the elements of the selected slices with the average value of the elements of the remaining unselected slices or random noise, and generate the disturbed neighborhood data once. Repeat this process multiple times to ensure that each slice is selected and generate some disturbed neighborhood data; 3) Fitting an explanatory model using the generated neighborhood data; 4) Using the trained fitting model to generate prediction results for the selected time series data samples; 5) Calculate the sub-feature weights by comparing the true labels of the selected time series data samples with the predicted results generated by the interpretation model. The sub-feature weights refer to the weights of each feature in each slice. 6) Normalize the multi-feature weights in all slices corresponding to the selected time series data samples, and select the first several sub-features in descending order of the absolute value of the weight, which are recorded as X i,j , represents feature j in the i-th slice; and, calculate the sum of the absolute values of the weights of each feature in each slice, and take the feature with the largest sum as the feature with the greatest impact on the prediction result; 7) For the feature that has the greatest impact on the prediction result, draw a first line graph based on its value in all slices of the selected time series data sample; 8) Calculate the mean of the values of the most influential feature in the slices corresponding to the same time period of the unselected time series data samples, draw a second line graph, and superimpose it on the first line graph; 9) According to the weight and positive / negative value of the most influential feature in all slices of the selected time series data sample, different time periods are marked with different colors. The colors are used to reflect the weight and positive / negative value, and a positive / negative correlation line graph is obtained to show the positive / negative correlation of the most influential feature on the prediction results at each time interval.

2. The local interpretation method of the time series regression model based on the Lime algorithm according to claim 1, characterized in that: In step 3), the labels of the neighborhood data required for fitting the explanatory model are generated by the trained time series data regression model.

3. The local interpretation method of the time series regression model based on the Lime algorithm according to claim 1 or 2, characterized in that: The explanatory model is a linear regression model.

4. The local interpretation method of the time series regression model based on the Lime algorithm according to claim 1, characterized in that: The calculation of the sub-feature weights in step 5) is implemented based on the Lime algorithm, and the sub-feature weights are an N*M matrix, where N represents the number of slices of the selected time series data sample, and M represents the number of features of the selected time series data sample.

5. A local interpretation system for a time series regression model based on the Lime algorithm, used to implement the method of claim 1, characterized in that the system include: A data acquisition module is used to acquire time series data sets and labels in business scenarios. The time series data in the time series data sets are multi-feature dimension data. The Lime-based time series data interpreter is used to train a time series data regression model using a business scenario's time series data set. The trained time series data regression model can output prediction results based on the input time series data and generate explanations for the prediction results. A mapper is used to map the explanation of the prediction results to the corresponding time period and features, and draw a positive and negative correlation line chart of the most influential features on the prediction results at each time interval.

6. The local interpretation system of the time series regression model based on the Lime algorithm according to claim 5, characterized in that: The Lime-based time series data interpreter includes: The perturbation unit is used to slice the selected time series data samples, randomly select one or more slices, replace the elements of the selected slices with the average value of the elements of the remaining unselected slices or random noise, and generate the perturbed neighborhood data. This is repeated several times to ensure that each slice is selected, and generate the perturbed neighborhood data. A regressor training unit, which is used to fit the explanatory model using the generated neighborhood data, and generate prediction results for the selected time series data samples using the trained fitting model; The weight calculation unit is used to calculate the sub-feature weight by comparing the true label of the selected time series data sample and the difference between the prediction result generated by the explanation model. The sub-feature weight refers to the weight of each feature in each slice.