Traditional Chinese medicine processing quality detection method based on spectral analysis
By establishing isolated forests and calculating the characteristic wavenumber possibility and abnormal scores of traditional Chinese medicine samples, the problem of insufficient accuracy of quality detection of traditional Chinese medicine preparation is solved, and higher detection accuracy and support for traditional Chinese medicine quality control is achieved.
Patent Information
- Application Number
- CN202510551396.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-04-29
AI Technical Summary
During the preparation of traditional Chinese medicine, the prior art lacks accuracy in quality detection, especially due to the complex composition of the medicinal material and the influence of spectral noise, the characteristic peak evaluation of the NIR spectrum is inaccurate.
By establishing a first isolated forest based on NIR spectrum, the possibility and final possibility of the characteristic wave number are calculated, and the adjacent repeated wave number is removed to obtain the characteristic wave number. Then, the reference value of the characteristic wave number is obtained using the HPLC fingerprint map, a second isolated forest is established, the abnormal score of the traditional Chinese medicine sample is calculated, and its quality is evaluated.
It improves the accuracy of quality testing of traditional Chinese medicine preparation, can more accurately distinguish and evaluate the quality of traditional Chinese medicine samples, significantly improves the accuracy of testing, and provides strong support for quality control of traditional Chinese medicine.
Smart Images

