Tea quality identification method based on near infrared spectrum direct feature extraction
Through the direct feature extraction method, feature extraction and data reduction of tea near-infrared spectra are solved, and the problems of subjective factors in tea quality identification and PCA compression information loss are achieved, and fast and accurate tea quality identification is achieved.
Patent Information
- Application Number
- CN202510698974.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-09-05
AI Technical Summary
The existing tea quality identification methods are greatly affected by subjective factors, the chemical detection cost is high and it is not suitable for large-scale applications. The accuracy of near-infrared spectral classification is limited by high-dimensional redundancy and small sample problems, and PCA compression leads to information loss.
The tea quality identification classifier was constructed by direct feature extraction and data dimensionality reduction by using direct feature extraction method. The tea leaf near-infrared spectrum was constructed through singular value decomposition and fuzzy membership calculation, and the K nearest neighbor classification algorithm was used for identification.
It realizes rapid and accurate identification of tea quality grades, is easy to operate, is intelligent and environmentally friendly, and is suitable for large-scale inspection.
Smart Images

Figure QLYQS_1 
Figure QLYQS_2 
Figure QLYQS_6
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of tea quality identification, and in particular to a tea quality identification method based on direct feature extraction of near-infrared spectroscopy. Background Art
[0002] Currently, tea grade identification methods are mainly based on human sensory evaluation and chemical testing. Human sensory evaluation is an old method for tea grade identification. Human sensory evaluation is the basis of tea quality identification. Based on the evaluator's feelings, the identification results are affected by the evaluator's subjective factors. Chemical testing is another commonly used method for tea grade identification. Due to the complex steps and high cost, the chemical testing method is not suitable for large-scale tea quality grade testing. In addition, there are other methods for identifying tea quality, such as electronic nose technology, hyperspectral technology, computer vision technology, etc. Compared with these methods, the near-infrared (NIR) method has the advantages of simple operation, low cost, and short time for tea grade classification.
[0003] However, near-infrared spectra have the characteristics of high dimensionality, redundancy, and overlap, which limit the accuracy of subsequent classification. The commonly used qualitative or quantitative analysis process of near-infrared spectra is: first preprocess the spectrum, then perform feature selection and feature extraction on the spectrum, and finally perform classification or regression operations. Feature extraction is very important for accurate classification. When the sample dimension is greater than the number of samples, a small sample problem will arise. The high-dimensional features of near-infrared data are often accompanied by a small sample problem. In order to solve the small sample problem, a commonly used method is principal component analysis (PCA) + linear feature extraction method (LDA), that is, first use PCA to compress the near-infrared spectrum and then use LDA for feature extraction. However, some identification information will be lost during PCA compression, resulting in inaccurate classification. Summary of the Invention
[0004] To address the shortcomings of the existing technology, the present invention proposes a tea quality identification method based on direct feature extraction from near-infrared spectra. This method uses a direct feature extraction method to extract features and reduce the dimensionality of tea near-infrared spectra, and then identifies tea quality grades based on the feature data and a classification model. This method eliminates the need for PCA dimensionality reduction and instead directly extracts and reduces the dimensionality of tea near-infrared spectra. This method extracts linear and nonlinear feature information from tea near-infrared spectra, thereby accurately identifying tea quality grades. The method offers the advantages of rapid detection, high classification accuracy, ease of operation, intelligent operation, and environmental friendliness.
[0005] The technical solutions adopted in the present invention are as follows:
[0006] A method for identifying tea quality by direct feature extraction using near-infrared spectroscopy specifically comprises the following steps:
[0007] Step 1: Obtain the near-infrared spectrum of the tea to be identified and perform preprocessing.
[0008] Step 2: Direct feature extraction method is used to extract features and reduce data dimension of tea near-infrared spectrum;
[0009] Step 3: Use the extracted tea feature data to train a tea quality identification classifier, and use the tea quality identification classifier to perform quality identification.
[0010] Furthermore, in step 1, near-infrared spectral data are obtained using an Antaris II near-infrared spectrometer.
[0011] Furthermore, in step 1, tea soup of the tea to be identified is prepared, and the tea soup is measured using a near-infrared spectrometer.
[0012] Furthermore, the near-infrared spectrum of tea was preprocessed using Savitzky-Golay filtering and multivariate scattering correction.
[0013] Furthermore, the direct feature extraction method comprises the following steps:
[0014] S2.1 Assume a training sample set X consisting of n samples in d-dimensional space, X = [x1, x2, x3, ..., x n ]; a test sample set X′ consisting of n1 samples in d-dimensional space,
[0015] Divide the training samples into c categories n≥c; S w is the intra-class scattering matrix of the training sample set X, S b The inter-class scattering matrix of the training sample set X, S t is the overall scattering matrix of the training sample set X;
[0016] To S t Perform singular value decomposition to obtain the orthogonal matrix P composed of the first r orthogonal vectors, and construct a new intra-class scattering matrix: S′ w =P T S w P, new inter-class scattering matrix: S b ′=P T S b P, set the regularized intra-class scattering matrix: S w * =S′ w +λI, where λ is the regularization parameter, λ∈(0,1), and I is the identity matrix;
[0017] To S w * Perform singular value decomposition and get:
[0018]
[0019] Among them, U w is an orthogonal matrix, D w is a diagonal matrix;
[0020] S2.2 Search D w Elements on the upper diagonal Satisfy Diagonal matrix Under the definition:
[0021]
[0022] Where I is the identity matrix, using the matrix For the matrix S b 'Diagonalize it and get:
[0023]
[0024] Where F is an orthogonal matrix;
[0025] Therefore, the transformation matrix
[0026] S2.3 projects the training sample set X onto the transformation matrix W1 to obtain the training sample set Z, which is denoted as:
[0027] Z=[z1,z2,z3,…,z n ]
[0028] Calculate the fuzzy membership μ of the new training sample set Z ij :
[0029]
[0030] Among them, μ ij Represents the jth training sample z j The degree of belonging to category i, is the average value of the training samples of the i-th category, is the average value of the k-th class training samples;
[0031] S2.4 Calculate the j-th fuzzy membership matrix U j
[0032]
[0033] Based on the fuzzy membership matrix U j , calculate the intra-class fuzzy kernel matrix K respectively fW and the inter-class fuzzy kernel matrix K fB :
[0034]
[0035] Among them, 1≤j≤c, 1≤i≤n, 1≤k≤n, 1≤s≤n.
[0036] S2.5 Matrix K according to S2.4 fW and K fB Constructing a Matrix And perform singular value decomposition on the matrix N: Among them, R is a diagonal matrix, K c is an orthogonal matrix, and Q is a unitary matrix obtained by decomposing the matrix N by singular value.
[0037] Let t = rank (N), according to the matrix K c Singular value decomposition of (1:c,1:t) to calculate the matrix K Y :
[0038] U T K c (1:c,1:t)K Y =∑Calculation Matrix K Z
[0039]
[0040] Among them, K Z The first c-1 columns of form the transformation matrix W2, I is the identity matrix, and ∑ is a diagonal matrix;
[0041] S2.6 projects the training sample set Z of S2.3 onto the transformation matrix W2 to obtain the training sample set D. D=[d1,d2,d3,…,d n ]; Project the test sample set of S2.1 onto the transformation matrix W1 and W2 successively to obtain the test sample set D′, Furthermore, the orthogonal matrix is denoted as F = [F α ,F β ], F α It's S b ′ is a matrix composed of eigenvectors corresponding to non-zero eigenvalues, and F β is the matrix S b ′ is a matrix composed of eigenvectors corresponding to zero eigenvalues.
[0042] Furthermore, the tea quality identification classifier was trained and tested using the data processed by the direct feature extraction method.
[0043] Furthermore, the tea quality identification classifier adopts the K-nearest neighbor classification algorithm.
[0044] Furthermore, the method is applicable to the quality identification of other leaf-type crops.
[0045] Beneficial effects of the present invention:
[0046] (1) The present invention proposes a method for identifying tea quality by directly extracting features from near-infrared spectra, which can directly extract identification information from the near-infrared spectra of tea without first using PCA to compress the spectrum, thereby solving the problem that some identification information is lost when PCA compresses the near-infrared spectrum.
[0047] (2) The present invention has the advantages of fast detection speed, high classification accuracy, convenient operation, intelligence, and green environmental protection.
[0048] (3) The present invention can be used for identifying the quality grade of tea, and can also be used for extracting and analyzing the near-infrared spectrum identification information of other foods. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 It is a flow chart of the present invention.
[0050] Figure 2 This is the near-infrared spectrum of the tea sample.
[0051] Figure 3 This is the near-infrared spectrum of tea leaves after pretreatment.
[0052] Figure 4 It is a three-dimensional data graph of the training sample set Z.
[0053] Figure 5 It is the fuzzy membership graph of the training sample set Z.
[0054] Figure 6 It is a three-dimensional data graph of the training sample set D.
[0055] Figure 7 It is a three-dimensional data graph of the test sample set D′. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0057] like Figure 1 As shown, the present invention proposes a method for identifying tea quality by direct feature extraction of near-infrared spectroscopy, and its specific operating steps are as follows:
[0058] Step 1: Obtain the near-infrared spectrum data of the tea sample to be identified and perform preprocessing.
[0059] In this example, six grades of Meicha tea were selected: special grade one, special grade two, grade one, grade two, grade three, and grade four. Sixty samples were collected for each grade, for a total of 180 samples. 3.0 g of tea sample was weighed using an electronic scale and placed in a beaker. 150 ml of 100°C hot water was then poured into the beaker. After the tea broth cooled to room temperature, the tea residue was filtered, and a small amount of the broth was aspirated using a pipette and placed into a quartz dish. The tea broth was then measured using a near-infrared spectrometer. The laboratory temperature and relative humidity were maintained relatively constant, and the Antaris II near-infrared spectrometer was preheated for one hour. Near-infrared spectra of the tea were collected using a reflectance integrating sphere mode. The near-infrared spectrometer scanned each sample 32 times to obtain the average diffuse reflectance spectrum. The spectral scans were performed at a wavenumber range of 10,000 to 4,000 cm⁻¹, with a scan interval of 3.857 cm⁻¹. The spectrum collected for each tea sample consisted of 1557-dimensional data. Each sample was sampled three times, and the average value was used as experimental data for subsequent model development. The near infrared spectrum of eyebrow tea sample is as follows Figure 2 shown.
[0060] In this embodiment, the near infrared spectrum of tea leaves is preprocessed using Savitzky-Golay filtering and multivariate scattering correction (MSC). Figure 3 shown.
[0061] Step 2: Use a direct feature extraction method to perform feature extraction and data dimensionality reduction on the pre-processed tea near-infrared spectrum in S2, and then extract the linear and nonlinear identification information of the tea near-infrared spectrum. The specific steps are as follows:
[0062] S2.1 Assume that a training sample set X consists of n = 252 samples in a d = 1557-dimensional space, X = [x1, x2, x3, ..., x 252 A test sample set X′ consists of n1=108 samples in d=1557 dimensional space, X′=[x′1,x′2,x′3,…,x′ 108 ] The training samples are divided into c = 6 categories, n = 252 is the number of training samples (n ≥ c), and c is the number of categories. w is the intra-class scattering matrix of the training sample set X, S b The inter-class scattering matrix of the training sample set X, S t is the overall scattering matrix of the training sample set X.
[0063] To S t Perform singular value decomposition to obtain r = 250 (r is S t The orthogonal matrix P composed of orthogonal vectors of rank) is constructed to construct a new intra-class scattering matrix S′ w =P T S wP, the new inter-class scattering matrix S′ b =P T S b P. Set the regularized intra-class scattering matrix as follows:
[0064] S w * =S′ w +λI
[0065] Where λ is the regularization parameter, λ = 0.2, I is the identity matrix. w * Perform singular value decomposition and get:
[0066]
[0067] Among them U w is an orthogonal matrix, D w is a diagonal matrix.
[0068] Calculation results:
[0069] S2.2 Search D w Elements on the upper diagonal Satisfy Diagonal matrix Under the definition:
[0070]
[0071] Where I is the identity matrix. Using the matrix For the matrix S b 'Diagonalize it and get:
[0072]
[0073] Among them, the orthogonal matrix F=[F α ,F β ]. F α It's S b ′ is a matrix composed of eigenvectors corresponding to non-zero eigenvalues, and F β is the matrix S b ′ is a matrix composed of eigenvectors corresponding to zero eigenvalues. Therefore, the transformation matrix
[0074] Calculation results:
[0075] S2.3 Project the training sample set X onto the transformation matrix W1 to obtain the training sample set Z. Z=[z1,z2,z3,…,z n ]. The three-dimensional data diagram of the training sample set Z is as follows Figure 4 As shown. Calculate the fuzzy membership μ of the new training sample set Z ij :
[0076]
[0077] μ ij Represents the jth (1≤j≤n) training sample z j The degree of belonging to the i-th (1≤i≤c) class, is the average value of the training samples of the i-th category, is the average value of the k-th class training samples. Figure 5 shown.
[0078] S2.4 Calculate the j-th fuzzy membership matrix U j
[0079]
[0080] Calculate the intra-class fuzzy kernel matrix K separately fW and the inter-class fuzzy kernel matrix K fB :
[0081]
[0082] Among them, 1≤j≤c, 1≤i≤n, 1≤k≤n, 1≤s≤n.
[0083] Calculation results:
[0084]
[0085] S2.5 Matrix K according to S2.4 fW and K fB Constructing a Matrix And perform singular value decomposition on the matrix N: Among them, r is a diagonal matrix, K c is an orthogonal matrix, and Q is a unitary matrix obtained by decomposing the matrix N by singular value.
[0086] Let t = rank (N) = 5, according to the matrix K c Singular value decomposition of (1:6,1:5) to calculate the matrix K Y :
[0087] U T K c (1:6,1:5)K Y =∑Calculation Matrix K Z
[0088]
[0089] K Z The first five columns of form the matrix W2, which is the transformation matrix. I is the identity matrix, and ∑ is a diagonal matrix.
[0090] Calculation results:
[0091] S2.6 projects the training sample set Z of S2.3 onto the transformation matrix W2 to obtain the training sample set D. D=[d1,d2,d3,…,d n ]. The three-dimensional image of the training sample set D is as follows Figure 6 As shown. The test sample set of S3.1 is projected onto the transformation matrix W1 and W2 to obtain the test sample set D′. The three-dimensional graph of the test sample set D′ is as follows Figure 7 shown.
[0092] Step 3: Use the extracted tea feature data to train a tea quality identification classifier, and use the tea quality identification classifier to perform quality identification.
[0093] In this embodiment, based on the data set obtained in steps 1 and 2, a tea quality identification classifier is trained using the data set, and the trained tea quality identification classifier is used to perform tea quality identification.
[0094] In this embodiment, the tea quality identification classifier uses the K-nearest neighbor classification algorithm. Experimental results show that when the K value of the K-nearest neighbor classification algorithm is 1, the classification accuracy of the test sample set reaches 97.5%.
[0095] In this embodiment, only tea is used as the identification object for illustration. In addition to tea, the present invention can also be applied to the quality identification of other crops, such as beans (black beans, soybeans, etc.), Fritillaria, wolfberry, red dates, etc.
[0096] The above embodiments are intended only to illustrate the design concepts and features of the present invention. Their purpose is to enable those skilled in the art to understand the contents of the present invention and implement them accordingly. The scope of protection of the present invention is not limited to the above embodiments. Therefore, any equivalent changes or modifications made based on the principles and design concepts disclosed in the present invention are within the scope of protection of the present invention.
Claims
1. A method for identifying tea quality by direct feature extraction using near-infrared spectroscopy, characterized in that: Specifically include the following steps: Step 1: Obtain the near-infrared spectrum of the tea to be identified and perform preprocessing. Step 2: Direct feature extraction method is used to extract features and reduce data dimension of tea near-infrared spectrum; Step 3: Use the extracted tea feature data to train a tea quality identification classifier, and use the tea quality identification classifier to perform quality identification.
2. The method for identifying tea quality by direct feature extraction using near infrared spectroscopy according to claim 1, wherein: In step 1, near-infrared spectral data were obtained using an Antaris II near-infrared spectrometer.
3. The tea quality identification method based on direct feature extraction of near infrared spectroscopy according to claim 1, characterized in that: In step 1, tea soup of the tea to be identified is prepared, and the tea soup is measured using a near-infrared spectrometer.
4. The method for identifying tea quality by direct feature extraction using near infrared spectroscopy according to claim 1, wherein: Savitzky-Golay filtering and multivariate scattering correction were used to preprocess the near-infrared spectra of tea.
5. The method for identifying tea quality by direct feature extraction using near infrared spectroscopy according to claim 1, wherein: The direct feature extraction method comprises the following steps: S2.1 Assume a training sample set X consisting of n samples in d-dimensional space, X = [x1, x2, x3, ..., x n ]; a test sample set X′ consisting of n1 samples in d-dimensional space, Divide the training samples into c categories n≥c; S w is the intra-class scattering matrix of the training sample set X, S b The inter-class scattering matrix of the training sample set X, S t is the overall scattering matrix of the training sample set X; To S t Perform singular value decomposition to obtain the orthogonal matrix P composed of the first r orthogonal vectors, and construct a new intra-class scattering matrix: S′ w =P T S w P, new inter-class scattering matrix: S b ′=P T S b P, set the regularized intra-class scattering matrix: S w * = S′ w +λI, where λ is the regularization parameter, λ∈(0,1), and I is the identity matrix; To S w * Perform singular value decomposition and get: Among them, U w is an orthogonal matrix, D w is a diagonal matrix; S2.2 Search D w Elements on the upper diagonal Satisfy Diagonal matrix Under the definition: Where I is the identity matrix, using the matrix For the matrix S b 'Diagonalize it and get: Where F is an orthogonal matrix; Therefore, the transformation matrix S2.3 projects the training sample set X onto the transformation matrix W1 to obtain the training sample set Z, which is denoted as: Calculate the fuzzy membership μ of the new training sample set Z ij : Among them, μ ij Represents the jth training sample z j The degree of belonging to category i, is the average value of the training samples of the i-th category, is the average value of the k-th class training samples; S2.4 Calculate the j-th fuzzy membership matrix U j Based on the fuzzy membership matrix U j , calculate the intra-class fuzzy kernel matrix K respectively fW and the inter-class fuzzy kernel matrix K fB : Among them, 1≤j≤c, 1≤i≤n, 1≤k≤n, 1≤s≤n. S2.5 Matrix K according to S2.4 fW and K fB Constructing a Matrix And perform singular value decomposition on the matrix N: Among them, R is a diagonal matrix, K c is an orthogonal matrix, and Q is a unitary matrix obtained by decomposing the matrix N by singular value. Let t = rank (N), according to the matrix K c Singular value decomposition of (1:c,1:t) to calculate the matrix K Y : Calculate the matrix K Z Among them, K Z The first c-1 columns of form the transformation matrix W2, I is the identity matrix, and ∑ is a diagonal matrix; S2.6 projects the training sample set Z of S2.3 onto the transformation matrix W2 to obtain the training sample set D. D=[d1,d2,d3,…,d n ]; Project the test sample set of S2.1 onto the transformation matrix W1 and W2 successively to obtain the test sample set D′, .
6. The method for identifying tea quality by direct feature extraction using near infrared spectroscopy according to claim 5, wherein: The orthogonal matrix is denoted as F = [F α ,F β ], F α It's S b ′ is a matrix composed of eigenvectors corresponding to non-zero eigenvalues, and F β is the matrix S b ′ is a matrix composed of eigenvectors corresponding to zero eigenvalues.
7. The method for identifying tea quality by direct feature extraction using near infrared spectroscopy according to claim 1, wherein: The tea quality identification classifier was trained and tested using data processed by direct feature extraction method.
8. The method for identifying tea quality by direct feature extraction using near infrared spectroscopy according to claim 1, wherein: The tea quality identification classifier adopts K-nearest neighbor classification algorithm.
9. The method for identifying tea quality by direct feature extraction using near infrared spectroscopy according to claim 1, wherein: Suitable for quality identification of other crops.
Citation Information
Cited By
Rapid identification method for tea category and grade based on near infrared spectrum
CN122193148A