Feature selection method for traffic emission prediction
By combining feature grouping, data cleaning, and interpretability SHAP analysis, a feature selection method is proposed to solve the problem of balancing model performance, computational efficiency, and interpretability in existing technologies. This method enables efficient screening of key factors in traffic emissions and improves the stability and accuracy of the model.
Patent Information
- Application Number
- CN202411114103.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-08-14
AI Technical Summary
Existing feature selection methods struggle to balance model performance, computational efficiency, and interpretability when dealing with traffic emissions prediction, especially on high-dimensional datasets where computational costs are high and transparency is lacking.
We employ a method that combines feature grouping, data cleaning, weight initialization, in-group and out-of-group correlation calculation, Tree-enhanced model, and SHAP analysis. We use automatic and manual grouping strategies to select the optimal feature combination and combine interpretable SHAP technology to optimize the feature selection process.
It improves the efficiency and accuracy of feature selection, effectively filters out key factors affecting traffic emissions, solves the interactive effects caused by highly correlated factors, and enhances the stability and interpretability of the model.
Smart Images

Figure CN118897974A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of traffic emission prediction, and in particular relates to a feature selection method for traffic emission prediction. Background Art
[0002] Accurately predicting and analyzing the causes of traffic emissions is crucial to developing effective emission reduction strategies. However, the factors that affect traffic emissions are numerous and complex, including vehicle type, road conditions, weather conditions, fuel efficiency, etc. The existence of redundant and irrelevant features not only increases the computational complexity of model training, but may also reduce the model's prediction accuracy and generalization ability. The core of feature selection technology is to select the most representative and influential subsets from massive features, eliminate non-critical and redundant elements, and improve model performance.
[0003] Existing feature selection methods can be summarized into three categories: filtering, wrapping, and embedding. The filtering method uses statistical metrics to evaluate the correlation or dependency between features and target variables; the wrapping method regards feature selection as an optimization problem and uses the learning algorithm itself to evaluate feature subsets; the embedding method integrates feature selection into the model training process.
[0004] However, existing technologies have their own limitations: although filtering methods are computationally efficient, they may ignore complex feature interactions and fail to consider the requirements of specific learning algorithms; although packaging methods can achieve high accuracy, they are computationally expensive, especially for high-dimensional data sets; although embedding methods can perform feature selection and model training at the same time, they often rely on specific models and lack transparency in the feature selection process. In addition, existing technologies often find it difficult to strike a balance between model performance, computational efficiency, and interpretability when processing high-dimensional data. Summary of the invention
[0005] The purpose of the present invention is to provide a feature selection method for traffic emission prediction in order to overcome the defects of the above-mentioned prior art.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] The present invention provides a feature selection method for traffic emission prediction, comprising the following steps:
[0008] Step S1: Obtain a traffic emission data set, group the data set by features, and obtain different feature groups;
[0009] Step S2: Perform data cleaning process on the grouped feature groups;
[0010] Step S3: Initialize the weight of each feature of the cleaned feature group in each group;
[0011] Step S4: According to the initialization weight of each feature, the feature correlation within and between groups is calculated respectively, and the feature weight value is updated according to the calculation result;
[0012] Step S5: remove features whose feature weights are less than a first preset value, select a machine learning method based on a Tree-enhanced model to calculate the degree of correlation between the features and the target, and combine the interpretable SHAP analysis method and the model's inherent feature importance method to calculate the feature importance value, and update the feature weight according to the feature importance value;
[0013] Step S6: Execute step S5 until at least one feature is retained for each group;
[0014] Step S7: Based on the feature weights obtained in step S6, the optimal feature combination is screened out, and prediction verification of the optimal combination is performed.
[0015] Furthermore, the traffic emission data set includes vehicle type, road conditions, weather conditions, and fuel efficiency.
[0016] Furthermore, the step S1 performs feature grouping on the data set, including the following process: setting feature grouping parameters, the grouping parameters including automatic grouping and manual grouping, using manual grouping for a data set whose feature number is less than a second preset value, and using automatic grouping for a data set whose feature number is greater than or equal to the second preset value, and dividing the data set into different feature groups according to the two methods.
[0017] Furthermore, the automatic grouping process includes: naming each feature in a standardized manner, calling the API instructions of the Gemini large language model, setting prompt words, performing semantic analysis on the feature names, returning the classified text parsed into a dictionary format, mapping the features to their results based on semantic analysis, and automatically grouping the features into different groups to achieve automatic grouping of features.
[0018] Furthermore, the data cleaning process in step S2 includes: data missing detection, outlier identification, data completion and normalization processing.
[0019] Furthermore, the specific steps of step S3 include: assigning the initial weights of the key features to be retained to The initial weights of the remaining features are assigned as follows:
[0020] Furthermore, the calculation of intra-group feature correlation in step S4 includes: giving priority to the initial weights The feature is calculated, and its correlation coefficient is adjusted if it exceeds the first preset threshold. The calculation method for calculating the correlation coefficient matrix of each feature within the group is as follows:
[0021]
[0022] in, is the feature X in group j jk and X jl The correlation coefficient of X jk,i Yes X jk The jth data point of X jl,i Yes X jl The jth data point of It is feature X jk The mean of It is feature X jl is the mean of ; n is the total number of data points.
[0023] Furthermore, the inter-group feature correlation calculation in step S4 includes: calculating the initial variance inflation factor VIF value of all features, determining an appropriate VIF threshold as a criterion for removing features; finding the feature with the highest current VIF value, and if the VIF value of the feature exceeds a second preset threshold, adjusting its weight to Otherwise, stop iterating; remove The VIF values of all remaining features are recalculated based on the features. The calculation formula is as follows:
[0024]
[0025] in, It is feature X jk The coefficient of determination when performing regression using all other features.
[0026] Further, step S5 includes the following steps: retaining the feature weights obtained in step S4 as and The features are divided into training set, validation set and test set according to the first preset ratio, and then the machine learning model based on the Tree-enhanced model is used to complete the training and validation, and the feature importance value inherent in the model is calculated. The feature importance value is calculated by the SHAP analysis method, and the feature weight ranked last in the feature importance is updated to
[0027] Furthermore, step S7 includes the following steps: updating the weight of the feature according to the feature importance value calculated in step S6; sorting all weights, and screening out the feature combination that produces the best result for the prediction performance index, that is, the optimal weight combination.
[0028] Compared with the prior art, the present invention has the following advantages:
[0029] (1) The present invention comprehensively considers the contradiction between performance, computational efficiency and interpretability faced by traditional methods when processing high-dimensional data, and provides a feature selection strategy based on interpretable machine learning, which can simultaneously improve the efficiency and accuracy of feature selection;
[0030] (2) The present invention is applied in the field of assessment of factors affecting traffic emissions, and can efficiently screen out key factors affecting traffic emissions, thus solving the interactive effects caused by highly correlated factors.
[0031] (3) The present invention combines automated feature classification with interpretable SHAP technology to avoid the processing of two highly correlated features in existing feature engineering technology, that is, simple screening may lead to the loss of important information, or retaining both features to introduce noise, thereby affecting the stability of the model; BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 is a flow chart of the feature selection method of the present invention;
[0033] Figure 2 Result graph of feature screening parameter tuning. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0035] Embodiment 1:
[0036] The present invention provides a feature selection method for traffic emission prediction, comprising the following steps:
[0037] Step S1: Obtain traffic emission data set and perform feature grouping: design a feature grouping strategy that combines automatic and manual methods to systematically classify and manage various factors that affect traffic emissions;
[0038] Step S2: Data cleaning: Perform a comprehensive traffic emission input data cleaning process, including detecting and processing missing values, identifying and processing outliers, performing necessary data completion, and normalizing the data;
[0039] Step S3: feature weight initialization: assigning an initial weight value to each feature;
[0040] Step S4: multicollinearity processing: based on the feature groups divided in step S1, calculate the feature correlations within and between groups respectively, and use the calculation results to update the feature weight values;
[0041] Step S5: Feature importance calculation: Select the machine learning method based on the Tree-enhanced model XGBoost to calculate the correlation between the feature and the target, and combine the interpretable SHAP analysis method and the model's inherent feature importance method to update the feature weight;
[0042] Step S6: Iteratively update weights: Repeat iterative step S5 until at least one feature is retained for each group;
[0043] Step S7: Based on the feature weights obtained in step S6, the optimal feature combination is screened out, and prediction verification of the optimal combination is performed.
[0044] Furthermore, the step S1 includes the following sub-steps:
[0045] Step S1.1: Set the feature grouping parameter GroupType∈{"manual","automatic"};
[0046] Step S1.2: For the data set X={x 1 ,x 2 ,…,x p}, set GroupType = "manual" to use the manual grouping method, where x 1 ,x 2 ,…,x p for factors such as speed, weather, fuel type, etc.;
[0047] Step S1.3: For the data set X with a large number of factors affecting traffic emissions, set GroupType = "automatic" and use the automatic grouping method to analyze the meaning of the names of the factors affecting emissions using the natural language processing capabilities of the Gemini-api large language model. The automatic feature classification process includes:
[0048] (1) Feature naming conventions: Ensure that each feature has a descriptive and meaningful name, such as "Speed" for vehicle speed.
[0049] (2) Calling the API instructions of the Gemini large language model: setting reasonable prompt words and performing semantic analysis on feature names;
[0050] (3) The returned classified text is parsed into a dictionary format, the features are mapped to the results based on semantic analysis, and the features are automatically classified into different groups, thereby achieving automatic classification of features.
[0051] Using the above two methods, it is divided into m different feature combinations
[0052] Furthermore, the step S2 performs comprehensive cleaning and standardization processing on the input data, specifically including: data missing detection, outlier discrimination, data completion and normalization processing, and the normalization calculation method is as follows:
[0053]
[0054] Among them, X′ is the normalized eigenvalue; X is the original eigenvalue; X min , X max are the minimum and maximum values; a is the lower limit of the target interval; b is the upper limit of the target interval.
[0055] Furthermore, the step S3 specifically includes:
[0056] (1) Assign the initial weight of the key feature p to be retained as:
[0057] (2) The initial weights of the remaining features are assigned as follows:
[0058] Furthermore, the step S4 includes two sub-steps:
[0059] Step S4.1: Intra-group correlation calculation: prioritize the initial weights The correlation coefficient is calculated. If it exceeds the set threshold, its weight is adjusted to The calculation method for calculating the correlation coefficient matrix for each group is as follows:
[0060]
[0061] in, is the feature X in group j jk and X jl The correlation coefficient of X jk,i Yes X jk The jth data point of X jl,i Yes X jl The jth data point of It is feature X jk The mean of It is feature X jl is the mean of ; n is the total number of data points.
[0062] Step S4.2: Calculation of inter-group correlation: Calculate the initial variance inflation factor (VIF value) of all features, determine an appropriate VIF threshold as the standard for removing features; find the feature with the highest current VIF value, and when the VIF value of the feature exceeds the set threshold, adjust its weight to Otherwise, stop iterating; remove The VIF values of all remaining features are recalculated based on the features. The calculation formula is as follows:
[0063]
[0064] in, It is feature X jk The coefficient of determination when performing regression using all other features.
[0065] Furthermore, the step S5 includes the following sub-steps:
[0066] Step S5.1: Use the Tree-Boost model (XGBoost) to calculate the correlation between feature X and target Y: retain the feature weight obtained in step S4 as The features are divided into training set, validation set and test set in a ratio of 6:2:2, and then the machine learning model is used to complete the training and validation;
[0067] Step S5.2: Calculate the feature importance value inherent to the model: The Tree model in machine learning calculates feature importance by accumulating the average number of samples covered by the split of each feature in each tree. The calculation method is as follows:
[0068]
[0069] Among them, K 1 (X q ) is feature X q The importance value of N q is the feature X used in all trees q The number of splits (X q ) is to use the feature to X q The set of nodes for row splitting; cover(s) is the number of samples covered by node s;
[0070] Step S5.3: SHAP analysis method to calculate feature importance values: Use the TreeExplainer algorithm and the trained machine learning model to calculate the Shapley value of each feature of each sample. The calculation formula is as follows:
[0071]
[0072] Where N is the set of all features; S is a subset of N excluding feature q, f(S) is predicted using the features in subset S, and |S| is the size of subset S; is a weighting factor that ensures that all feature combinations are considered. Tree-SHAP adapts the Shapley value calculation to tree-based models by decomposing the prediction process into the sum of contributions from individual trees. The Shapley value of feature q in a tree-based model is given by:
[0073]
[0074] Where H is the number of trees, L h is the number of leaves in the tree h, is the number of samples that reach node j in tree h, is the value of feature q at node j, and is the value of the previous node of feature q.
[0075] Step S5.4: Set the scaling factor δ to balance the influence of feature splitting importance and gain importance, and calculate the feature importance value as follows:
[0076]
[0077] Among them, K(X q ) is the final normalized X q The importance value of is the normalized K 1 (X q ), is the normalized K 2 (X q ), the normalization method can refer to the calculation method in step 2, where the values of a and b are set to 0 and 0.5 respectively.
[0078] Furthermore, in step S6, an improved backward elimination strategy is used to perform multiple rounds of prediction iterations. In each round of iteration, the feature weight ranked last in feature importance is updated to -1 until the number of iterations n is less than a preset threshold nm, by comparing the performance indicators of the model under different feature combinations (such as accuracy, root mean square error, etc.).
[0079] Furthermore, the step S7 needs to be based on the feature importance value K(X q ) Update feature X q Weight All weights are sorted to select the feature combination that produces the best prediction performance indicator, that is, the optimal weight combination.
[0080] Embodiment 2:
[0081] This embodiment takes the relationship between vehicle NOx emissions (target) and influencing factors (features) as an example, and provides a feature selection method and device based on interpretable machine learning. The implementation process is as follows: Figure 1 As shown, the following steps are included:
[0082] Step S1: Design optional automatic or manual feature grouping techniques to divide features into several groups based on inter-feature correlation or domain knowledge. There are 56 influencing factors {x 1 ,x 2 ,…,x p}(feature number p=56), set the parameter to GroupType∈{"automatic"}, and select the automatic grouping method. The detailed process is as follows:
[0083] (1) Feature naming standards: Ensure that each feature has a descriptive and clear name, such as the word "speed" which directly reveals its role and meaning in the model;
[0084] (2) Calling "Gemini-api" (https: / / aistudio.google.com / app / apikey): semantic analysis of feature names and descriptions involves setting reasonable prompts and applying NLP techniques to understand the context and importance of each feature; the following is the prompt set for this patent: "prompt = Our goal is to classify pollutant emissions. The following is a list of feature names: {','.join(feature_names)}. Please divide them into no more than M categories based on their meanings and provide category names. At the same time, determine which feature(s) should be considered as the target variable (y). Return the result in the following format: 'Category 1: [Feature 1, Feature 2, ...] Category 2: [Feature 1, Feature 2, ...] Target: [Target 1, Target 2, ...]";
[0085] (3) The classified text is parsed into a dictionary format, the features are mapped to the results based on semantic analysis, and the features are automatically classified into different groups, thereby achieving automatic classification and reasonable grouping of features. In this embodiment, the features are automatically divided into 7 groups (m=7).
[0086] Step S2: Based on step S1, the input data is fully cleaned and standardized, including: data missing detection, outlier discrimination, data completion and normalization. The normalization calculation method is as follows:
[0087]
[0088] Where X′ is the value of the normalized data point; X is the value of the original data point; Xmin , X max are the minimum and maximum values in the data set; a is the lower bound of the target interval (usually 0); and b is the upper bound of the target interval (usually 1). In this embodiment, a is set to 0 and b is set to 1.
[0089] Step S3: Initialize the weight of each feature in the i-th group and assign an initial weight to each feature based on its expected contribution to the model. For features that are identified as representative by domain experts or that need to be retained due to specific needs, their initial weights are It is considered to have a significant impact on the predictive ability of the model, so it is given the highest weight. For other features that are not identified as key features, their initial weights are set Considered to contribute little to the model or have no practical significance.
[0090] Step S4: For the grouping results of step S1, this embodiment completes the screening of highly correlated features according to the following two steps: first, the intra-group correlation calculation is performed, and the features with initial weights set to 1 are given priority. For other features that are highly correlated with them (the correlation coefficient threshold is set to 0.9 in this embodiment), their weights are adjusted to -1, thereby weakening the influence of redundant features. The calculation method of the correlation coefficient matrix for each group is as follows:
[0091]
[0092] in, is the feature X in group j jk and X jl The correlation coefficient of X jk,i Yes X jk The jth data point of X jl,i Yes X jl The jth data point of It is feature X jk The mean of It is feature X jl is the mean of ; n is the total number of data points.
[0093] The second is the calculation of inter-group correlation: calculate the initial variance inflation factor (VIF value) of all features, and determine a suitable VIF threshold (the threshold is set to 10 in this embodiment) as the standard for removing features. Find the feature with the highest current VIF value. If the VIF value of the feature exceeds the preset threshold, remove it from the model. Otherwise, stop the iteration because the VIF of all features meets the requirements. After removing the feature, rebuild the model based on the updated feature set and recalculate the VIF values of all remaining features. The calculation formula is as follows:
[0094]
[0095] in, It is feature X jk The coefficient of determination when performing regression using all other features.
[0096] Step S5: Combine the SHAP method with the feature importance evaluation technology based on the XGBoost model to update the feature weights. Specifically, by setting the scaling factor δ, the result is as follows: Figure 2 As shown. Balancing the impact of feature split importance and gain importance to obtain a more comprehensive feature importance assessment, the final feature importance value is calculated as follows:
[0097]
[0098] Among them, K(X q ) is the final normalized X q The importance value of is the normalized K 1 (X q ), is the normalized K 2 (X q ), the normalization method can refer to the calculation method in step 2, where the values of a and b are set to 0 and 0.5 respectively. 1 (X q ) is the feature X calculated based on the inherent method of the model q The importance value of N q is the feature X used in all trees q The number of splits (X q ) is to use the feature to X q The set of nodes for row splitting; cover(s) is the number of samples covered by node s. 2 (X q ) is the feature X calculated based on the SHAP method q The importance value of h is the number of leaves in the tree h, n j t is the number of samples that reach node j in tree h, is the value of feature q at node j, and is the value of the previous node of feature q.
[0099] Step S6: Use the improved backward elimination strategy to perform multiple rounds of prediction iterations. In each round of iteration, the feature weight with the lowest feature importance ranking is updated to -1 until the number of iterations n is less than the preset threshold nm. By comparing the mean square error (MSE) of the model under different feature combinations.
[0100] Step S7: The feature importance value K(X) calculated in steps S5 and S6 needs to be q ) Update feature X q Weight Then all weights are sorted to screen out the feature combination that produces the best prediction performance indicator, that is, the optimal weight combination.
[0101] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A feature selection method for traffic emission prediction, characterized in that: The following steps are involved: Step S1: Obtain a traffic emission data set, group the data set by features, and obtain different feature groups; Step S2: Perform data cleaning process on the grouped feature groups; Step S3: Initialize the weight of each feature of the cleaned feature group in each group; Step S4: According to the initialization weight of each feature, the feature correlation within and between groups is calculated respectively, and the feature weight value is updated according to the calculation result; Step S5: remove features whose feature weights are less than a first preset value, select a machine learning method based on a Tree-enhanced model to calculate the degree of correlation between the features and the target, and combine the interpretable SHAP analysis method and the model's inherent feature importance method to calculate the feature importance value, and update the feature weight according to the feature importance value; Step S6: Execute step S5 until at least one feature is retained for each group; Step S7: Based on the feature weights obtained in step S6, the optimal feature combination is screened out, and prediction verification of the optimal combination is performed.
2. A feature selection method for traffic emission prediction according to claim 1, characterized in that: The traffic emission dataset includes vehicle type, road conditions, weather conditions, and fuel efficiency.
3. A feature selection method for traffic emission prediction according to claim 1, characterized in that: The step S1 groups the data set into feature groups. The method comprises the following processes: setting feature grouping parameters, wherein the grouping parameters include automatic grouping and manual grouping, adopting manual grouping for a data set whose feature number is less than a second preset value, and adopting automatic grouping for a data set whose feature number is greater than or equal to the second preset value, and dividing the data set into different feature groups according to the two methods.
4. A feature selection method for traffic emission prediction according to claim 3, characterized in that: The automatic grouping process includes: naming each feature in a standardized manner, calling the API instructions of the Gemini large language model, setting prompt words, performing semantic analysis on the feature names, returning the classified text parsed into a dictionary format, mapping the features to their results based on semantic analysis, and automatically grouping the features into different groups to achieve automatic grouping of features.
5. A feature selection method for traffic emission prediction according to claim 1, characterized in that: The data cleaning process in step S2 includes: data missing detection, outlier identification, data completion and normalization processing.
6. A feature selection method for traffic emission prediction according to claim 1, characterized in that: The specific steps of step S3 include: assigning the initial weights of the key features to be retained to The initial weights of the remaining features are assigned as follows:
7. A feature selection method for traffic emission prediction according to claim 1, characterized in that: The calculation of intra-group feature correlation in step S4 includes: giving priority to the initial weights The feature is calculated, and its correlation coefficient is adjusted if it exceeds the first preset threshold. The calculation method for calculating the correlation coefficient matrix of each feature within the group is as follows: in, is the feature X in group j jk and X jl The correlation coefficient of X jk,i Yes X jk The jth data point of X jl,i Yes X jl The jth data point of It is feature X jk The mean of It is feature X jl is the mean of ; n is the total number of data points.
8. A feature selection method for traffic emission prediction according to claim 1, characterized in that: The step S4 of calculating the inter-group feature correlation includes: calculating the initial variance inflation factor (VIF) value of all features, determining a suitable VIF threshold as a criterion for removing features; finding the feature with the highest current VIF value, and if the VIF value of the feature exceeds the second preset threshold, adjusting its weight to Otherwise, stop iterating; remove The VIF values of all remaining features are recalculated based on the features. The calculation formula is as follows: in, It is feature X jk The coefficient of determination when performing regression using all other features.
9. A feature selection method for traffic emission prediction according to claim 1, characterized in that: The step S5 comprises the following steps: retaining the feature weights obtained in step S4 as and The features are divided into training set, validation set and test set according to the first preset ratio, and then the machine learning model based on the Tree-enhanced model is used to complete the training and validation, and the feature importance value inherent in the model is calculated. The feature importance value is calculated by the SHAP analysis method, and the feature weight ranked last in the feature importance is updated to 10. A feature selection method for traffic emission prediction according to claim 1, characterized in that: The step S7 comprises the following steps: updating the weight of the feature according to the feature importance value calculated in step S6; sorting all the weights, and screening out the feature combination that produces the best result of the prediction performance index, that is, the optimal weight combination.
Citation Information
Patent Citations
Feature selection device for traffic accident analysis
CN110659820A
Doctor hospitalization service performance evaluation method and system based on case combination
CN114358618A
Network traffic classification method based on improved feature selection
CN116633867A
Charging method capable of automatically distributing control power
CN116691418A
Method for predicting DNA recombination sites based on xgboost
US20230307093A1
Cited By
Risk prediction model training method, device and equipment and risk prediction method
CN119762217A
Risk prediction model training method, device, equipment and risk prediction method
CN119762217B
