A dynamic truck scale measurement method with automatic parameter fitting
By real-time recording and predicting vehicle weight using a decision tree model, the problem of traditional methods being unable to reflect dynamic weight changes in real time is solved, efficient and accurate vehicle weight measurement is achieved, manual intervention and errors are reduced, and the efficiency of traffic management and safety monitoring is improved.
Patent Information
- Application Number
- CN202411868999.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2044-12-18
AI Technical Summary
Traditional vehicle weight measurement methods rely on static weighing equipment, which cannot reflect the weight changes of vehicles during dynamic driving in real time. Existing weight prediction models are difficult to effectively capture the complex nonlinear relationship between vehicle characteristics and weight, resulting in insufficient prediction accuracy and unable to meet the needs of modern traffic management and safety monitoring.
By recording vehicle weight, speed, and model data in real time, a decision tree model is built for prediction. The model is retrained when the error exceeds a threshold. Data cleaning and feature extraction are used to improve data quality. One-Hot Encoding is used to process categorical variables. The optimal features and thresholds are selected for data segmentation to establish an adaptive prediction system.
It significantly improves the accuracy of vehicle weighing, reduces manual intervention and operational errors, improves work efficiency, ensures that the model maintains efficient prediction capabilities in a changing environment, and reduces manpower and time costs.
Smart Images

