Industrial product quality prediction method based on XGBoost algorithm
The XGBoost algorithm-based method addresses inefficiencies in traditional quality detection by preprocessing data and optimizing model parameters, resulting in enhanced prediction accuracy and efficiency, supporting high-quality and efficient industrial production.
Patent Information
- Application Number
- CN202411574025.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-03-18
AI Technical Summary
Traditional industrial product quality detection methods are inefficient, unable to handle complex variations and non-linear relationships, underutilize data, and are subjective, leading to low efficiency and high costs, which fail to meet modern industrial demands for high-quality and efficient production.
A method using the XGBoost algorithm, incorporating sparse matrices and optimized model parameters, for predicting industrial product quality by preprocessing data, extracting relevant features, and training with distributed gradient boosting to enhance prediction accuracy and efficiency.
The method significantly improves product quality prediction accuracy, increases production efficiency, reduces costs, and enhances decision-making, leading to improved quality management and market competitiveness.
Smart Images

Figure CN119648023A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an industrial product quality prediction method, and in particular to an industrial product quality prediction method based on an XGBoost algorithm. Background Art
[0002] In modern industrial production, product quality is one of the core elements of enterprise competitiveness. High-quality products can not only enhance the market reputation of enterprises, but also reduce the cost of after-sales service and improve customer satisfaction. Therefore, accurate prediction of product quality has become a key link in industrial production.
[0003] Traditional industrial product quality inspection methods have many shortcomings, including the inability to detect problems in the production process in a timely manner due to post-testing, low efficiency and high cost, difficulty in handling complex variations and nonlinear relationships, insufficient data utilization, lack of real-time performance, and strong subjectivity. These limitations make it difficult for traditional methods to meet the needs of modern industrial production for high quality and high efficiency. Summary of the invention
[0004] In order to solve the problems in the background technology, the present invention provides an industrial product quality prediction method based on the XGBoost algorithm. The method of the present invention can solve the problems of low efficiency, difficulty in handling complex variations and nonlinear relationships, insufficient data utilization, and strong subjectivity in traditional quality detection methods.
[0005] The technical solution adopted by the present invention is:
[0006] The industrial product quality prediction method based on the XGBoost algorithm of the present invention comprises:
[0007] Step 1: Collect product quality data of target industrial products and perform preprocessing to extract useful features as training set;
[0008] Step 2: Input the training set into the distributed gradient boosting XGBoost (eXtreme Gradient Boosting) algorithm for training, introduce sparse matrices into the distributed gradient boosting XGBoost algorithm, and tune the model parameters of the distributed gradient boosting XGBoost algorithm to select the parameter combination with the best performance, so as to obtain the trained distributed gradient boosting XGBoost algorithm.
[0009] Step 3: The product quality data of the industrial product to be predicted is preprocessed in the same way as in step 1 and then input into the trained distributed gradient enhancement XGBoost algorithm. After processing, the quality prediction result of the industrial product is output and displayed on the display to achieve industrial product quality prediction.
[0010] In step 1, the product quality data includes the material inspection report data and qualified rate data of the target industrial product. In order to accurately predict product quality, it is necessary to clearly and systematically collect and organize a series of relevant data, which should cover multiple aspects such as product design, raw material quality and various performance indicators of the final product.
[0011] In the step 1, the product quality data is preprocessed. First, the Z-score is used to remove outliers and remove noise. Then, interpolation, mean filling or median filling methods are used to fill missing values. Finally, the data is converted into a unified format or unit for standardization, thereby improving the data quality and making it more suitable for analysis and modeling, and finally obtaining product quality data after extracting useful features.
[0012] Preprocess the collected data and extract useful features from the raw data. Raw data usually contains noise, missing values, outliers and other problems. Directly using these data for analysis may lead to inaccurate or misleading results. Therefore, extracting useful features from raw data and performing appropriate preprocessing are the key to ensuring the effectiveness of subsequent analysis and modeling.
[0013] In step 2, a sparse matrix is introduced into the activation function Softmax layer of the distributed gradient boosting XGBoost algorithm to optimize the model performance. The sparse matrix is as follows:
[0014]
[0015] Among them, A(i,j) represents the element in the i-th row and j-th column of the sparse matrix; indptr[] points to the starting position of the non-zero elements stored in the storage array data in the sparse matrix; data k Represents the storage array of the kth non-zero element in the sparse matrix, indices k Represents the storage column index of the k-th nonzero element in the sparse matrix.
[0016] In the step 2, the model parameters of the distributed gradient boosting XGBoost algorithm are tuned. First, several groups of model parameters of the distributed gradient boosting XGBoost algorithm are preset, and then the grid search method is used to traverse and tune each group of model parameters of the XGBoost algorithm. The performance of each group of model parameters is evaluated by cross-validation, and finally the best performing model parameter combination is selected as the final hyperparameter setting of the distributed gradient boosting XGBoost algorithm to obtain a trained distributed gradient boosting XGBoost algorithm.
[0017] The XGBoost algorithm is used to train the model on the preprocessed data. XGBoost is an efficient gradient boosting algorithm that can handle large-scale data sets and high-dimensional features and has good prediction performance. The grid search method is used to tune the model parameters to find the optimal parameter combination to improve the prediction accuracy of the model. The grid search traverses the predefined parameter combinations, evaluates the performance of each combination, and finally selects the best performing parameter combination. The data set is divided into multiple subsets through cross-validation, and the model is trained and evaluated multiple times to reduce the randomness of the evaluation results.
[0018] The cross-validation is specifically as follows: first, the training set is divided into M subsets, K-1 subsets are used for training each time, and the remaining subset is evaluated to obtain the current prediction accuracy, precision, recall rate, and F1 score of the distributed gradient boosting XGBoost algorithm, and select the model parameter combination with the highest prediction accuracy, precision, recall rate, and F1 score.
[0019] In the step 3, the quality prediction result of the industrial product is the qualified rate of the industrial product, and the industrial products whose qualified rate is greater than or equal to the preset qualified rate threshold are determined as qualified industrial products.
[0020] The beneficial effects of the present invention are:
[0021] The method of the present invention can solve the problems existing in traditional quality detection methods, such as low efficiency, difficulty in handling complex variations and nonlinear relationships, insufficient data utilization, and strong subjectivity. By utilizing the efficiency and flexibility of the XGBoost algorithm, the present invention can significantly improve the accuracy of product quality prediction, improve production efficiency, reduce production costs, enhance data utilization, improve decision-making scientificity, improve customer satisfaction, and support the continuous improvement and innovation of enterprises, and ultimately significantly improve the quality management level in industrial production, enhance the market competitiveness of enterprises, and achieve high-quality and high-efficiency production goals. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a flow chart of the method of the present invention;
[0023] Figure 2 Schematic diagram of the confusion matrix of the model in the embodiment of the present invention. DETAILED DESCRIPTION
[0024] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0025] like Figure 1As shown, the industrial product quality prediction method based on the XGBoost algorithm of the present invention is as follows:
[0026] Step 1: Collect product quality data of target industrial products and perform preprocessing to extract useful features as training set; in specific implementation, it can be divided into 80% training set and 20% test set. Product quality data includes material inspection report data and qualified rate data of target industrial products. In order to accurately predict product quality, it is necessary to clearly and systematically collect and organize a series of relevant data, which should cover multiple aspects such as product design, raw material quality and various performance indicators of the final product.
[0027] As shown in Table 1, the material inspection report data and qualified result data of the material named shrapnel used in the product SF7J311 collected in the embodiment of the present invention are shown.
[0028] Table 1
[0029]
[0030]
[0031]
[0032] Among them, the inspection standards for the inspection items of shrapnel are specifically as follows: appearance inspection: the surface of the target shrapnel is smooth and free of burrs, defects, deformation, rust and other defects, the shrapnel and rivet cannot be loose, and the rivet is flat; shrapnel length: 33.5±0.20cm; shrapnel width: 8; rivet height: 3.3±0.20cm; rivet outer diameter: 6±0.1cm; rivet flatness: 5.50-0.1cm; shrapnel rivet height: 4.5+0.2-0.1cm; shrapnel thickness: 0.30-0.05cm; rivet hardness test: Rockwell hardness HRC (Rockwell Hardness) 25-30; shrapnel hardness test: Brinell hardness HB (Brinell Hardness) 400±25; environmental protection: environmental protection certification ROHS (Restriction of Hazardous Substances). N (Number) is the sampling number, AC (Accept) is the number of unqualified samples accepted, and acceptance is performed if 0 unqualified samples are found.
[0033] The present invention can also collect product quality data of spring wire for processing. The inspection standards of the inspection items of spring wire are specifically as follows: Appearance inspection: the appearance of the target inspection power line is intact, the surface is smooth, the handwriting is clear, and there are no obvious defects such as burrs; Color inspection: according to the color requirements of the drawing or the task list, the color of the material is compared with the color of the color card or standard color block under the JAG60-6 six-light source light box or the colorimeter, and it is required that the color of the material is not significantly different from the color of the color card or the color block; Safety parameter inspection: check the safety registration, and the feeding material is consistent with the material used in the registered machine (model, parameters, manufacturer); Logo abrasion resistance test: use a piece of water-soaked cloth to apply normal force to wipe 15 back and forth (about 15s), and then use a piece of alcohol-soaked cloth to apply normal force to wipe 15 back and forth (about 15s), and the logo is still easy to recognize after the test ( If the mark is molded, this test is not performed); Conductive polarity test: adjust the multimeter to the conduction test mode, use the two needles of the multimeter to connect one pin and the corresponding branch line, the multimeter displays 0 or an alarm sounds; Withstand voltage test: Use a withstand voltage tester to test the outer surface of the plug and the two pins, 4500V / 5mA / 3S cannot be broken down or flashed; Power cord bending test: The power cord is installed in the sheath and subjected to 20,000 bending tests. After the test, the cable core wire breakage rate does not exceed 10%; Carbon body height of electric carbon: 5-0.05-0.1cm; Electric carbon spring wire diameter: 0.4cm; Electric carbon spring inner diameter: 4.8cm; Electric carbon plug outer diameter: 50-0.1cm; Electric carbon pull-off force test: The brush should be able to withstand 9.8N pulling force without loosening; Electric carbon environmental protection certification ROHS; Product qualification rate.
[0034] The product quality data is preprocessed by first using the Z-score to remove outliers and noise, then using interpolation, mean filling or median filling methods to fill missing values, and finally converting it to a unified format or unit for standardization, thereby improving data quality and making it more suitable for analysis and modeling, and finally obtaining product quality data after extracting useful features.
[0035] The standardization process is as follows:
[0036]
[0037] Among them, X norm is the normalized data point, X is the original data point, and X min is the minimum value of the data set, X max is the maximum value of the data set.
[0038] Preprocess the collected data and extract useful features from the raw data. Raw data usually contains noise, missing values, outliers and other problems. Directly using these data for analysis may lead to inaccurate or misleading results. Therefore, extracting useful features from raw data and performing appropriate preprocessing are the key to ensuring the effectiveness of subsequent analysis and modeling.
[0039] The processed data is divided into training set and test set. The training set is used to train the model so that the model can learn the patterns and regularities in the data. The test set is used to evaluate the performance of the model on unseen data to ensure that the model has good generalization ability, that is, it can perform well on new, unseen data.
[0040] Step 2: Input the training set into the distributed gradient boosting XGBoost (eXtreme Gradient Boosting) algorithm for training, introduce sparse matrices into the distributed gradient boosting XGBoost algorithm, and tune the model parameters of the distributed gradient boosting XGBoost algorithm to select the parameter combination with the best performance, so as to obtain the trained distributed gradient boosting XGBoost algorithm.
[0041] In the specific implementation, first import the XGBoost library and other necessary libraries, then create an XGBoost model instance and set relevant parameters, and finally use the training set data to train the model. The main parameters used include: the number of weak learners n_estimators, the learning rate learning_rate, the maximum depth of each tree max_depth, the minimum sample weight and min_child_weight in the child node, the sample ratio subsample used to train each tree, the feature ratio colsample_bytree used to train each tree, the objective function objective, the evaluation indicator eval_metric, the minimum loss reduction required for node splitting gamma, the weight lambda of the L2 regularization term, and the weight alpha of the L1 regularization term. The specific formula is as follows:
[0042]
[0043] Among them, Obj() is the objective function, θ is the model parameter of the XGBoost algorithm; n is the total number of samples, L() is the loss function of the i-th sample, and y i and are the true value and predicted value of the i-th sample respectively; K is the total number of trees, Ω() is the regularization term of the k-th tree, and f k is the kth parameter of the XGBoost algorithm; γ is the minimum loss reduction required for node splitting, T is the number of leaf nodes in the tree, λ is the weight of the L2 regularization term, and wj is the weight of the jth leaf node, and α is the weight of the L1 regularization term.
[0044] A sparse matrix is introduced in the Softmax layer of the activation function of the distributed gradient boosting XGBoost algorithm to optimize the model performance. The sparse matrix is as follows:
[0045]
[0046] Among them, A(i,j) represents the element in the i-th row and j-th column of the sparse matrix; indptr[] points to the starting position of the non-zero elements stored in the storage array data in the sparse matrix; data k Represents the storage array of the kth non-zero element in the sparse matrix, indices k Represents the storage column index of the k-th nonzero element in the sparse matrix.
[0047] The data structure of a sparse matrix uses three arrays to represent the non-zero elements in the sparse matrix, namely: data: stores the values of non-zero elements. indices: stores the column index of each non-zero element. indptr (index pointer): stores the starting position of the non-zero elements of each row in the data array. For each row of elements, the value of the non-zero element is stored in the range of indptr[i] to indptr[i+1]-1 in the data array, and the corresponding column index is stored in the same range of the indices array.
[0048] The model parameters of the distributed gradient boosting XGBoost algorithm are tuned. First, several groups of model parameters of the distributed gradient boosting XGBoost algorithm are preset. Then, the grid search method is used to traverse and tune each group of model parameters of the XGBoost algorithm. Cross-validation is used to evaluate the performance of each group of model parameters. Finally, the best performing model parameter combination is selected as the final hyperparameter setting of the distributed gradient boosting XGBoost algorithm to obtain the trained distributed gradient boosting XGBoost algorithm.
[0049] In the specific implementation, we first define a parameter grid containing all the hyperparameters that need to be tuned and their possible values; then use the grid search tool GridSearchCV to traverse all parameter combinations, and evaluate the performance of each parameter combination during the cross-validation process, and record the performance indicators of each combination; finally, after the grid search is completed, select the parameter combination with the best performance as the final hyperparameter setting.
[0050] The XGBoost algorithm is used to train the model on the preprocessed data. XGBoost is an efficient gradient boosting algorithm that can handle large-scale data sets and high-dimensional features and has good prediction performance. The grid search method is used to tune the model parameters to find the optimal parameter combination to improve the prediction accuracy of the model. The grid search traverses the predefined parameter combinations, evaluates the performance of each combination, and finally selects the best performing parameter combination. The data set is divided into multiple subsets through cross-validation, and the model is trained and evaluated multiple times to reduce the randomness of the evaluation results.
[0051] Specifically, the cross-validation is as follows: first, the training set is divided into M subsets, K-1 subsets are used for training each time, and the remaining subset is used for evaluation to obtain the current prediction accuracy, precision, recall rate, and F1 score of the distributed gradient boosting XGBoost algorithm, and then the model parameter combination with the highest prediction accuracy, precision, recall rate, and F1 score is selected.
[0052] The prediction accuracy, precision, recall and F1 score are as follows:
[0053]
[0054] Among them, TP is the number of samples correctly predicted by the model as positive, TN is the number of samples correctly predicted by the model as negative, FP is the number of samples incorrectly predicted by the model as positive (actually negative), and FN is the number of samples incorrectly predicted by the model as negative (actually positive); the value range of F1 score is [0, 1], and the larger the value, the better the performance of the model.
[0055] Step 3: The product quality data of the industrial product to be predicted is preprocessed in the same way as in step 1 and then input into the trained distributed gradient enhancement XGBoost algorithm. After processing, the quality prediction result of the industrial product is output and displayed on the display to achieve the quality prediction of the industrial product. The quality prediction result of the industrial product is the qualified rate of the industrial product. The industrial product with a qualified rate greater than or equal to the preset qualified rate threshold is determined as a qualified industrial product.
[0056] After the model training is completed, it can be evaluated to understand the performance of the model on the training data and test data, and to determine whether it has good generalization ability, that is, it can perform well on unseen data. The evaluation process usually includes the calculation and analysis of multiple indicators to fully understand the performance of the model. To perform model reasoning and prediction, you first need to load the trained model. The data in the reasoning phase also needs to be preprocessed as in the training phase to ensure that the data format is consistent with the model training. Finally, the preprocessed data is input into the model, and the model generates prediction results based on the input data, thereby realizing product quality prediction.
[0057] like Figure 2 As shown, it is a schematic diagram of the confusion matrix of the model in the embodiment of the present invention, which is used to evaluate the performance of the model in the classification task, and shows the comparison between the prediction results and the actual results of the model in different categories. The rows of the confusion matrix represent the actual categories, and the columns represent the predicted categories. Although there are some misclassifications, the overall prediction effect of the model is still relatively ideal. The model has good generalization ability on the current data set. In order to further improve the performance of the model, the data can be continuously updated iteratively to reduce misclassification and improve prediction accuracy.
[0058] The above description of the embodiments is to facilitate the understanding and application of the present invention by those skilled in the art. It is obvious that those skilled in the art can easily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without creative work. Therefore, the present invention is not limited to the above embodiments, and improvements and modifications made by those skilled in the art based on the disclosure of the present invention should be within the scope of protection of the present invention.
Claims
1. A method for predicting industrial product quality based on XGBoost algorithm, characterized in that: include: Step 1: Collect product quality data of target industrial products and perform preprocessing to extract useful features as training set; Step 2: Input the training set into the distributed gradient boosting XGBoost algorithm for training, introduce the sparse matrix into the distributed gradient boosting XGBoost algorithm, and select the parameter combination with the best performance after tuning the model parameters of the distributed gradient boosting XGBoost algorithm, so as to obtain the trained distributed gradient boosting XGBoost algorithm; Step 3: The product quality data of the industrial product to be predicted is preprocessed in the same way as in step 1 and then input into the trained distributed gradient enhancement XGBoost algorithm. After processing, the quality prediction result of the industrial product is output and displayed on the display to achieve industrial product quality prediction.
2. The industrial product quality prediction method based on the XGBoost algorithm according to claim 1, characterized in that: In the step 1, the product quality data includes the material inspection report data and the qualified rate data of the target industrial product.
3. The industrial product quality prediction method based on the XGBoost algorithm according to claim 1, characterized in that: In the step 1, the product quality data is preprocessed. First, the Z-score is used to remove outliers and remove noise. Then, interpolation, mean filling or median filling methods are used to fill missing values. Finally, the data is converted into a unified format or unit for standardization, and finally the product quality data after useful features are extracted is obtained.
4. The industrial product quality prediction method based on the XGBoost algorithm according to claim 1, characterized in that: In step 2, a sparse matrix is introduced into the activation function Softmax layer of the distributed gradient boosting XGBoost algorithm to optimize the model performance. The sparse matrix is as follows: Among them, A(i,j) represents the element in the i-th row and j-th column of the sparse matrix; indptr[] points to the starting position of the non-zero elements stored in the storage array data in the sparse matrix; data k Represents the storage array of the kth non-zero element in the sparse matrix, indices k Represents the storage column index of the k-th nonzero element in the sparse matrix.
5. The industrial product quality prediction method based on XGBoost algorithm according to claim 1, characterized in that: In the step 2, the model parameters of the distributed gradient boosting XGBoost algorithm are tuned. First, several groups of model parameters of the distributed gradient boosting XGBoost algorithm are preset, and then the grid search method is used to traverse and tune each group of model parameters of the XGBoost algorithm. The performance of each group of model parameters is evaluated by cross-validation, and finally the best performing model parameter combination is selected as the final hyperparameter setting of the distributed gradient boosting XGBoost algorithm to obtain a trained distributed gradient boosting XGBoost algorithm.
6. The industrial product quality prediction method based on XGBoost algorithm according to claim 5 is characterized in that: The cross-validation is specifically as follows: first, the training set is divided into M subsets, K-1 subsets are used for training each time, and the remaining subset is evaluated to obtain the current prediction accuracy, precision, recall rate, and F1 score of the distributed gradient boosting XGBoost algorithm, and select the model parameter combination with the highest prediction accuracy, precision, recall rate, and F1 score.
7. The industrial product quality prediction method based on XGBoost algorithm according to claim 1, characterized in that: In the step 3, the quality prediction result of the industrial product is the qualified rate of the industrial product, and the industrial products whose qualified rate is greater than or equal to the preset qualified rate threshold are determined as qualified industrial products.