Method and device for identifying Baijiu brands and key metal elements based on metal concentration
By constructing a liquor brand classification model based on metal element concentration, combining neural networks and SHAP algorithms to identify key metal elements, the intelligence and transparency of liquor brand classification are solved, and the accurate and efficient classification of liquor brands is achieved.
Patent Information
- Application Number
- CN202510365507.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-07-08
AI Technical Summary
The prior art lacks systematic methods to use metal element data to intelligently classify liquor brands, and the model lacks transparency and interpretability, which affects its application in actual production.
By constructing a liquor brand classification model based on metal element concentration, combining neural networks and SHAP algorithms, we can identify the contribution of key metal elements to liquor brands, and achieve accurate and efficient classification of liquor brands.
It improves the reliability and intelligence of liquor brand classification, enhances the transparency and interpretability of the model, and provides technical support for liquor brand identification and quality control.
Smart Images

Figure CN120280043A_ABST
Abstract
Description
Technical Field
[0001] The present invention mainly relates to the technical field of brewing, and in particular to a method and device for identifying liquor brands and key metal elements based on metal concentrations. Background Art
[0002] With the development of the food industry and the increasing demand of consumers for high-quality liquor, the classification and quality control of liquor brands have become particularly important. Traditional liquor brand classification methods mainly rely on sensory evaluation and empirical judgment, which have the problems of strong subjectivity and low efficiency. In recent years, liquor analysis methods based on chemical composition data have gradually received attention. The concentration of metal elements is closely related to the brand and quality of liquor. The brewing raw materials, production equipment, and storage containers used in different brand liquors (for example, raw materials such as grains and water from different origins, and liquor storage containers of different materials) may all cause differences in the content of metal elements in liquor. However, there is currently a lack of a systematic method to use metal element data to achieve intelligent classification of liquor brands and effectively identify the key metal elements that have a significant impact on the classification results.
[0003] In the prior art, although some studies use chemical composition data to construct classification models, they fail to fully combine interpretive algorithms to evaluate the feature contribution degree, resulting in the lack of transparency and interpretability of the models, which limits their application in actual production. Summary of the Invention
[0004] The technical problem to be solved by the present invention is: to provide a method and device for identifying liquor brands and key metal elements based on metal concentrations, aiming to improve the reliability and intelligence of classifying liquor brands based on metal element concentrations.
[0005] The technical solution adopted by the present invention to solve the above technical problem is:
[0006] On the one hand, the present invention provides a method for identifying liquor brands and key metal elements based on metal concentrations, and the method includes:
[0007] Step 1: Obtain the metal element concentrations and brand types of liquor samples, and construct a metal element concentration-liquor brand type data set;
[0008] Step 2: Use the metal element concentrations as inputs and the liquor brand types as outputs to establish a liquor brand classification model, and train the liquor brand classification model based on the constructed metal element concentration-liquor brand type data set;
[0009] Step 3: Embed a metal element feature contribution recognition module for analyzing the contribution degree of metal element types to the liquor brand recognition results into the trained liquor brand classification model;
[0010] Step 4: The Baijiu brand classification model outputs the brand type of the Baijiu sample to be tested and the key metal elements with high contribution to Baijiu brand recognition based on the metal element concentrations of the Baijiu sample to be tested.
[0011] Further, the metal elements include: Li, Na, K, Mg, Ca, Ba, B, Al, Ti, Cr, Mn, Fe, Co, Ni, Cu, Zn.
[0012] Further, in Step 2, a Baijiu brand classification model is established based on one or more of the MLP, LSTM, RNN, CNN, GRU, and Transformer models.
[0013] Further, the metal element feature contribution recognition module analyzes the contribution of metal elements to the Baijiu brand recognition result based on the SHAP algorithm, specifically including:
[0014] Calculating the SHAP value of each metal element for the Baijiu classification result;
[0015] Evaluating the contribution of each metal element according to the calculated SHAP value;
[0016] Sorting the contributions of all metal element features, and selecting the metal elements with contributions higher than the set value as the key metal elements.
[0017] Further, in Step 1, preprocessing is also included for the constructed metal element concentration - Baijiu brand type dataset, and the preprocessing includes data standardization: normalizing the metal element concentration data to eliminate the influence of different compound magnitudes.
[0018] Further, the training process of the Baijiu brand classification model in Step 2 includes: dividing the established metal element concentration - Baijiu brand type dataset into a training set and a test set, training the Baijiu brand classification model using the training set, evaluating the training effect of the Baijiu brand classification model using the test set, and when the accuracy of the Baijiu brand classification model on the test set is greater than the preset accuracy threshold, the training of the Baijiu brand classification model is completed.
[0019] Further, during the training process of the Baijiu brand classification model in Step 2, the cross - entropy loss function is used to evaluate the difference between the Baijiu brand classification model and the probability distribution of the true labels, and its expression is:
[0020]
[0021] In the formula, M is the number of Baijiu samples; C is the number of Baijiu brands; p ij is the true Baijiu brand label of the i - th Baijiu sample corresponding to the j - th Baijiu brand; is the probability that the i-th baijiu sample is predicted as baijiu brand j.
[0022] On the other hand, the present invention also provides a device for identifying baijiu brands and key metal elements based on metal concentration, including:
[0023] A dataset acquisition module: used to obtain the metal element data of baijiu sample data and the baijiu brand data corresponding to the baijiu samples, and construct a metal element-baijiu brand dataset;
[0024] A model training module: taking the metal element concentration as the input and the baijiu brand type as the output, creating a baijiu brand classification model, and training the baijiu brand classification model based on the constructed metal element concentration-baijiu brand type dataset;
[0025] A key metal identification module: used to analyze the contribution degree of the metal element type to the baijiu brand identification result;
[0026] A baijiu brand classification module: based on the trained baijiu brand classification model, input the metal element concentration characteristics of the baijiu sample to be discriminated into the baijiu brand classification model, obtain the baijiu brand classification result, and identify the key metal element types with high contribution degree to the baijiu brand identification.
[0027] The beneficial effects of the present invention are as follows: The method and device for identifying baijiu brands and key metal elements based on metal concentration according to the present invention establish a baijiu brand classification model for identifying baijiu brand types based on metal element concentration through a neural network model, realizing accurate and efficient classification of baijiu brands. And a metal element feature contribution identification module is embedded in the established baijiu identification model, which can identify the key metal elements that have a significant impact on the baijiu brand classification result while classifying baijiu, and explain the baijiu brand classification result, thereby enhancing the trust in the baijiu brand classification model and providing technical support for baijiu brand identification and quality control. Description of the Drawings
[0028] Figure 1 is the flowchart of the method for identifying baijiu brands and key metal elements according to the present invention;
[0029] Figure 2 is the schematic diagram of the confusion matrix of the baijiu brand classification result in the embodiment;
[0030] Figure 3 is the schematic diagram of the mean value ranking of the SHAP values of the metal elements corresponding to a certain brand in the embodiment;
[0031] Figure 4 is the schematic diagram of the device for identifying baijiu brands and key metal elements based on metal concentration in the present invention. Detailed Embodiments
[0032] As Figure 1 shown, the method for identifying liquor brands and key metal elements based on metal concentration according to the present invention includes the following steps:
[0033] Step 1: Obtain the metal element concentration and brand type of the liquor sample, and construct a metal element concentration - liquor brand type dataset.
[0034] The metal elements in the metal element concentration - liquor brand type dataset may include all metal elements that may be detected in liquor, and the specific metal elements selected in the metal element concentration - liquor brand type dataset are selected by the experimenter according to the situation.
[0035] In this embodiment, the liquor brand types in the metal element concentration - liquor brand type dataset include Brand 1, Brand 2, Brand 3, Brand 4, Brand 5, and Brand 6, and the metal elements include 17 metal elements such as Li, Na, K, Mg, Ca, etc., namely Metal 1 to Metal 17.
[0036] Before training the liquor brand classification model, preprocess the constructed metal element concentration - liquor brand type dataset. The specific preprocessing methods include:
[0037] Data augmentation: During the training process of the liquor brand classification model, perform data augmentation on the metal element concentration of the training set in the metal element concentration - liquor brand type dataset in the form of data fluctuations within a set small range;
[0038] Data standardization: Perform normalization processing on the metal element concentration data to eliminate the influence of different compound magnitudes;
[0039] The data standardization method needs to be executed in both the training and application stages of the liquor brand classification model, and the same standardization method needs to be used in the training and application stages of the liquor brand classification model.
[0040] In this embodiment, the sklearn.preprocessing.StandardScaler function is used to define the standardization method, and the metal element concentration is standardized to a distribution with a mean of 0 and a standard deviation of 1. In order to ensure that the same standardization parameters can be used in both model training and application, the pickle.dump function is used to save the standardized metal element concentration parameters as a pkl format file for subsequent reading.
[0041] Step 2: Use the metal element concentration as the input and the liquor brand type as the output to establish a liquor brand classification model, and train the liquor brand classification model based on the constructed metal element concentration - liquor brand type dataset.
[0042] The white liquor brand classification model is established based on one or more network structures among basic neural networks such as MLP, LSTM, RNN, CNN, GRU, and Transformer.
[0043] In this embodiment, based on the PyTorch library, an MLP network is used to build a white liquor brand classification model. Specifically:
[0044] class MetalBrandClassifier(nn.Module):
[0045] def __init__(self, input_size, num_classes):
[0046] super(MetalBrandClassifier, self).__init__()
[0047] self.fc1 = nn.Linear(input_size, 128)
[0048] self.fc2 = nn.Linear(128, 64)
[0049] self.fc3 = nn.Linear(64, num_classes)
[0050] self.relu = nn.ReLU()
[0051] self.dropout = nn.Dropout(0.2)
[0052] def forward(self, x):
[0053] x = self.relu(self.fc1(x))
[0054] x = self.dropout(x)
[0055] x = self.relu(self.fc2(x))
[0056] x = self.fc3(x)
[0057] return x
[0058] In this embodiment, since the established metal element concentration - white liquor brand type dataset considers 17 metal elements, the input dimension input_size = 17, and the other hyperparameters are: num_classes = 6.
[0059] The established dataset of metal element concentration - liquor brand type is divided into a training set and a test set, and the training set is used to train the liquor brand classification model.
[0060] During the training of the liquor brand classification model, the cross - entropy loss function is used to evaluate the difference between the prediction result of the liquor brand classification model and the probability distribution of the true labels. The cross - loss function is implemented based on the torch.nn.CrossEntropyLoss function, and the expression of the cross - loss function is:
[0061]
[0062] In the formula, M is the number of liquor samples; C is the number of liquor brands; p ij is the true liquor brand label of the i - th liquor sample corresponding to the j - th liquor brand; is the probability that the i - th liquor sample is predicted as liquor brand j.
[0063] The cross - loss function is implemented based on the torch.nn.CrossEntropyLoss function.
[0064] In this embodiment, as Figure 2 shown, brand classification with 100% accuracy for all test set data can be achieved.
[0065] Step 3: Embed a metal element feature contribution recognition module for analyzing the contribution of metal elements to the recognition result of liquor brand types into the trained liquor brand classification model.
[0066] The metal element feature contribution recognition module analyzes the contribution of metal elements to the liquor brand recognition result based on the SHAP algorithm, specifically including:
[0067] Calculating the SHAP value of each metal element for the recognition result of liquor brand types;
[0068] Evaluating the contribution of each metal element to the recognition result of liquor brand types according to the calculated SHAP values;
[0069] Sorting the contributions of all metal elements, and selecting the metal elements with contributions higher than the set value as key metal elements.
[0070] The SHAP algorithm is as follows:
[0071]
[0072] In the formula, φ jis the SHAP value of metal element data j; N is the set of all metal elements; S is the metal element subset; v(S) is the output value of the model when it only contains the metal element subset S; |S| is the size of the metal element subset S; |N| is the total number of metal elements.
[0073] In this embodiment, after the model training is completed, the SHAP values corresponding to the metal elements are calculated for all test set data. Taking brand 6 as an example, the mean ranking diagram of the SHAP values of the metal elements is as follows: Figure 3 As shown, it can be seen that metal elements 7, 11, 4, 9, and 15 are the five metal elements with the highest contribution to the SHAP value. Among them, metals 7, 11, and 9 have a positive effect on the classification of brand 6.
[0074] Step 4: The liquor brand classification model outputs the brand type of the liquor sample to be tested and the key metal elements that contribute most to liquor brand identification based on the metal element concentration of the liquor sample to be tested.
[0075] like Figure 4 As shown, the present invention also provides a device for identifying liquor brands and key metal elements based on metal concentration, the device comprising:
[0076] Dataset acquisition module: used to obtain the metal element concentration and liquor brand data of liquor samples and construct the metal element concentration-liquor brand dataset;
[0077] Model training module: Establish a liquor brand classification model and train the liquor brand classification model based on the constructed metal element concentration-liquor brand type dataset;
[0078] Key metal identification module: used to analyze the contribution of metal elements to the identification results of liquor brands;
[0079] Liquor brand classification module: Based on the trained liquor brand classification model, the metal element concentration of the liquor sample to be tested is input into the liquor brand classification model to obtain the liquor brand classification results, and identify the key metal element types that contribute most to the liquor brand type recognition results.
Claims
1. A method for identifying liquor brands and key metal elements based on metal concentration, characterized in that The method includes: Step 1: Obtain the metal element concentrations and brand types of baijiu samples, and construct a metal element concentration - baijiu brand type dataset; Step 2: Use the metal element concentrations as inputs and the baijiu brand types as outputs to establish a baijiu brand classification model, and train the baijiu brand classification model based on the constructed metal element concentration - baijiu brand type dataset; Step 3: Embed a metal element feature contribution recognition module for analyzing the contribution degree of metal elements to the recognition result of baijiu brand types into the trained baijiu brand classification model; Step 4: The baijiu brand classification model outputs the brand type of the baijiu sample to be tested and the key metal elements with high contribution degrees to the recognition of baijiu types based on the metal element concentrations of the baijiu sample to be tested.
2. The method for identifying liquor brands and key metal elements based on metal concentration according to claim 1, wherein The metal elements include: Li, Na, K, Mg, Ca, Ba, B, Al, Ti, Cr, Mn, Fe, Co, Ni, Cu, Zn.
3. The method for identifying liquor brands and key metal elements based on metal concentration according to claim 1, wherein It is characterized in that Step 1 further includes preprocessing the constructed metal element concentration - baijiu brand type dataset, and the preprocessing includes data standardization: normalizing the metal element concentration data in the metal element concentration - baijiu brand type dataset to eliminate the influence of different compound magnitudes.
4. The method for identifying the brand of Chinese liquor and key metal elements based on metal concentration according to claim 1, characterized in that, In Step 2, a baijiu brand classification model is established based on one or more of the MLP, LSTM, RNN, CNN, GRU, and Transformer models.
5. The method for identifying liquor brands and key metal elements based on metal concentration according to claim 1, wherein The metal element feature contribution recognition module analyzes the contribution degree of metal elements to the recognition result of baijiu brand types based on the SHAP algorithm, specifically including: Calculating the SHAP value of each metal element for the recognition result of baijiu brand types; Evaluating the contribution degree of each metal element to the recognition result of baijiu brand types according to the calculated SHAP values; Sorting the contribution degrees of all metal elements, and selecting the metal elements with contribution degrees higher than the set value as the key metal elements.
6. The method for identifying liquor brands and key metal elements based on metal concentration according to claim 1, wherein In Step 2, the training of the baijiu brand classification model includes: dividing the constructed metal element concentration - baijiu brand type dataset into a training set and a test set, using the training set to train the baijiu brand classification model, using the test set to evaluate the training effect of the baijiu brand classification model, and when the accuracy rate of the baijiu brand classification model on the test set is greater than the preset accuracy rate threshold, the training of the baijiu brand classification model is completed.
7. The method for identifying Chinese liquor brands and key metal elements based on metal concentration according to claim 1, wherein During the training process of the baijiu brand classification model in Step 2, the cross - entropy loss function is used to evaluate the difference between the prediction result of the baijiu brand classification model and the probability distribution of the true labels, and its expression is: Where M is the number of baijiu samples; C is the number of baijiu brands; p ij is the true baijiu brand label of the i-th baijiu sample corresponding to the j-th baijiu brand; is the probability that the i-th baijiu sample is predicted as the baijiu brand j.
8. A device for identifying liquor brands and key metal elements based on metal concentration, which is used to implement the method for identifying liquor brands and key metal elements based on metal concentration according to any one of claims 1-7, is characterized in that, The device includes: A dataset acquisition module: used to obtain the metal element concentrations and baijiu brand data of baijiu samples, and construct a metal element concentration - baijiu brand dataset; A model training module: establishes a baijiu brand classification model, and trains the baijiu brand classification model based on the constructed metal element concentration - baijiu brand type dataset; A key metal recognition module: used to analyze the contribution degree of metal elements to the recognition result of baijiu types; Baijiu brand classification module: Based on the trained baijiu brand classification model, input the metal element concentration of the baijiu sample to be tested into the baijiu brand classification model to obtain the baijiu brand classification result, and identify the key metal element types with a high contribution degree to the baijiu brand type recognition result.