Figure CN120064203A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traditional Chinese medicine quality detection, and particularly to a method for detecting the quality of processed traditional Chinese medicine based on spectral analysis. Background Art
[0002] Traditional Chinese medicine processing is a traditional technique and method for processing Chinese medicinal materials into Chinese medicine decoction pieces according to traditional Chinese medicine theory, in accordance with the needs of syndrome differentiation and treatment, the nature of the drugs themselves, and different requirements for dispensing and preparation. During the process of traditional Chinese medicine processing, there will be an increase in the content of active ingredients, the destruction of toxic substances, and chemical changes in other components. The processing effect, that is, the quality of Chinese medicinal materials, directly determines the quality of Chinese patent medicines. For a long time, the quality detection of traditional Chinese medicine processing has relied on empirical discrimination and lacks standard instrumental analysis. Traditional quality detection means, such as microscopic identification method and chromatographic analysis method, mostly require sample pretreatment, the analysis process is complex and time-consuming, and the capital cost is also relatively high.
[0003] Near-infrared spectroscopy (NIR) can achieve rapid, non-destructive and on-line quality detection of Chinese medicinal materials. However, in practical applications, especially for Chinese medicinal materials with complex components, taking Gastrodia elata as an example, as a plant traditional Chinese medicine with complex components, its main active ingredients mainly include phenolic components such as gastrodin, sugars, and active proteins. Due to different factors such as the source of medicinal materials, cultivation conditions, growth years, and harvesting seasons, these factors all affect the quality of the medicinal materials. Therefore, the NIR spectra of different samples of the same processed traditional Chinese medicine may have large differences, and due to the complex light absorption characteristics of solid traditional Chinese medicine, it is easy to introduce spectral noise and errors, resulting in the problem of insufficient accuracy in directly evaluating the quality of medicinal materials through the characteristic peaks of NIR spectra. Summary of the Invention
[0004] In order to solve the technical problem of insufficient accuracy in the quality detection of medicinal materials, the purpose of the present invention is to provide a method for detecting the quality of processed traditional Chinese medicine based on spectral analysis. The specific technical solutions adopted are as follows: Establish a first isolation forest based on the wave numbers in the NIR spectrum of the processed traditional Chinese medicine sample, calculate the possibility and the final possibility that the wave number is a characteristic wave number, and select the wave number according to the final possibility and remove adjacent repeated wave numbers to obtain the characteristic wave number; Obtain the reference value of the characteristic wave number according to the HPLC fingerprint spectrum of the traditional Chinese medicine sample, select the processed traditional Chinese medicine sample and place it at the root node, use the reference value of the characteristic wave number randomly selected for the first time as the splitting value, and when the characteristic wave number is randomly selected non-first time, set the splitting value as a random number between the maximum value and the minimum value of the sample, and establish a second isolation forest; In the second isolation forest, the traditional Chinese medicine samples in the right subtree and the left subtree of the isolation tree are respectively encoded as a first value and a second value, and the probability that the target characteristic wave number is qualified is obtained according to the final possibility, the tree depth difference value between the traditional Chinese medicine sample and the target characteristic wave number in the isolation tree, and the encoding information, and the anomaly score of the traditional Chinese medicine sample is obtained according to the probability. Obtain a reference sample of the traditional Chinese medicine sample to be tested, and determine the quality of the traditional Chinese medicine sample to be tested according to the anomaly score of the reference sample.
[0005] Further, the process of obtaining the possibility includes: Take the opposite of the absolute value of the balance factor of the j-th isolation tree in the isolation forest of the i-th wave number as the input value of the exponential function with the natural constant e as the base, and obtain the split absolute value by subtracting the minimum split value from the maximum split value of the j-th isolation tree in the isolation forest of the i-th wave number and then taking the absolute value. Multiply the split absolute value by the output value of the exponential function as the possibility component that the i-th wave number is the characteristic wave number in the j-th isolation tree, and repeat the process of obtaining the possibility component to obtain the possibility component that the i-th wave number is the characteristic wave number in each isolation tree, where the value range of i is from 1 to the number of wave numbers, and the value range of j is from 1 to the number of isolation trees. Obtain the normalized value of the average of the possibility components as the possibility that the i-th wave number is the characteristic wave number.
[0006] Further, the process of obtaining the final possibility includes: In the isolation forest of the i-th wave number, obtain the sum of the absolute values of the differences in tree depth distances between any two traditional Chinese medicine samples with different backgrounds in different isolation trees. Multiply the normalized value of the sum of the absolute values by the possibility that the i-th wave number is the characteristic wave number to obtain the final possibility that the i-th wave number is the characteristic wave number.
[0007] Further, the removal of adjacent repeated wave numbers includes: Obtain the change consistency value of two adjacent wave numbers, and when the change consistency value is greater than the preset change threshold, remove the wave number with the smaller final possibility among the two adjacent wave numbers.
[0008] Further, the process of obtaining the change consistency value includes: Obtain the first absolute value of the difference between the reflectivity change difference values of any two traditional Chinese medicine samples, where the reflectivity change difference value represents the second absolute value of the difference in reflectivity between two adjacent wave numbers. Add up the first absolute values in sequence to obtain the sum of the first absolute values, and use the opposite number of the sum of the first absolute values as the input value of the exponential function with the natural constant e as the base. The output value of the exponential function is the change consistency value.
[0009] Further, the process of obtaining the reference value of the characteristic wave number includes: According to the HPLC fingerprint map, obtain the content of the active ingredients of any of the processed traditional Chinese medicine samples. The average reflectance of the characteristic wave numbers corresponding to the traditional Chinese medicine samples with the lowest qualified content is used as the reference value of the characteristic wave number.
[0010] Further, the process of obtaining the probability includes: In any of the isolated trees, calculate the sum of the coding ratios. The coding ratio is the a-th coding divided by the serial number of the a-th coding, where the value range of a is from 1 to the tree depth difference value, and the tree depth difference value is the difference between the depth of the leaf node where the traditional Chinese medicine sample is located and the depth at which the i-th wave number first appears. Calculate the sum of the sums of the coding ratios corresponding to each of the isolated trees. The normalized value after multiplying the sum by the final possibility that the i-th wave number is the characteristic wave number is used as the probability that the target characteristic wave number is qualified, where the i-th wave number is the target characteristic wave number.
[0011] Further, the process of obtaining the anomaly score includes: Use the opposite number of the probability that the target characteristic wave number is qualified as the input value of the exponential function with the natural constant e as the base. The output value of the exponential function is used as the anomaly score component, where the value range of the target characteristic wave number is from 1 to the number of characteristic wave numbers. Use the normalized value of the sum of the anomaly score components as the anomaly score of the traditional Chinese medicine sample.
[0012] Further, the process of obtaining the reference sample includes: Calculate the minimum value after accumulating and summing the absolute values of the differences in reflectance of each of the characteristic wave numbers corresponding to the traditional Chinese medicine sample to be tested and the traditional Chinese medicine sample. The traditional Chinese medicine sample corresponding to the minimum value is the reference sample.
[0013] Further, determining the quality of the traditional Chinese medicine sample to be tested according to the anomaly score of the reference sample includes: When the anomaly score of the reference sample is greater than the first anomaly threshold, the quality of the traditional Chinese medicine sample to be tested is unqualified. When the anomaly score of the reference sample is greater than the second anomaly threshold and less than or equal to the first anomaly threshold, the quality of the traditional Chinese medicine sample to be tested is passing. When the anomaly score of the reference sample is less than or equal to the second anomaly threshold, the quality of the traditional Chinese medicine sample to be tested is good.
[0014] The present invention has the following beneficial effects: First, a first isolation forest is established based on the wave numbers in the NIR spectrum of the processed traditional Chinese medicine sample, the possibility and the final possibility of the wave number being a characteristic wave number are calculated, and the wave number is selected according to the final possibility and adjacent repeated wave numbers are removed to obtain the characteristic wave number. The characteristic wave number is regarded as the characteristic of the traditional Chinese medicine sample, and the characteristic can play a role in distinguishing the traditional Chinese medicine sample.
[0015] Second, a reference value of the characteristic wave number is obtained according to the HPLC fingerprint of the traditional Chinese medicine sample. The processed traditional Chinese medicine sample is placed at the root node, and the reference value of the characteristic wave number randomly selected for the first time is used as the splitting value. When the characteristic wave number is randomly selected non-first time, the splitting value is set to a random number between the maximum value and the minimum value of the sample, and a second isolation forest is established. The second isolation forest is the basis for obtaining the anomaly score subsequently.
[0016] Furthermore, in the second isolation forest, the traditional Chinese medicine samples in the right subtree and the left subtree of the isolation tree are respectively encoded as a first value and a second value, and the probability that the target characteristic wave number is qualified is obtained according to the final possibility, the difference value of the tree depth between the traditional Chinese medicine sample in the isolation tree and the target characteristic wave number, and the coding information, and the anomaly score of the traditional Chinese medicine sample is obtained according to the probability. Each traditional Chinese medicine sample has a corresponding anomaly score.
[0017] Finally, a reference sample of the traditional Chinese medicine sample to be tested is obtained, and the quality of the traditional Chinese medicine sample to be tested is determined according to the anomaly score of the reference sample. The reference sample is the traditional Chinese medicine sample with the smallest difference from the traditional Chinese medicine sample to be tested, and the anomaly score of the reference sample is the anomaly score of the traditional Chinese medicine sample to be tested. The higher the anomaly score, the worse the sample quality.
[0018] The present invention uses the isolation forest algorithm for multiple traditional Chinese medicine samples, analyzes the correlation and characteristic performance between each wavelength in the spectral data, extracts the key features for anomaly detection, accurately calculates the anomaly score of the traditional Chinese medicine sample to be tested, and evaluates its quality status accordingly, thereby realizing the quality detection of the traditional Chinese medicine processing process. The application of the present invention can significantly improve the accuracy of detection and provide strong support for the quality control of traditional Chinese medicine. Description of the Drawings
[0019] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0020] Figure 1 Flow chart of the traditional Chinese medicine processing quality detection method based on spectral analysis provided by the first embodiment of the present invention; Figure 2 Flow chart of the process for obtaining possibilities provided by the second embodiment of the present invention; Figure 3 Flow chart of the process for obtaining final possibilities provided by the third embodiment of the present invention; Figure 4 Flow chart of the process for obtaining the change consistency value provided by the fourth embodiment of the present invention; Figure 5 Flow chart of the process for obtaining probabilities provided by the fifth embodiment of the present invention; Figure 6 Flow chart of the process for obtaining anomaly scores provided by the sixth embodiment of the present invention. Detailed implementation manners
[0021] In order to further elaborate on the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation manners, structures, features, and effects of the traditional Chinese medicine processing quality detection method based on spectral analysis proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present invention belongs.
[0023] The following specifically describes the specific solution of the traditional Chinese medicine processing quality detection method based on spectral analysis provided by the present invention in conjunction with the accompanying drawings.
[0024] Please refer to Figure 1 , which shows the flow chart of the traditional Chinese medicine processing quality detection method based on spectral analysis provided by the first embodiment of the present invention, and the method includes: S101. Establish a first isolation forest based on the wave numbers in the NIR spectrum of the processed traditional Chinese medicine sample, calculate the possibility and the final possibility of the wave numbers as characteristic wave numbers, and select the wave numbers according to the final possibility and remove adjacent duplicate wave numbers to obtain the characteristic wave numbers.
[0025] Data preparation: Taking Gastrodia elata as an example, a number of Gastrodia elata from different producing areas, different production years, and different collection seasons are obtained. Gastrodia elata with the same producing area, the same production year, and the same collection time is recorded as Gastrodia elata with the same background. All Gastrodia elata are processed according to the processing description in the Chinese Pharmacopoeia under the same conditions. After completion, each Gastrodia elata is equally divided into several samples.
[0026] The processing of Gastrodia elata slices is as follows: wash, moisten thoroughly or steam until soft, cut into thin slices, and dry.
[0027] Conditions: The steaming condition is 42 minutes at 100 °C, and the drying condition is 48 minutes at 50 °C.
[0028] Take a thin slice of a sample of all Gastrodia elata every 10 minutes. Use a spectrometer, fiber optic sampling, with a scanning range of 4000 - 10000 (wave number / cm), and the resolution is 8 . Scan each thin slice three times. Perform preprocessing on the spectrum of each scanned thin slice, including polynomial filtering and multivariate signal correction. Take the mean value of the spectra of the three scans after preprocessing (the vertical axis is the logarithm of the reflectance corresponding to the wave number log(1 / R), hereinafter referred to as the reflectance) as the spectrum of the sample.
[0029] The core of the Isolation Forest algorithm lies in its ability to efficiently identify isolated points that deviate from the main aggregation area in the dataset. When processing the spectral data of all samples, each wave number is regarded as a unique feature. Given that light produces different responses when interacting with different components, the range of feature values and the feedback on the active ingredients of each sample are different. Therefore, using the principle of the Isolation Forest, the key characteristic wave numbers can be accurately screened out. On the other hand, during the processing of traditional Chinese medicine, the content of active ingredients increases, toxic substances are degraded, and the interaction between components will also lead to an enhanced correlation between spectral features. By analyzing the spectral changes of Gastrodia elata samples with the same background during the processing, the wave numbers most relevant to the processing technology can be identified, thereby further determining the characteristic wave numbers.
[0030] For the processed samples, each characteristic wave number can be analyzed as an independent feature. Since the feature values of different samples are different, and the feature values of unqualified Gastrodia elata often have uniqueness, the Isolation Forest algorithm can be used again to identify abnormal samples. However, considering the complex background differences, there may be significant feature differences between different Gastrodia elata. Therefore, the aggregation area does not necessarily completely represent normal samples, and outlier data is not necessarily abnormal data. Therefore, after training the Isolation Forest, when calculating the anomaly score, the feature value needs to be considered rather than just the division speed.
[0031] The reflectance of traditional Chinese medicine samples at any wavenumber is regarded as one-dimensional data, and an ordered binary tree is established (the data of any node is greater than the data of all its left subtrees and less than the data of all its right subtrees). All the data is placed at the root node, and a splitting value is randomly selected between the maximum and minimum values. The one-dimensional data is continuously split until all the data is separately placed at the leaf nodes. In this isolated tree, for any leaf node, the more times of splitting required, the higher the degree of data aggregation, and the less suitable the wavenumber is as a characteristic wavenumber. And the more average the number of splits between leaf nodes is, the more average the data distribution is, and thus the more it can play a role in distinguishing samples. Therefore, the more it can be used as a characteristic wavenumber.
[0032] Due to the correlation of features, for example, as the processing progresses, there is a high consistency in the change of sample characteristic values at some wavenumbers, and they change by the same amplitude at the same time. Then, not all of these wavenumbers need to be used as characteristic wavenumbers. The changes at different times reflect the sequence of component changes and can also be used as characteristic wavenumbers.
[0033] The process of obtaining the said possibility will be described in detail in the second embodiment and will not be elaborated here.
[0034] The process of obtaining the said final possibility will be described in detail in the third embodiment and will not be elaborated here.
[0035] Selecting the wavenumbers according to the said final possibility and removing adjacent duplicate wavenumbers to obtain the said characteristic wavenumbers specifically includes: Arrange the said final possibility in descending order, and select the wavenumbers of the top preset percentage. The preset percentage can be set independently, preferably 10%.
[0036] The said removing adjacent duplicate wavenumbers includes: Obtain the change consistency value of two adjacent said wavenumbers. When the change consistency value is greater than the preset change threshold, remove the wavenumber with the smaller said final possibility among the two adjacent said wavenumbers.
[0037] The said preset change threshold can be set independently, preferably 0.7.
[0038] Remove adjacent duplicate wavenumbers until all wavenumbers are non-adjacent.
[0039] The process of obtaining the said change consistency value will be described in detail in the fourth embodiment and will not be elaborated here.
[0040] S102. Obtain the reference value of the characteristic wave number according to the HPLC fingerprint of the traditional Chinese medicine sample. Select the prepared traditional Chinese medicine sample and place it at the root node. The reference value of the characteristic wave number randomly selected for the first time is used as the splitting value. When the characteristic wave number is randomly selected non-first time, the splitting value is set to a random number between the maximum value and the minimum value of the sample, and a second isolation forest is established.
[0041] The prepared traditional Chinese medicine samples include traditional Chinese medicine samples of all backgrounds. Regarding the characteristic wave numbers as features, select some traditional Chinese medicine samples, and each time use any feature as the splitting feature, randomly select the splitting value between the maximum value and the minimum value until all traditional Chinese medicine samples become single leaf nodes, and an isolation tree is established. In this process, the leaf nodes with larger tree depths are more difficult to distinguish. If the number of unqualified traditional Chinese medicine samples is small, the leaf nodes with smaller tree depths are more likely to be unqualified traditional Chinese medicine samples. However, there are two problems in this process. One is that the selection of features is accidental, and only the features related to the active ingredients and the harmful ingredients can prove the unqualifiedness of the sample. The other is that the number of unqualified traditional Chinese medicine samples is uncertain, which also leads to the uncertainty of the tree depth for unqualified traditional Chinese medicine samples.
[0042] To solve the above problems, in-depth learning can be carried out on the various features of qualified traditional Chinese medicine samples and used as a reference for setting the splitting value. In this way, the unqualified degree of traditional Chinese medicine samples can be more scientifically quantified, thereby improving the accuracy and efficiency of detection.
[0043] The process of obtaining the reference value of the characteristic wave number includes: Obtain the content of the active ingredient of any prepared traditional Chinese medicine sample according to the HPLC fingerprint. The average reflectance of the characteristic wave number corresponding to the traditional Chinese medicine sample with the content being the lowest qualified content is used as the reference value of the characteristic wave number.
[0044] Regard all characteristic wave numbers as features, and construct a sample space composed of all prepared traditional Chinese medicine samples (that is, excluding the samples obtained during the processing). Randomly select a certain proportion (preferably 50%) of traditional Chinese medicine samples from this sample space by sampling with replacement, and place these traditional Chinese medicine samples at the root node of the isolation tree. During the process of constructing the isolation tree, randomly select one feature from all features as the splitting basis with replacement. When a certain feature is selected for the first time, its splitting value is set to the reference value. When this feature is selected again in the subsequent process, its splitting value is randomly set to a random number between the maximum value and the minimum value of this feature in the current traditional Chinese medicine sample set. By continuously splitting into the left subtree and the right subtree, continue this process until all traditional Chinese medicine samples are separately placed at the leaf nodes, thus obtaining a complete isolation tree. Repeat the above sampling and isolation tree construction process a preset number of times (preferably 100 times), and finally obtain an isolation forest composed of a preset number of isolation trees.
[0045] S103. In the second isolation forest, the traditional Chinese medicine samples in the right subtree and the left subtree of the isolation tree are respectively encoded as a first value and a second value. According to the final possibility, the difference in tree depth between the traditional Chinese medicine sample and the target characteristic wave number in the isolation tree, and the encoding information, the probability that the target characteristic wave number is qualified is obtained, and the anomaly score of the traditional Chinese medicine sample is obtained according to the probability.
[0046] For any feature, an inorder traversal can be performed on all splitting values of the binary tree. The splitting value corresponding to the reference value is usually located in the middle of the traversal sequence. In the traversal sequence, the splitting value closest to the reference value is often located in the right subtree. Therefore, in the isolation tree, the greater the depth and the more nodes in the right subtree, the greater the probability of being qualified.
[0047] Encoding starts from the position of the feature of any isolation tree. If the traditional Chinese medicine sample is in the right subtree, it is encoded as the first value (preferably 1), and if it is in the left subtree, it is encoded as the second value (preferably -1) to obtain the encoding information of the traditional Chinese medicine sample.
[0048] Using the final possibility of the characteristic wave number as a weight, the probability that any feature of any traditional Chinese medicine sample is qualified is obtained.
[0049] The process of obtaining the probability will be described in detail in the fifth embodiment and will not be elaborated here.
[0050] The process of obtaining the anomaly score will be described in detail in the sixth embodiment and will not be elaborated here.
[0051] S104. Obtain a reference sample of the traditional Chinese medicine sample to be tested, and determine the quality of the traditional Chinese medicine sample to be tested according to the anomaly score of the reference sample.
[0052] The process of obtaining the reference sample includes: Calculating the minimum value after summing up the absolute values of the differences in reflectance between the traditional Chinese medicine sample to be tested and the characteristic wave numbers corresponding to the traditional Chinese medicine samples, and the traditional Chinese medicine sample corresponding to the minimum value is the reference sample.
[0053] Determining the quality of the traditional Chinese medicine sample to be tested according to the anomaly score of the reference sample includes: When the anomaly score of the reference sample is greater than the first anomaly threshold, the quality of the traditional Chinese medicine sample to be tested is unqualified. When the anomaly score of the reference sample is greater than the second anomaly threshold and less than or equal to the first anomaly threshold, the quality of the traditional Chinese medicine sample to be tested is passing. When the anomaly score of the reference sample is less than or equal to the second anomaly threshold, the quality of the traditional Chinese medicine sample to be tested is good.
[0054] The first abnormal threshold can be set independently, preferably 0.6. The second abnormal threshold can also be set independently, preferably 0.4.
[0055] For any wave number, all traditional Chinese medicine samples form a sample space. Part of the traditional Chinese medicine samples are drawn from the sample space with replacement. Preferably, the drawing ratio is 1 / 2. These traditional Chinese medicine samples are placed at the root node. A splitting value is randomly selected between the maximum value and the minimum value of these traditional Chinese medicine samples and split into a left subtree and a right subtree (the data of any node is greater than the data of all its left subtrees and less than the data of all its right subtrees) until all samples are separately placed at the leaf nodes to obtain an isolation tree; After several (preferably 100) draws, several isolation trees are obtained to form an isolation forest.
[0056] In the isolation forest of any wave number, in order to avoid the influence of extreme values and error values on the splitting process, the range of the splitting value is used to characterize the range of the wave number characteristic value. The maximum value and the minimum value of the splitting values of any isolation tree in the isolation forest of any wave number are obtained. The larger the overall range of the isolation forest, the more the traditional Chinese medicine samples can be distinguished. Therefore, the greater the possibility that the wave number is a characteristic wave number.
[0057] The balance factor of a binary tree is the height of the left subtree of the binary tree minus the height of the right subtree, which can measure the balance of the binary tree. For the isolation forest of any wave number, the smaller the overall balance factor, the more balanced the isolation forest, indicating that the data distribution is relatively average and the more the samples can be distinguished. Therefore, the greater the possibility that the wave number is a characteristic wave number.
[0058] Figure 2 It is a flowchart of the obtaining process of the possibility provided by the second embodiment of the present invention. The obtaining process of the possibility includes: S201. Take the opposite of the absolute value of the balance factor of the j-th isolation tree in the isolation forest of the i-th wave number as the input value of the exponential function with base e, and obtain the splitting absolute value by taking the absolute value after subtracting the minimum splitting value from the maximum splitting value of the j-th isolation tree in the isolation forest of the i-th wave number.
[0059] The splitting absolute value can be expressed by the formula: ; where, the represents the maximum splitting value of the j-th isolation tree in the isolation forest of the i-th wave number, the represents the minimum splitting value of the j-th isolation tree in the isolation forest of the i-th wave number, and the represents the absolute value function.
[0060] The output value of multiplying the split absolute value by the exponential function is used as the likelihood component that the \(i\)-th wave number is the characteristic wave number in the \(j\)-th isolation tree. The process of obtaining the likelihood component is repeated to obtain the likelihood components that the \(i\)-th wave number is the characteristic wave number in each isolation tree, where the value range of \(i\) is from 1 to the number of wave numbers, and the value range of \(j\) is from 1 to the number of isolation trees.
[0061] The output value of the exponential function can be expressed as: ; where, the represents the exponential function with the natural constant \(e\) as the base, the represents the balance factor of the \(j\)-th isolation tree in the isolation forest of the \(i\)-th wave number, and the represents the absolute value function.
[0062] The likelihood component can be expressed as: ; S203. Calculate the normalized value of the average of the likelihood components as the likelihood that the \(i\)-th wave number is the characteristic wave number.
[0063] The likelihood can be expressed as: ; where, the represents the normalization function, preferably the range normalization function, and the represents the number of isolation trees. The represents the likelihood that the \(i\)-th wave number is the characteristic wave number.
[0064] To avoid the influence of the harvesting background and distinguish whether the difference in characteristic values is due to the background or processing, further analysis is performed on traditional Chinese medicine samples with the same background. For all traditional Chinese medicine samples with any background, obtain the depth of each traditional Chinese medicine sample in any isolation tree. The greater the difference in depth, the greater the difference between samples with the same background. The greater the difference between all samples with the same background in the isolation tree, the more likely the difference in characteristic values is due to processing rather than the background.
[0065] Figure 3 This is the flowchart of the process for obtaining the final likelihood provided by the third embodiment of the present invention. The process for obtaining the final likelihood includes: S301. In the isolation forest of the \(i\)-th wave number, obtain the sum of the absolute values of the differences in tree depths between any two traditional Chinese medicine samples with different backgrounds in different isolation trees.
[0066] The sum of the distances can be expressed as: ; Among them, the represents the tree depth distance of the u-th sample of the m-th background sample of the j-th isolated tree in the isolated forest of the i-th wave number, and the represents the tree depth distance of the -th sample of the m-th background sample of the j-th isolated tree in the isolated forest of the i-th wave number, and the represents the absolute value function.
[0067] The background samples refer to the classification of traditional Chinese medicine samples according to different origins, production years, and collection times. The traditional Chinese medicine origin, production year, and collection time of the same background sample are the same.
[0068] S302. Multiply the normalized value of the sum of absolute values by the probability that the i-th wave number is the characteristic wave number to obtain the final probability that the i-th wave number is the characteristic wave number.
[0069] The final probability can be expressed as: ; Among them, the represents the probability that the i-th wave number is the characteristic wave number, and the represents the final probability that the i-th wave number is the characteristic wave number. The value range of is from 1 to the number U of the samples, the value range of m is from 1 to the number M of the background samples, and the value range of j is from 1 to the number .
[0070] Figure 4 is the flowchart of the acquisition process of the change consistency value provided by the fourth embodiment of the present invention. The acquisition process of the change consistency value includes: S401. Obtain the first absolute value of the difference between the difference values of the reflectivity change differences of any two of the traditional Chinese medicine samples. The reflectivity change difference value represents the second absolute value of the difference in reflectivity between two adjacent wave numbers.
[0071] The first absolute value can be expressed as: ; Among them, the represents the reflectivity change difference value of the r-th traditional Chinese medicine sample, and the represents the reflectivity change difference value of the s-th traditional Chinese medicine sample.
[0072] The reflectivity change difference value can be expressed as: ; Among them, the represents the reflectivity of one of the two adjacent wavenumbers, and the represents the reflectivity of the other of the two adjacent wavenumbers.
[0073] S402. Add up the first absolute values in sequence to obtain the sum of the first absolute values, and use the opposite of the sum of the first absolute values as the input value of the exponential function with base e. The output value of the exponential function is the change consistency value.
[0074] The change consistency value can be expressed as: ; wherein, the represents the change consistency value, and the ranges from 1 to the number R of the first absolute values, and the represents the exponential function with base e, the natural constant.
[0075] Figure 5 is a flowchart of the process for obtaining the probability provided in the fifth embodiment of the present invention. The process for obtaining the probability includes: S501. In any one of the isolated trees, calculate the sum of the coding ratios. The coding ratio is the a-th coding divided by the serial number of the a-th coding, wherein the value range of a is from 1 to the tree depth difference value, and the tree depth difference value is the difference between the depth of the leaf node where the traditional Chinese medicine sample is located and the depth at which the i-th wavenumber first appears.
[0076] The sum of the coding ratios can be expressed as: ; wherein, the represents the a-th coding, the represents the serial number of the a-th coding, and the represents the tree depth difference value of the j-th isolated tree.
[0077] represents that the reciprocal of the coding serial number is used as the weight to weight the coding.
[0078] S502. Calculate the sum value of the sums of the coding ratios corresponding to each isolated tree. The normalized value after multiplying the sum value by the final possibility that the i-th wavenumber is the characteristic wavenumber is used as the probability that the target characteristic wavenumber is qualified, where the i-th wavenumber is the target characteristic wavenumber.
[0079] The probability can be expressed as: ; wherein, the represents the probability that the i-th wavenumber is qualified, and the represents the final possibility that the i-th wave number is the characteristic wave number, and the represents the number of the isolated trees.
[0080] Figure 6 is a flowchart of the process for obtaining the anomaly score provided by the sixth embodiment of the present invention. The process for obtaining the anomaly score includes: S601. Taking the opposite number of the probability that the target characteristic wave number is qualified as the input value of the exponential function with the natural constant e as the base, and taking the output value of the exponential function as the anomaly score component, where the value range of the target characteristic wave number is from 1 to the number of characteristic wave numbers.
[0081] The anomaly score component can be expressed as: ; where the represents the exponential function with the natural constant e as the base, and the represents the probability that the i-th wave number is qualified, that is, the probability that the target characteristic wave number is qualified.
[0082] S602. Taking the normalized value of the sum of the anomaly score components as the anomaly score of the traditional Chinese medicine sample.
[0083] The anomaly score can be expressed as: ; where the represents the anomaly score of the traditional Chinese medicine sample, and the represents the number of features, that is, the number of characteristic wave numbers.
[0084] For any traditional Chinese medicine sample, the higher the probability that all features are qualified, the higher the quality of the traditional Chinese medicine sample, and thus the smaller the anomaly score.
[0085] The present invention has the following beneficial effects: First, a first isolated forest is established according to the wave numbers in the NIR spectrum of the processed traditional Chinese medicine sample, the possibility and the final possibility that the wave number is the characteristic wave number are calculated, and the wave numbers are selected according to the final possibility and the adjacent repeated wave numbers are removed to obtain the characteristic wave numbers. The characteristic wave numbers are regarded as the characteristics of the traditional Chinese medicine sample, and the characteristics can play a role in distinguishing the traditional Chinese medicine sample.
[0086] Secondly, obtain the reference value of the characteristic wave number according to the HPLC fingerprint of the traditional Chinese medicine sample. Place the prepared traditional Chinese medicine sample at the root node, and use the reference value of the characteristic wave number randomly selected for the first time as the splitting value. When the characteristic wave number is randomly selected non-first time, the splitting value is set to a random number between the maximum and minimum values of the sample, and a second isolation forest is established. The second isolation forest is the basis for obtaining the anomaly score subsequently.
[0087] Furthermore, in the second isolation forest, encode the traditional Chinese medicine samples in the right subtree and the left subtree of the isolation tree as the first value and the second value respectively. Calculate the probability that the target characteristic wave number is qualified according to the final possibility, the difference value of the tree depth between the traditional Chinese medicine sample and the target characteristic wave number in the isolation tree, and the encoding information, and calculate the anomaly score of the traditional Chinese medicine sample according to the probability. Each traditional Chinese medicine sample has a corresponding anomaly score.
[0088] Finally, obtain the reference sample of the traditional Chinese medicine sample to be tested, and determine the quality of the traditional Chinese medicine sample to be tested according to the anomaly score of the reference sample. The reference sample is the traditional Chinese medicine sample with the smallest difference from the traditional Chinese medicine sample to be tested, and the anomaly score of the reference sample is the anomaly score of the traditional Chinese medicine sample to be tested. The higher the anomaly score, the worse the sample quality.
[0089] The present invention uses the isolation forest algorithm for multiple traditional Chinese medicine samples, analyzes the correlation and characteristic performance between each wavelength in the spectral data, extracts the key features for anomaly detection, accurately calculates the anomaly score of the traditional Chinese medicine sample to be tested, and evaluates its quality status accordingly, thereby realizing the quality detection of the traditional Chinese medicine processing process. The application of the present invention can significantly improve the accuracy of detection and provide strong support for the quality control of traditional Chinese medicine.
[0090] It should be noted that: the above sequence of the embodiments of the present invention is only for description and does not represent the superiority or inferiority of the embodiments. The processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0091] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between each embodiment can be referred to each other. The key points of each embodiment are described as the differences from other embodiments.
Claims
1. A method for detecting the quality of Chinese medicine processing based on spectral analysis, characterized in that: The method comprises: Establishing a first isolated forest according to the wavenumber in the NIR spectrum of the processed traditional Chinese medicine sample, calculating the possibility and final possibility of the wavenumber being a characteristic wavenumber, selecting the wavenumber according to the final possibility and removing adjacent repeated wavenumbers to obtain the characteristic wavenumber; Wherein, the method for obtaining the possibility is: taking the opposite of the absolute value of the balance factor of the jth isolated tree in the isolated forest of the i-th wave number as the input value of the exponential function with the natural constant e as the base, and subtracting the maximum splitting value of the jth isolated tree in the isolated forest of the i-th wave number from the minimum splitting value and taking the absolute value to obtain the splitting absolute value; multiplying the splitting absolute value by the output value of the exponential function as the possibility component of the i-th wave number being the characteristic wave number in the j-th isolated tree, repeating the process of obtaining the possibility component to obtain the possibility component of the i-th wave number being the characteristic wave number in each isolated tree, wherein the value range of i is 1 to the number of the wave numbers, and the value range of j is 1 to the number of the isolated trees; obtaining the normalized value of the average value of the possibility component as the possibility that the i-th wave number is the characteristic wave number; The method for obtaining the final possibility is as follows: in the isolated forest of the i-th wave number, the sum of the absolute values of the difference in tree depth distance between any two of the Chinese medicine samples with different backgrounds of different isolated trees is obtained; the normalized value of the sum of the absolute values is multiplied by the possibility that the i-th wave number is the characteristic wave number to obtain the final possibility that the i-th wave number is the characteristic wave number; According to the HPLC fingerprint of the traditional Chinese medicine sample, a reference value of the characteristic wavenumber is obtained, the processed traditional Chinese medicine sample is selected and placed at the root node, the reference value of the characteristic wavenumber randomly selected for the first time is used as the splitting value, and when the characteristic wavenumber is not randomly selected for the first time, the splitting value is set to a random number between the maximum value and the minimum value of the sample, and a second isolation forest is established; In the second isolated forest, the Chinese medicine samples in the right subtree and the left subtree of the isolated tree are respectively encoded as the first value and the second value, and the probability that the target characteristic wave number is qualified is calculated according to the final probability, the tree depth difference value between the Chinese medicine sample in the isolated tree and the target characteristic wave number, and the encoding information, and the abnormal score of the Chinese medicine sample is calculated according to the probability; A reference sample of the Chinese medicine sample to be tested is obtained, and the quality of the Chinese medicine sample to be tested is determined according to the abnormality score of the reference sample.
2. The method for detecting the quality of Chinese medicine processing based on spectral analysis according to claim 1, characterized in that: The removing of adjacent repeated wave numbers comprises: A change consistency value of two adjacent wave numbers is obtained, and when the change consistency value is greater than a preset change threshold, the wave number with a smaller final probability among the two adjacent wave numbers is removed.
3. The method for detecting the quality of Chinese medicine processing based on spectral analysis as claimed in claim 2, characterized in that: The process of obtaining the change consistency value includes: Obtaining a first absolute value of the difference between the reflectivity change difference values of any two of the traditional Chinese medicine samples, wherein the reflectivity change difference value represents a second absolute value of the difference between the reflectivities at two adjacent wave numbers; The first absolute values are sequentially added to obtain the sum of the first absolute values, and the inverse of the sum of the first absolute values is used as an input value of an exponential function with the natural constant e as the base, and the output value of the exponential function is the change consistency value.
4. The method for detecting the quality of Chinese medicine processing based on spectral analysis according to claim 1, characterized in that: The process of obtaining the reference value of the characteristic wave number includes: The content of the effective ingredient of the traditional Chinese medicine sample after any processing is obtained according to the HPLC fingerprint, and the mean reflectivity value of the characteristic wavenumber corresponding to the traditional Chinese medicine sample with the minimum qualified content is used as the reference value of the characteristic wavenumber.
5. The method for detecting the quality of Chinese medicine processing based on spectral analysis according to claim 1, characterized in that: The process of obtaining the probability includes: In any of the isolated trees, the sum of the coding ratios is calculated, where the coding ratio is the a-th code divided by the sequence number of the a-th code, wherein the value range of a is 1 to the tree depth difference value, and the tree depth difference value is the difference between the depth of the leaf node where the traditional Chinese medicine sample is located and the depth at which the i-th wave number first appears; The sum of the sums of the coding ratios corresponding to the isolated trees is calculated, and the normalized value obtained by multiplying the sum by the final possibility that the i-th wavenumber is the characteristic wavenumber is used as the probability that the target characteristic wavenumber is qualified, wherein the i-th wavenumber is the target characteristic wavenumber.
6. The method for detecting the quality of Chinese medicine processing based on spectral analysis according to claim 1, characterized in that: The process of obtaining the abnormality score includes: The inverse of the probability that the target characteristic wave number is qualified is used as the input value of an exponential function with the natural constant e as the base, and the output value of the exponential function is used as the abnormal score component, wherein the value range of the target characteristic wave number is 1 to the number of the characteristic wave number; The normalized value of the sum of the abnormal score components is used as the abnormal score of the traditional Chinese medicine sample.
7. The method for detecting the quality of Chinese medicine processing based on spectral analysis according to claim 1, characterized in that: The process of obtaining the reference sample includes: The smallest absolute value of the difference between the reflectivity of the Chinese medicine sample to be tested and the reflectivity of each characteristic wavenumber corresponding to the Chinese medicine sample is calculated, and the Chinese medicine sample corresponding to the smallest absolute value is used as the reference sample.
8. The method for detecting the quality of Chinese medicine processing based on spectral analysis according to claim 1, characterized in that: Determining the quality of the Chinese medicine sample to be tested according to the abnormality score of the reference sample includes: When the abnormality score of the reference sample is greater than the first abnormality threshold, the quality of the Chinese medicine sample to be tested is unqualified; when the abnormality score of the reference sample is greater than the second abnormality threshold and less than or equal to the first abnormality threshold, the quality of the Chinese medicine sample to be tested is qualified; when the abnormality score of the reference sample is less than or equal to the second abnormality threshold, the quality of the Chinese medicine sample to be tested is good.
Citation Information
Patent Citations
Method for identifying Chinese herbal medicine by using THz-TDS (terahertz-total dissolved solids) in combination with fuzzy rule expert system
CN103411912A
Grain condition data outlier detection method based on isolated forest
CN113327172A
Portable eucommia ulmoides leaf screening device for near infrared spectrum transmission detection and screening method
CN117269108A
Intelligent fault monitoring method for electric power communication equipment
CN117411811A
Quzu fructus aurantii medicinal material effectiveness detection method and system based on spectral analysis
CN118398103A