Figure CN119884540B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of dynamic vehicle scale measurement with automatic parameter fitting, and in particular to a dynamic vehicle scale measurement method with automatic parameter fitting. Background Art
[0002] Traditional vehicle weight measurement methods typically rely on static weighing equipment, which is not only time-consuming but also fails to reflect real-time weight changes during dynamic driving. Furthermore, existing weight prediction models are often based on relatively simple linear regression or rule-based models, which struggle to effectively capture the complex nonlinear relationship between vehicle characteristics and weight. This results in insufficient prediction accuracy, failing to meet the demands of modern traffic management and safety monitoring. Toll collection systems, widely used at highway toll booths in my country, rely on dynamic truck scales. To ensure accurate billing, these scales must undergo regular mandatory calibration.
[0003] Dynamic truck scales are outdoor measuring instruments. Calibrators need to carry laptop computers to debug instrument parameters and record raw data on site. However, on-site data recording is greatly affected by environmental factors, and laptop computers face many challenges when used on site, mainly manifested in:
[0004] 1. In summer, direct sunlight causes the screen to reflect light. Even if the screen brightness is adjusted to the maximum, sometimes it is difficult to clearly see the recorded form content;
[0005] 2. In other seasons, weather conditions such as wind, sand, rain, and snow may affect the performance of the laptop and even cause malfunctions, making it unusable.
[0006] The current calibration process requires manual participation in multiple links, consuming a lot of manpower and material resources. In particular, in terms of data recording, the current calibration process involves manual operations in multiple links, resulting in a waste of manpower and material resources. Calibrators need to manually record the measurement data of dynamic vehicle scales and enter these data into the management system. This recording and entry process is not only cumbersome, but also prone to errors, increasing the risk of data processing.
[0007] By predicting vehicle weight in real time, this invention significantly improves prediction accuracy, keeping errors within a set threshold. This not only enhances the effectiveness of traffic safety monitoring but also provides data support for road maintenance, enabling better prediction of road load conditions and reducing road damage caused by overloading. Furthermore, with continuous model updates and optimization, the system's predictive capabilities will be gradually enhanced to adapt to different vehicles and driving conditions, achieving more accurate weight monitoring.
[0008] The above information disclosed in this Background section is only for enhancement of understanding of the background of the present disclosure and therefore it may contain information that does not form the prior art that is already known to a person of ordinary skill in the art. Summary of the Invention
[0009] The purpose of the present invention is to provide a dynamic vehicle scale measurement method with automatic parameter fitting to solve the problems raised in the above background technology.
[0010] To achieve the above object, the present invention provides the following technical solutions:
[0011] A dynamic vehicle scale measurement method with automatic parameter fitting, comprising the following steps:
[0012] Step 1: Record the weight, speed, and vehicle type data of the monitored vehicle passing the weighing platform in real time. Collect the weight, speed, and vehicle type data of the monitored vehicle passing the weighing platform during the historical period. Clean and extract the collected weight and speed data to obtain the vehicle's characteristic data.
[0013] Step 2: Build a decision tree model, use the historical vehicle feature data to be monitored, including weight, speed and vehicle model data, as a training set, and the corresponding vehicle actual weight data as a label, and input it into the decision tree model for training;
[0014] Step 3: Input the real-time recorded weight, speed, and vehicle type data of the monitored vehicle as it passes the weighing platform into the trained decision tree model to predict the actual vehicle weight data;
[0015] Step 4: Based on the error between the actual vehicle weight data predicted by the model and the actual weight data of the vehicle weighing, determine whether this error exceeds the set error threshold and retrain the model.
[0016] Furthermore, the historical time period for collecting vehicle data to be monitored is set as T. During this T time period, each vehicle passing through the weighing platform is continuously monitored. For each vehicle, the moment it passes through the weighing platform, that is, the timestamp t ij Record the following information: the instantaneous weight W of the i-th vehicle when it passes the weighing platform for the jth time ij , the instantaneous speed V of the i-th vehicle when it passes the weighing platform for the jth time ij , the vehicle type classification C obtained by the vehicle type recognition system for the i-th vehicle at the j-th time ij , organize these data into a data set D:
[0017] D={(t ij ,W ij ,V ij ,C ij )|i=1,2,…,n,j=1,2,…,ni}
[0018] Where n represents the total number of vehicles passing through the weighing platform within the time period T, n i represents the number of times the weight, speed and vehicle model data of the i-th vehicle are monitored in the time period T;
[0019] Get the minimum and maximum weight data of each vehicle passing the weighing platform during the T time period:
[0020] W min =min(W ij |i=1,2,…,n,j=1,2,…,n i )
[0021] W max =max(W ij |i=1,2,…,n,j=1,2,…,n i )
[0022] Among them, for each car, if W ij <W min or W ij >W max , it is considered as an outlier and removed;
[0023] Get the minimum and maximum speed data of each vehicle passing the weighing platform during the T time period:
[0024] V min =min(V ij |i=1,2,…,n,j=1,2,…,n i )
[0025] V max =max(V ij |i=1,2,…,n,j=1,2,…,n i )
[0026] Among them, for each car, if V ij <V min or V ij >V max , it is considered as an outlier and removed;
[0027] The method for real-time recording the weight, speed and vehicle type data of the monitored vehicle when it passes the weighing platform is as follows: db Record data to form a data set:
[0028] D r ={(t db , W r,db , V r,ab , C r,db)|d=1,2,…,m,b=1,2,…,m d}
[0029] Among them, m represents the total number of vehicles recorded during the monitoring period, m d Indicates the number of times the weight, speed and vehicle model data of the d-th vehicle are monitored within the time period T.
[0030] Furthermore, the instantaneous weight W when passing through the weighing platform during the T time period is ij , calculate the instantaneous weight W of all vehicles ij The mean value W m :
[0031]
[0032] in, Indicates the total number of monitoring times of the effective weight of all vehicles after removing outliers;
[0033] Calculate the deviation of each vehicle's weight from the mean and select the weight with the largest deviation from the mean. For the i-th vehicle, calculate the deviation of the weight from the mean at each weighing:
[0034] D ij =|W ij -W m |
[0035] Among them, D ij represents the deviation of the i-th vehicle at the j-th weighing;
[0036] Then for the i-th vehicle, find the number of weighings j that leads to the maximum deviation:
[0037] j i =argmax(D ij )for all i
[0038] Among them, j i represents the index of the weighing that causes the largest deviation in the i-th vehicle;
[0039] By finding the index j i , select the corresponding weight as the dynamic parameter W s :
[0040]
[0041] Among them, W s represents the weight with the largest deviation from the mean;
[0042] At the selected vehicle index j i The speed of the weighing that leads to the largest deviation is extracted as follows:
[0043]
[0044] Among them, V s represents the speed of the weighing that leads to the largest weight deviation in the i-th vehicle;
[0045] Extract the vehicle model classification at the same weighing:
[0046]
[0047] Among them, C s Indicates the vehicle type classification that leads to the largest weight deviation in the i-th vehicle;
[0048] The extracted dynamic weight, speed, and vehicle type are classified and organized into a feature dataset:
[0049] F={(W s , V s , C s )}
[0050] Where F represents the feature dataset, which contains the selected weight, speed and vehicle type classification data.
[0051] Furthermore, the feature dataset F is standardized to eliminate the influence caused by different dimensions between features:
[0052]
[0053] Among them, F' is the standardized feature data, and F is the original feature data;
[0054] μ is the mean of the characteristic data, and its calculation formula is:
[0055]
[0056] Among them, u represents the number of samples of feature data, F a represents the eigenvalue of the ath sample;
[0057] σ is the standard deviation of the characteristic data, and its calculation formula is:
[0058]
[0059] Among them, (F a -μ) 2 represents the square of the difference between each sample and the mean;
[0060] When the decision tree processes categorical data, One-Hot Encoding can convert categorical variables into numerical form. Suppose the vehicle type classification C sThere are three categories: SUV, sedan, and truck. Through one-hot encoding, each category is represented by a separate binary column of 0 or 1. These categories are represented as:
[0061]
[0062] Each row corresponds to a category, allowing the model to treat each category as a different input feature;
[0063] Use the vehicle weight recorded in the historical data as the label vector Y:
[0064] Y={W o |o=1,2,…,O}
[0065] Where O represents the number of vehicles, W o is the actual weight of the oth vehicle;
[0066] At each node, select a feature f to divide the data, use the mean square error (MSE) as the division criterion, evaluate the division effect of each node, and calculate the mean square error of the current node R:
[0067]
[0068] Among them, M R Indicates the number of samples of the current node R, W o represents the true weight of the o-th sample, Represents the predicted weight of the current node R, which is the mean of all samples in the node:
[0069]
[0070] The decision tree starts from the root node, recursively selects the best feature f and divides the data into the left subset D according to the partitioning criteria left and right subset D right , with p representing the index of the sample being examined:
[0071] D left ={(F′ p , Y p )|F′ p,f ≤threshold}
[0072] Among them, the left subset contains all samples whose feature f value is less than or equal to a certain threshold threshold, F' p represents the standardized feature vector of the pth sample, Y p represents the target variable of the p-th sample;
[0073] D right ={(F′ p , Yp )|F′ p,f >threshold}
[0074] Among them, the right subset contains all samples whose feature f values are greater than a certain threshold threshold.
[0075] Further, calculate the left subset D after feature f is divided left and right subset D right The mean square error of:
[0076]
[0077] Among them, M left and M right is the number of samples in the left and right subsets, and are the predicted weights of the left and right subsets;
[0078] Taking into account the mean square error before and after division, the overall mean square error is calculated:
[0079]
[0080] Among them, MSE split is the overall mean square error of the current partition, which represents the weighted average of the prediction errors after the data is partitioned by a certain feature and threshold. R is the total number of samples in the current node, that is, the sum of the number of samples in the left child node and the right child node, that is, M R =M left +M right , MSE left and MSE right are the mean square errors of the left and right child nodes, respectively, indicating the mean square error between the sample prediction value and the true value in the left and right child nodes;
[0081] Select the best split feature and threshold, and select the one with the minimum MSE for all features and their possible split points. split The characteristic f * and threshold * :
[0082]
[0083] Among them, f * The best feature to be selected is the feature that can most effectively reduce the mean square error, threshold * is the optimal threshold selected to divide the feature f * The value of is chosen so that the overall mean square error is minimized after division. argmin represents the operation of finding the features and thresholds that minimize the mean square error.
[0084] Further, create child nodes according to the feature f * and threshold * Partitioning is performed, and samples that meet the conditions will be divided into the left child node R left , samples that do not meet the conditions will be divided into the right child node R right , for each child node R left and R right , repeat the above operation until the stop condition is reached;
[0085] During the training process, decide when to stop splitting: when the number of samples of the current leaf node is less than the preset minimum number of samples, stop splitting; when the depth of the tree reaches the preset maximum depth, stop splitting; when the mean square error of the node is small enough, stop splitting;
[0086] When the stopping condition is reached, the current node becomes a leaf node and stores the predicted value of the node. The predicted value is usually the mean of the node samples:
[0087]
[0088] in, is the predicted value of the current leaf node, indicating the predicted result of the sample corresponding to the leaf node, M leaf is the number of samples of the current leaf node, W o is the true target value of the oth sample in the current leaf node;
[0089] Based on the real-time monitored data, construct feature data:
[0090] F r ={(W r,s , V r,s , C r,s )}
[0091] Input the standardized feature data into the trained decision tree model X to predict the actual weight of the vehicle:
[0092]
[0093] in, represents the actual weight of the model's prediction of the real-time input feature, F' r It is the standardized feature data;
[0094] The calculation process of the decision tree model X:
[0095]
[0096] Among them, each corresponds to the leaf node Leaf k The predicted value of .
[0097] Further, the actual vehicle weight data predicted and the actual weighed vehicle weight W are calculated. actual The error E between:
[0098]
[0099] Then define an acceptable error threshold ∈ and check whether the calculated error E exceeds the set error threshold ∈: If E>∈, the model needs to be retrained;
[0100] Retraining the model requires collecting new sample data since the model prediction, including new feature data and corresponding actual weight data, and merging the newly collected data with the original training data to form a larger training dataset D train,up :
[0101] D train,up =D train ∪{(F new , W actual )}
[0102] Using the updated dataset D trian,up Retrain the decision tree model X, following the previous training process: feature selection, partitioning, and generating leaf nodes:
[0103] X(F′ r )=Train(D train,up )
[0104] During the training process, the decision tree model is retrained with the updated training data set to rebuild the model structure. After retraining, an independent validation set is used to evaluate the model effect and calculate the prediction error of the new model:
[0105]
[0106] Compute the absolute error of the new model:
[0107]
[0108] The above steps ensure that the error of the new model is lower than the error of the old model and is within an acceptable range.
[0109] Compared with the prior art, the present invention has the following beneficial effects:
[0110] By recording and analyzing vehicle weight, speed, and vehicle model data in real time and using a decision tree model for prediction, this method effectively reduces errors introduced by human factors and the external environment in traditional methods, thereby significantly improving vehicle weighing accuracy. This method automatically records, processes, and analyzes data, reducing the need for manual intervention and the error rate associated with manual operation, making dynamic vehicle scale calibration more efficient and reliable.
[0111] Cleaning and feature extraction of collected data helps improve data quality and ensure the effectiveness of the training set. This process enables the model to more accurately identify and utilize vehicle characteristics, thereby improving prediction results. Automated measurement and data processing processes reduce the workload of testers, saving time and labor costs, and improving overall work efficiency. By determining the error between the predicted and actual values, if the error exceeds a set threshold, the system automatically retrains the model. This adaptive adjustment mechanism ensures that the model maintains efficient prediction capabilities under changing environmental conditions.
[0112] The present invention effectively solves common technical problems in dynamic vehicle weighing: real-time data collection and feature extraction improve the timeliness and effectiveness of data; the establishment of a decision tree model enhances the ability to process complex data; real-time prediction reduces manual intervention and improves work efficiency; and the error judgment and model optimization mechanism ensure the long-term stability and accuracy of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0113] Figure 1 Schematic diagram of the overall method of the present invention. DETAILED DESCRIPTION
[0114] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to specific embodiments.
[0115] It should be noted that, unless otherwise defined, the technical or scientific terms used in the present invention should have the usual meanings understood by people with ordinary skills in the field to which the present invention belongs. The "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative position relationships. When the absolute position of the object being described changes, the relative position relationship may also change accordingly.
[0116] Example:
[0117] See also Figure 1 , the present invention provides a technical solution:
[0118] A dynamic vehicle scale measurement method with automatic parameter fitting, comprising the following steps:
[0119] Step 1: Record the weight, speed, and vehicle type data of the monitored vehicle passing the weighing platform in real time. Collect the weight, speed, and vehicle type data of the monitored vehicle passing the weighing platform during the historical period. Clean and extract the collected weight and speed data to obtain the vehicle's characteristic data.
[0120] Set the historical time period for collecting vehicle data to be monitored as T. During this T time period, continuously monitor each vehicle passing through the weighing platform. For each vehicle, the moment it passes through the weighing platform, that is, the timestamp t ij Record the following information: the instantaneous weight W of the i-th vehicle when it passes the weighing platform for the jth time ij , the instantaneous speed V of the i-th vehicle when it passes the weighing platform for the jth time ij , the vehicle type classification C obtained by the vehicle type recognition system for the i-th vehicle at the j-th time ij , organize these data into a data set D:
[0121] D={(t ij , W ij ,V ij , C ij )|i=1,2,…,n,j=1,2,…,n i}
[0122] Where n represents the total number of vehicles passing through the weighing platform within the time period T, n i represents the number of times the weight, speed and vehicle model data of the i-th vehicle are monitored in the time period T;
[0123] t ij W represents the timestamp when the i-th vehicle passes the weighing platform for the jth time, recording the specific time information of each weighing; ij ,V ij Reflecting the weight and speed of the vehicle at a specific time and conditions, these dependent variables can indicate the state of the vehicle. For example, a larger W ij It may indicate that the vehicle is heavily loaded or the vehicle classification has changed; timestamp t ij and vehicle type classification C ij Affects W ij ,V ijFor example, the speed of a vehicle of the same model at a certain moment may be proportional to its weight, and a greater speed may lead to a change in weight data;
[0124] Get the minimum and maximum weight data of each vehicle passing the weighing platform during the T time period:
[0125] W min =min(W ij |i=1,2,…,n,j=1,2,…,n i )
[0126] W max =max(W ij |i=1,2,…,n,j=1,2,…,n i )
[0127] Among them, for each car, if W ij <W min or W ij >W max , it is considered an outlier and is eliminated, which may indicate data collection errors or vehicle overload. The formula is used to find the minimum and maximum weight of all vehicles in the time period T to help determine the normal range;
[0128] Get the minimum and maximum speed data of each vehicle passing the weighing platform during the T time period:
[0129] V min =min(V ij |i=1,2,…,n,j=1,2,…,n i )
[0130] W max =max(V ij |i=1,2,…,n,j=1,2,…,n i )
[0131] Among them, for each car, if V ij <V min or V ij >V max , it is considered an outlier and is eliminated. The formula is used to determine the speed range of all vehicles to ensure the validity and reliability of the data. If the speed exceeds the range, it may indicate an abnormal driving state of the vehicle;
[0132] The method for real-time recording the weight, speed and vehicle type data of the monitored vehicle when it passes the weighing platform is as follows: db Record data to form a data set:
[0133] D r ={(tdb ,W r,db ,V r,db ,C r,db )|d=1,2,…,m,b=1,2,…,m d}
[0134] Among them, m represents the total number of vehicles recorded during the monitoring period, m d represents the number of times the weight, speed, and vehicle type data of the d-th vehicle were monitored in time period T;
[0135] The instantaneous weight W when passing through the weighing platform during the T time period ij , calculate the instantaneous weight W of all vehicles ij The mean value W m :
[0136]
[0137] in, W represents the total number of monitoring times of the effective weight of all vehicles after removing outliers. m It reflects the overall weight level of the vehicle. A larger mean value indicates that the vehicle is heavier overall, which may be related to the vehicle type and load conditions.
[0138] Calculate the deviation of each vehicle's weight from the mean and select the weight with the largest deviation from the mean. For the i-th vehicle, calculate the deviation of the weight from the mean at each weighing:
[0139] D ij =|W ij -W m |
[0140] Among them, D ij The deviation of the i-th vehicle at the j-th weighing time reflects the difference between each weighing and the overall mean. A larger deviation indicates that the weight of the weighing is significantly different from the overall weight level, which may indicate special circumstances (such as overloading, data anomaly, etc.);
[0141] Then for the i-th vehicle, find the number of weighings j that leads to the maximum deviation:
[0142] j i =argmax(D ij )for all i
[0143] Among them, j i Represents the index of the weighing that causes the maximum deviation in the i-th vehicle. The weight value pointed to by this index will be used as a dynamic parameter to reflect the extreme situation and facilitate subsequent analysis and decision-making;
[0144] By finding the index j i, select the corresponding weight as the dynamic parameter W s :
[0145]
[0146] Among them, W s represents the weight with the largest deviation from the mean;
[0147] At the selected vehicle index j i The speed of the weighing that leads to the largest deviation is extracted as follows:
[0148]
[0149] Among them, V s represents the speed of the weighing that leads to the largest weight deviation in the i-th vehicle;
[0150] Extract the vehicle model classification at the same weighing:
[0151]
[0152] Among them, C s Indicates the vehicle type classification that leads to the largest weight deviation in the i-th vehicle;
[0153] The extracted dynamic weight, speed, and vehicle type are classified and organized into a feature dataset:
[0154] F={(W s , V s , C s )}
[0155] Here, F represents the feature dataset, which contains the selected weight, speed, and vehicle type classification data. The feature dataset F organizes the vehicle information with the largest deviation from the mean to facilitate subsequent model training and predictive analysis.
[0156] Step 2: Build a decision tree model, use the historical vehicle feature data to be monitored, including weight, speed and vehicle model data, as a training set, and the corresponding vehicle actual weight data as a label, and input it into the decision tree model for training;
[0157] The feature dataset F is standardized to eliminate the influence caused by different dimensions between features:
[0158]
[0159] Among them, F' is the standardized feature data, and F is the original feature data;
[0160] The original feature data F may affect the effect of model training due to different dimensions. The standardized feature data F' reflects the performance of different features at the same scale after processing. After standardization, the mean of all features is 0 and the standard deviation is 1, so that features of different dimensions can be compared under the same standard.
[0161] μ is the mean of the feature data, which is used to measure the center position of the data. Its calculation formula is:
[0162]
[0163] Among them, u represents the number of samples of feature data, F a represents the eigenvalue of the ath sample;
[0164] σ is the standard deviation of the characteristic data, and its calculation formula is:
[0165]
[0166] Among them, (F a -μ) 2 represents the square of the difference between each sample and the mean;
[0167] When the decision tree processes categorical data, One-Hot Encoding can convert categorical variables into numerical form. Suppose the vehicle type classification C s There are three categories: SUV, sedan, and truck. Through one-hot encoding, each category is represented by a separate binary column of 0 or 1. These categories are represented as:
[0168]
[0169] Each row corresponds to a category, so that the model can treat each category as a different input feature and use binary form to represent each category as an independent feature. This processing method prevents the model from generating sequential relationships between categories during calculations.
[0170] Original model classification C s ,Through one-hot encoding, the model can better handle categorical variables and avoid,information loss caused by improper category encoding;
[0171] Use the vehicle weight recorded in the historical data as the label vector Y:
[0172] Y={W o |o=1,2,…,O}
[0173] Where O represents the number of vehicles, W o is the actual weight of the oth vehicle; label Y represents the real weight of the historical vehicle, each W ois the actual weight of the corresponding vehicle, which is used as the training target of the model;
[0174] At each node, select a feature f to divide the data, use the mean square error (MSE) as the division criterion, evaluate the division effect of each node, and calculate the mean square error of the current node R:
[0175]
[0176] Among them, M R Indicates the number of samples of the current node R, W o represents the true weight of the o-th sample, Represents the predicted weight of the current node R, which is the mean of all samples in the node:
[0177]
[0178] MSE reflects the prediction accuracy of the current node. The smaller the value, the better the prediction effect of the model at the node. The number of samples M R The difference between the actual and predicted weights will affect the size of the MSE. As the number of samples increases, if the prediction is accurate, the MSE will tend to decrease;
[0179] The decision tree starts from the root node, recursively selects the best feature f and divides the data into the left subset D according to the partitioning criteria left and right subset D right , with p representing the index of the sample being examined:
[0180] D left ={(F′ p ,Y p )|F′ p,f ≤threshold}
[0181] Among them, the left subset contains all samples whose feature f value is less than or equal to a certain threshold threshold, F' p represents the standardized feature vector of the pth sample, Y p represents the target variable of the p-th sample;
[0182] D right ={(F′ p , Y p )|F′ p,f >threshold}
[0183] Among them, the right subset contains all samples whose feature f values are greater than a certain threshold threshold;
[0184] The sample distribution of the left and right subsets can affect the prediction effect of subsequent nodes, the eigenvalue F' p,fThe larger the threshold, the more likely it is to affect the distribution of samples and thus the learning of the model.
[0185] Calculate the left subset D after feature f is divided left and right subset D right The mean square error is used to evaluate the effectiveness of the current feature division:
[0186]
[0187] Among them, M left and M right is the number of samples in the left and right subsets, and is the predicted weight of the left subset and the right subset; MSE left and MSE right Reflects the prediction accuracy of samples in the two subsets. The smaller the value, the more effective the division.
[0188] Comprehensively consider the mean square error before and after the division, calculate the overall mean square error of the current division, combine the mean square errors of the left and right subsets, and evaluate the overall effect of the division:
[0189]
[0190] Among them, MSE split is the overall mean square error of the current division, which represents the weighted average of the prediction errors after dividing the data by a certain feature and threshold. The smaller the value, the better the division effect. R is the total number of samples in the current node, that is, the sum of the number of samples in the left child node and the right child node, that is, M R =M left +M right , MSE left and MSE right are the mean square errors of the left and right child nodes, respectively, indicating the mean square error between the sample prediction value and the true value in the left and right child nodes;
[0191] Select the best split feature and threshold, and select the one with the minimum MSE for all features and their possible split points. split The characteristic f * and threshold * , select the features and their partitioning thresholds that can most effectively reduce the mean square error:
[0192]
[0193] Among them, f * The best feature to be selected is the feature that can most effectively reduce the mean square error, threshold * is the optimal threshold selected to divide the feature f* The value of is chosen so that the overall mean square error is minimized after division. argmin represents the operation of finding the features and thresholds that minimize the mean square error.
[0194] Create child nodes according to feature f * and threshold * Partitioning is performed, and samples that meet the conditions will be divided into the left child node R left , samples that do not meet the conditions will be divided into the right child node R right , for each child node R left and R right , repeat the above operation until the stop condition is reached;
[0195] During the training process, decide when to stop splitting: when the number of samples of the current leaf node is less than the preset minimum number of samples, stop splitting; when the depth of the tree reaches the preset maximum depth, stop splitting; when the mean square error of the node is small enough, stop splitting;
[0196] When the stopping condition is reached, the current node becomes a leaf node and stores the predicted value of the node. The predicted value is usually the mean of the node samples:
[0197]
[0198] in, is the predicted value of the current leaf node, indicating the predicted result of the sample corresponding to the leaf node, M leaf is the number of samples of the current leaf node, W o is the true target value of the oth sample in the current leaf node.
[0199] Step 3: Input the real-time recorded weight, speed, and vehicle type data of the monitored vehicle as it passes the weighing platform into the trained decision tree model to predict the actual vehicle weight data;
[0200] Based on the real-time monitored data, construct feature data:
[0201] F r ={(W r,s , V r,s ,C r,s )}
[0202] Input the standardized feature data into the trained decision tree model X to predict the actual weight of the vehicle:
[0203]
[0204] in, represents the actual weight of the model's prediction of the real-time input feature, F' rIt is standardized feature data. At each node of the tree, the specific value of the feature value determines which leaf node the sample enters, thus affecting the final prediction value.
[0205] Represents the model's estimate of the actual weight of the vehicle based on the input feature data. It is the output of the decision tree and represents the system's response to external input. It reflects the weight that a vehicle can reach under certain conditions (such as speed and classification). The larger the predicted value, the heavier the model believes the vehicle is.
[0206] If the input features (e.g., speed, vehicle type) change, the model will adjust its predictions based on these changes. For example, if the vehicle’s speed is high and it is a heavy SUV, the model may predict a higher weight; if the independent variables (e.g., V r,s ) increases, and model C r,s ) also supports higher weights, and the model may output higher prediction values On the contrary, if the independent variable (such as W r,s ) decreases, which may lead to the prediction results reduction, especially when it reflects the adaptability of the model to certain conditions;
[0207] The calculation process of the decision tree model X:
[0208]
[0209] Among them, each corresponds to the leaf node Leaf k The predicted value represents the average actual weight of the samples in the leaf node, X(F' r ) represents the process of processing and predicting the standardized feature data by the decision tree model, X(F' r ) represents the process of processing and predicting standardized feature data by the decision tree model.
[0210] Step 4: Based on the error between the actual vehicle weight data predicted by the model and the actual weight data of the vehicle weighing, determine whether the error exceeds the set error threshold and retrain the model;
[0211] Calculate the actual vehicle weight data predicted by the above method and the actual weighed vehicle weight W actual The error E between:
[0212]
[0213] Then define an acceptable error threshold ∈ and check whether the calculated error E exceeds the set error threshold ∈: If E>∈, it means that the prediction is beyond the acceptable range, and the model needs to be retrained;
[0214] ∈ is the set acceptable error threshold, which indicates the maximum prediction error that the model can tolerate in practical applications, and determines whether the prediction accuracy of the model is within the acceptable range;
[0215] E represents the accuracy of the model prediction. The smaller the value, the closer the model prediction result is to the actual value. On the contrary, the prediction is more biased. The input feature data F' of the model r and model parameters. Changes in these independent variables may affect the model's predictions and thus affect the error E;
[0216] Retraining the model requires collecting new sample data since the model prediction, including new feature data and corresponding actual weight data, and merging the newly collected data with the original training data to form a larger training dataset D train,up :
[0217] D train,up =D train ∪{(F new ,W actual )}
[0218] D train,up is the updated training data set, including the original training data D train and newly collected sample data (F new ,W actual ), expand the training set by incorporating new sample data to improve the learning effect of the model;
[0219] Using the updated dataset D train,up Retrain the decision tree model X, following the previous training process: feature selection, partitioning, and generating leaf nodes:
[0220] X(F′ r )=Train(D train,up )
[0221] During the training process, the decision tree model is retrained with the updated training data set to rebuild the model structure. The performance of the retrained model X will depend on the quality and characteristics of the training data.
[0222] After retraining, use an independent validation set to evaluate the model effect and calculate the prediction error of the new model:
[0223]
[0224] is the updated Model X up For input feature data F' r The prediction results;
[0225] Compute the absolute error of the new model:
[0226]
[0227] The absolute error E generated by the new model's prediction of the actual weight up , used to measure the prediction accuracy of the updated model on the new data set. The above steps ensure that the error of the new model is lower than the error of the old model and is within an acceptable range;
[0228] E up It reflects the prediction accuracy of the new model. The smaller the value, the better the model performance. The actual weighing data W actual The prediction results of the new model will be directly affected by the change of independent variables, thereby affecting E up .
[0229] The above formulas are all dimensionless and numerical calculations. The formulas are obtained by collecting a large amount of data and performing software simulation to obtain the most recent real situation. The preset parameters in the formulas are set by technicians in this field according to actual conditions.
[0230] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed by hardware or software depends on the specific application and design constraints of the technical solution.
[0231] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, and may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment as needed.
[0232] The above is only a specific implementation method of the present application, but the scope of protection of the present application is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in this application, which should be covered by the scope of protection of the present application.
Claims
1. A dynamic vehicle scale measurement method with automatic parameter fitting, characterized in that: The specific steps include: Step 1: Record the weight, speed, and vehicle type data of the monitored vehicle passing the weighing platform in real time. Collect the weight, speed, and vehicle type data of the monitored vehicle passing the weighing platform during the historical period. Clean and extract the collected weight and speed data to obtain the vehicle's characteristic data. Step 2: Build a decision tree model, use the historical vehicle feature data to be monitored, including weight, speed and vehicle model data, as a training set, and the corresponding vehicle actual weight data as a label, and input it into the decision tree model for training; Step 3: Input the real-time recorded weight, speed, and vehicle type data of the monitored vehicle as it passes the weighing platform into the trained decision tree model to predict the actual vehicle weight data; Step 4: Based on the error between the actual vehicle weight data predicted by the model and the actual weight data of the vehicle weighing, determine whether the error exceeds the set error threshold and retrain the model; Standardize the feature dataset F to eliminate the impact of different dimensions between features: Among them, F ' is the standardized feature data, F is the feature data set; μ is the mean of the characteristic data, and its calculation formula is: Among them, u represents the number of samples of feature data, F a represents the eigenvalue of the ath sample; σ is the standard deviation of the characteristic data, and its calculation formula is: Among them, (F a -μ) 2 represents the square of the difference between each sample and the mean; When the decision tree processes categorical data, One-Hot Encoding can convert categorical variables into numerical form. Suppose the vehicle type classification C s There are three categories: SUV, sedan, and truck. Through one-hot encoding, each category is represented by a separate binary column of 0 or 1. These categories are represented as: Each row corresponds to a category, allowing the model to treat each category as a different input feature; Use the vehicle weight recorded in the historical data as the label vector Y: Y={W o |o=1,2,…,O} Where O represents the number of vehicles, W o is the actual weight of the oth vehicle; At each node, select a feature f to divide the data, use the mean square error (MSE) as the division criterion, evaluate the division effect of each node, and calculate the mean square error of the current node R: Among them, M R Indicates the number of samples of the current node R, W o represents the true weight of the o-th sample, Represents the predicted weight of the current node R, which is the mean of all samples in the node: The decision tree starts from the root node, recursively selects the best feature f and divides the data into the left subset D according to the partitioning criteria left and right subset D right , with p representing the index of the sample being examined: D left ={(F′ p ,Y p )|F′ p,f ≤threshold} Among them, the left subset contains all samples whose feature f value is less than or equal to a certain threshold threshold, F' p represents the standardized feature vector of the pth sample, Y p represents the target variable of the p-th sample; D right ={(F′ p ,Y p )|F p,f >threshold} Among them, the right subset contains all samples whose feature f values are greater than a certain threshold threshold; Calculate the left subset D after feature f is divided left and right subset D right The mean square error of: Among them, M left and M right is the number of samples in the left and right subsets, and are the predicted weights of the left and right subsets; Taking into account the mean square error before and after division, the overall mean square error is calculated: Among them, MSE split is the overall mean square error of the current partition, which represents the weighted average of the prediction errors after the data is partitioned by a certain feature and threshold. R is the total number of samples in the current node, that is, the sum of the number of samples in the left child node and the right child node, that is, M R =M left +M right , MSE left and MSE right are the mean square errors of the left and right child nodes, respectively, indicating the mean square error between the sample prediction value and the true value in the left and right child nodes; Select the best split feature and threshold, and select the one with the minimum MSE for all features and their possible split points. split The characteristic f * and threshold * : Among them, f * The best feature to be selected is the feature that can most effectively reduce the mean square error, threshold * is the optimal threshold selected to divide the feature f * The value of is chosen so that the overall mean square error is minimized after division. argmin represents the operation of finding the features and thresholds that minimize the mean square error. Create child nodes according to feature f * and threshold * Partitioning is performed, and samples that meet the conditions will be divided into the left child node R left , samples that do not meet the conditions will be divided into the right child node R right , for each child node R left and R right , repeat the above operation until the stop condition is reached; During the training process, decide when to stop splitting: when the number of samples of the current leaf node is less than the preset minimum number of samples, stop splitting; when the depth of the tree reaches the preset maximum depth, stop splitting; when the mean square error of the node is small enough, stop splitting; When the stopping condition is reached, the current node becomes a leaf node and stores the predicted value of the node. The predicted value is usually the mean of the node samples: in, is the predicted value of the current leaf node, indicating the predicted result of the sample corresponding to the leaf node, M leaf is the number of samples of the current leaf node, W o is the true target value of the oth sample in the current leaf node; Based on the real-time monitored data, construct feature data: F r ={(W r,s ,V r,s ,C r,s )} Input the standardized feature data into the trained decision tree model X to predict the actual weight of the vehicle: in, represents the actual weight of the model’s prediction for the real-time input feature, F ' r It is the standardized feature data; The calculation process of the decision tree model X: Among them, each corresponds to the leaf node Leaf k The predicted value of .
2. The dynamic vehicle scale measurement method with automatic parameter fitting according to claim 1 is characterized by: Set the historical time period for collecting vehicle data to be monitored as T. During this T time period, continuously monitor each vehicle passing through the weighing platform. For each vehicle, the moment it passes through the weighing platform, that is, the timestamp t ij Record the following information: the instantaneous weight W of the i-th vehicle when it passes the weighing platform for the jth time ij , the instantaneous speed V of the i-th vehicle when it passes the weighing platform for the jth time ij , the vehicle type classification C obtained by the vehicle type recognition system for the i-th vehicle at the j-th time ij , organize these data into a data set D: D={(t ij ,W ij ,V ij ,C ij )|i=1,2,…,n,j=1,2,…,n i } Where n represents the total number of vehicles passing through the weighing platform within the time period T, n i represents the number of times the weight, speed and vehicle model data of the i-th vehicle are monitored in the time period T; Get the minimum and maximum weight data of each vehicle passing the weighing platform during the T time period: IN min =min(W ij |i=1,2,…,n,j=1,2,…,n i ) W max =max(W ij |i=1,2,…,n,j=1,2,…,n i ) Among them, for each car, if W ij <W min or W ij >W max , it is considered as an outlier and removed; Get the minimum and maximum speed data of each vehicle passing the weighing platform during the T time period: V min =min(V ij |i=1,2,…,n,j=1,2,…,n i ) V max =max(V ij |i=1,2,…,n,j=1,2,…,n i ) Among them, for each car, if V ij <V min or V ij >V max , it is considered as an outlier and removed; The method for real-time recording the weight, speed and vehicle type data of the monitored vehicle when it passes the weighing platform is as follows: db Record data to form a data set: D r ={(t db ,W r,db ,V r,db ,C r,db )|d=1,2,…,m,b=1,2,…,m d } Among them, m represents the total number of vehicles recorded during the monitoring period, m d Indicates the number of times the weight, speed and vehicle model data of the d-th vehicle are monitored within the time period T.
3. The dynamic vehicle scale measurement method with automatic parameter fitting according to claim 2 is characterized in that: The instantaneous weight W when passing through the weighing platform during the T time period ij , calculate the instantaneous weight W of all vehicles ij The mean value W m : in, Indicates the total number of monitoring times of the effective weight of all vehicles after removing outliers; Calculate the deviation of each vehicle's weight from the mean and select the weight with the largest deviation from the mean. For the i-th vehicle, calculate the deviation of the weight from the mean at each weighing: D ij =|W ij -W m | Among them, D ij represents the deviation of the i-th vehicle at the j-th weighing; Then for the i-th vehicle, find the number of weighings j that leads to the maximum deviation: j i =argmax(D ij )for all i Among them, j i represents the index of the weighing that causes the largest deviation in the i-th vehicle; By finding the index j i , select the corresponding weight as the dynamic parameter W s : Among them, W s represents the weight with the largest deviation from the mean; At the selected vehicle index j i The speed of the weighing that leads to the largest deviation is extracted as follows: Among them, V s represents the speed of the weighing that leads to the largest weight deviation in the i-th vehicle; Extract the vehicle model classification at the same weighing: Among them, C s Indicates the vehicle type classification that leads to the largest weight deviation in the i-th vehicle; The extracted dynamic weight, speed, and vehicle type are classified and organized into a feature dataset: F={(W s ,V s ,C s )} Where F represents the feature dataset, which contains the selected weight, speed and vehicle type classification data.
4. The dynamic vehicle scale measurement method with automatic parameter fitting according to claim 3 is characterized by: Calculate the actual vehicle weight data predicted by the above method and the actual weighed vehicle weight W actual The error E between: Then define an acceptable error threshold ∈ and check whether the calculated error E exceeds the set error threshold ∈: If E>∈, the model needs to be retrained; Retraining the model requires collecting new sample data since the model prediction, including new feature data and corresponding actual weight data, and merging the newly collected data with the original training data to form a larger training dataset D train,up : D train,up =D train ∪{(F new ,w actual )} Using the updated dataset D train,up Retrain the decision tree model X, following the previous training process: feature selection, partitioning, and generating leaf nodes: X(F′ r )=Train(D train,up ) During the training process, the decision tree model is retrained with the updated training data set to rebuild the model structure; After retraining, use an independent validation set to evaluate the model effect and calculate the prediction error of the new model: Compute the absolute error of the new model: The above steps ensure that the error of the new model is lower than the error of the old model and is within an acceptable range.
Citation Information
Patent Citations
Weighing error automatic compensation method of vehicle scale
CN102506983A
Vehicle-mounted weight prediction method and system, electronic equipment and medium
CN112819031A