Modeling method for rapid detection of DOM content in alfalfa hay using near-infrared spectroscopy

The method improves DOM content detection in ryegrass hay by segmenting near-infrared spectra and using isolated trees to correct abnormal points, addressing the inaccuracies caused by instrument faults and operational errors, resulting in enhanced detection accuracy.

CN119334902BActive Publication Date: 2025-03-18NORTHEAST AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411884836.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-03-18
Estimated Expiration
2044-12-20

AI Technical Summary

Technical Problem

Existing methods for detecting the dry matter (DOM) content in ryegrass hay using near-infrared spectroscopy are hindered by instrument faults and operational errors, leading to inaccurate data and low detection accuracy due to ineffective identification and correction of abnormal values.

Method used

A method involving the segmentation of near-infrared spectra into sub-curves, adjustment of sampling frequency based on local curve characteristics, and the use of isolated trees to evaluate and correct abnormal points, resulting in improved data quality and accuracy.

Benefits of technology

This approach enhances the detection accuracy of DOM content by effectively identifying and correcting abnormal points, reducing the impact of instrument faults and operational errors, leading to a more reliable model for ryegrass hay analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119334902B_ABST
    Figure CN119334902B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of near-infrared light technology, and in particular to a modeling method for rapid near-infrared spectrum detection of DOM content in alfalfa hay. The method divides an infrared spectrum curve into a characteristic curve, divides a sub-curve of the characteristic curve into a local curve, obtains and adjusts the sampling frequency according to the inclination and length of the local curve, and obtains characteristic points on the local curve with the adjusted sampling frequency; establishes multiple isolated trees based on the characteristic points on each characteristic curve, obtains an abnormal evaluation index according to the depth difference of the characteristic point in the isolated tree where the characteristic point is located, and uses the index to divide normal data points and abnormal characteristic points; corrects the infrared spectrum curve according to the amplitude difference and abnormal evaluation index between the abnormal characteristic point and the normal characteristic point, and models the data based on the obtained corrected infrared spectrum curve. The present invention effectively improves the accuracy of detecting the DOM content of alfalfa hay.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of near infrared light, and in particular to a modeling method for rapid near infrared spectrum detection of DOM content in alfalfa hay. Background Art

[0002] Alfalfa hay is a high-quality feed source. It plays an important role in the animal husbandry industry because of its rich nutrients and high-quality feed value. At the same time, alfalfa is widely planted for its role in improving soil and maintaining water and soil. The content of digestible organic matter in alfalfa varies with the environment, genes and grazing intensity. Therefore, the detection of the content of digestible organic matter in alfalfa is of great significance for evaluating grass quality, animal health and feed quality and safety.

[0003] When using near-infrared spectroscopy to quickly detect the DOM content of alfalfa hay, outliers may exist in the collected spectral data due to instrument failure, improper operation, etc. Existing methods usually use interpolation, smoothing and other techniques to remove outliers in spectral data, but these techniques may not be able to effectively identify and correct outliers, thereby affecting the quality of spectral data, resulting in low accuracy in detecting the DOM content of alfalfa hay, and thus causing errors in the constructed model. Summary of the invention

[0004] In order to solve the technical problem that the use of interpolation, smoothing and other technologies may not effectively identify and correct abnormal points, resulting in low accuracy in the detection of DOM content in alfalfa hay, the object of the present invention is to provide a modeling method for rapid near-infrared spectroscopy detection of DOM content in alfalfa hay. The technical scheme adopted is as follows:

[0005] The present invention proposes a modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy, the method comprising:

[0006] Obtain infrared spectrum curve of alfalfa hay sample;

[0007] The infrared spectrum curve is divided into different sub-curves, and the sub-curves are merged according to the amplitude difference between each sub-curve and the data points on the adjacent sub-curves and the length of each sub-curve to obtain different characteristic curves; the sub-curve is divided into different local curves, and the adjustment sampling frequency of the corresponding local curve is determined according to the inclination and length of each local curve of the sub-curve; the characteristic points on each local curve are obtained at the adjusted sampling frequency;

[0008] Establishing a number of isolated trees based on the feature points on each feature curve, obtaining an abnormality evaluation index for each feature point on each feature curve according to the depth difference of each feature point in all the isolated trees in which it is located, and the depth of each feature point in the isolated tree in which it is located; dividing the feature points on each feature curve into normal feature points and abnormal feature points based on the abnormality evaluation index;

[0009] According to the amplitude difference between the abnormal feature point and the normal feature point on the infrared spectrum curve, and the abnormal evaluation index of the abnormal feature point, the infrared spectrum curve is corrected to obtain a corrected infrared spectrum curve; and modeling is performed based on the corrected infrared spectrum curve.

[0010] Furthermore, the sub-curves are merged according to the amplitude difference between the data points on each sub-curve and its adjacent sub-curves, and the length of each sub-curve, to obtain different characteristic curves, including:

[0011] Obtain the maximum point on each sub-curve of the infrared spectrum curve; for the sub-curves other than the first sub-curve of the infrared spectrum curve, obtain the merging index between each sub-curve and its adjacent previous sub-curve according to the amplitude difference between the maximum point on each sub-curve and its adjacent previous sub-curve, and the wavelength difference between the two end points of each sub-curve;

[0012] A similar sequence is formed by the first sub-curve of the infrared spectrum curve, and the second sub-curve is used as the sub-curve to be updated. When the merging index between the sub-curve to be updated and its adjacent previous sub-curve meets a preset condition, the sub-curve to be updated is added to the similar sequence, the similar sequence is updated, and the adjacent next sub-curve of the sub-curve to be updated is used as the next sub-curve to be updated; when the merging index does not meet the preset condition, the similar sequence is used as the merging sequence, and a new similar sequence is formed by the sub-curve to be updated, and the adjacent next sub-curve of the sub-curve to be updated is used as the new sub-curve to be updated, and it is determined whether the merging index between the new sub-curve to be updated and its adjacent previous sub-curve meets the preset condition, all sub-curves of the infrared spectrum curve are traversed, and the sub-curves of the infrared spectrum curve are divided into a plurality of merging sequences;

[0013] Each sub-curve in the combined sequence is combined to obtain a characteristic curve.

[0014] Further, the step of determining the adjustment sampling frequency of the corresponding local curve according to the inclination and length of each local curve of the sub-curve includes:

[0015] For each local curve of each sub-curve, the ratio of the absolute value of the difference between the amplitudes of the two end points of the local curve to the absolute value of the difference between the wavelengths is used as the inclination index of the local curve; the ratio of the absolute value of the difference between the wavelengths of the two end points of the local curve to the absolute value of the difference between the wavelengths of the two end points of the sub-curve where the local curve is located is recorded as the length ratio index of the local curve;

[0016] According to the tilt index and the length ratio index, a sampling index of the local curve is obtained; the tilt index and the sampling index are positively correlated, and the length ratio index and the sampling index are negatively correlated;

[0017] The preset sampling frequency corresponding to the local curve is weighted by using the sampling index, and the weighted result is rounded to obtain the adjusted sampling frequency of the local curve.

[0018] Furthermore, obtaining the abnormality evaluation index of each characteristic point on each characteristic curve includes:

[0019] For all feature points on each feature curve, obtain the depth of each feature point in each isolated tree where it is located;

[0020] The variance of the depth of each feature point in all isolated trees in which it is located is recorded as the depth dispersion index of each feature point;

[0021] The ratio of the depth of each feature point in each isolated tree where it is located to the depth of the isolated tree is used as the local depth index of each isolated tree where each feature point is located; the cumulative sum of the local depth indexes of all isolated trees where each feature point is located is recorded as the comprehensive depth index of each feature point;

[0022] According to the depth discrete index and the comprehensive depth index, an abnormality evaluation index of each feature point is obtained; the depth discrete index and the abnormality evaluation index are positively correlated, and the comprehensive depth index and the abnormality evaluation index are negatively correlated.

[0023] Furthermore, the infrared spectrum curve is corrected according to the amplitude difference between the abnormal feature point and the normal feature point on the infrared spectrum curve, and the abnormal evaluation index of the abnormal feature point to obtain the corrected infrared spectrum curve, including:

[0024] The adjacent previous normal feature point of each abnormal feature point on the infrared spectrum curve is recorded as the reference point of each abnormal feature point; using the abnormal evaluation index of each abnormal feature point, the absolute value of the difference between the amplitude of each abnormal feature point and its reference point is weighted to obtain the abnormal correction value of each abnormal feature point;

[0025] If the amplitude of each abnormal feature point is greater than the amplitude of its reference point, the difference between the amplitude of each abnormal feature point and the abnormal correction value is used as the correction amplitude of the corresponding abnormal feature point; if the amplitude of each abnormal feature point is less than the amplitude of its reference point, the sum of the amplitude of each abnormal feature point and the abnormal correction value is used as the correction amplitude of the corresponding abnormal feature point;

[0026] Determine a correction point for each abnormal feature point, wherein the amplitude of the correction point is the correction amplitude of each abnormal feature point;

[0027] Curve fitting is performed on the correction points of the normal characteristic points and the abnormal characteristic points on the infrared spectrum curve to obtain a corrected infrared spectrum curve.

[0028] Furthermore, obtaining a merging index between each sub-curve and its adjacent previous sub-curve includes:

[0029] The absolute value of the difference between the amplitude of each sub-curve and the maximum point on the previous sub-curve and the product of the absolute value of the difference between the wavelengths of the two endpoints of each sub-curve are negatively correlated and normalized to obtain the merging index between each sub-curve and its previous sub-curve.

[0030] Furthermore, the preset condition is that the merging index between the sub-curve to be updated and its adjacent previous sub-curve is greater than a preset merging threshold.

[0031] Furthermore, dividing the infrared spectrum curve into different sub-curves includes:

[0032] The minimum value points on the infrared spectrum curve are obtained, and the curve between every two adjacent minimum value points is recorded as a sub-curve.

[0033] Furthermore, dividing the sub-curve into different local curves includes:

[0034] Each sub-curve is divided into two local curves based on the maximum value point on each sub-curve.

[0035] Furthermore, the dividing the characteristic points on each characteristic curve into normal characteristic points and abnormal characteristic points based on the abnormal evaluation index includes:

[0036] For all feature points on each feature curve, feature points whose abnormal evaluation index is greater than a preset abnormal threshold are recorded as abnormal feature points, and feature points whose abnormal evaluation index is less than or equal to the preset abnormal threshold are recorded as abnormal feature points.

[0037] The present invention has the following beneficial effects:

[0038] First, instrument failure and other reasons may cause the spectral curves representing the same organic matter to be divided. Due to the different contents of different organic matter in the alfalfa hay sample, the spectral curves representing different organic matter are also divided. At the same time, abnormal points are easier to identify on the spectral curves representing the same organic matter, so the sub-curves representing the same digestible organic matter are merged to obtain the characteristic curve. The amount of calculation required to directly perform abnormality detection on all data points on the characteristic curve is large. In order to reduce the amount of calculation and improve the calculation efficiency, some data points are selected from the data points on the characteristic curve for abnormality detection. Specifically, the tilt degree and length of the amplitude change degree of the local curve within the unit wavelength band are analyzed to determine the adjustment sampling frequency of the local curve, and the characteristic points of the local curves with different amplitude changes are adaptively collected, which helps to retain important information on the infrared spectrum curve during the sampling process.

[0039] Second aspect: Since abnormal points are easier to identify on the spectral curve representing the same organic matter, an isolated tree is established based on the characteristic points on each characteristic curve to improve the accuracy of the abnormal degree of the characteristic points in the isolated tree. The depth difference of the characteristic point in all the isolated trees in which it is located reflects the credibility of the abnormal degree determined by the characteristic point in the isolated tree, and combined with the depth of the characteristic point in the isolated tree in which it is located, the analysis is performed so that the obtained abnormal evaluation index can more accurately reflect the abnormal degree of the characteristic point, and further improve the accuracy of dividing the normal characteristic points and abnormal characteristic points on the characteristic curve based on the abnormal evaluation index.

[0040] The third aspect: the amplitude difference between abnormal feature points and normal feature points reflects the abnormal part of the amplitude of the abnormal feature points compared with the normal feature points. The abnormal evaluation index presents the degree of amplitude abnormality of the abnormal feature points. The abnormal feature points on the infrared spectrum curve are corrected by combining the two factors to improve the accuracy of the correction of abnormal feature points, effectively reduce the interference of instrument failure and improper operation on the infrared spectrum data of alfalfa and licorice, improve the accuracy of DOM content detection of alfalfa hay, and thus make the constructed model more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0042] Figure 1 A flowchart of the steps of a modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy provided by one embodiment of the present invention;

[0043] Figure 2A flowchart of a method for acquiring a characteristic curve provided by an embodiment of the present invention;

[0044] Figure 3 A system structure diagram of a modeling system for rapid near-infrared spectroscopy detection of DOM content in alfalfa hay provided by one embodiment of the present invention;

[0045] Figure 4 A computer device schematic diagram of a modeling device for rapid near-infrared spectroscopy detection of DOM content in alfalfa hay provided by one embodiment of the present invention. DETAILED DESCRIPTION

[0046] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the modeling method for the near-infrared spectrum rapid detection of the DOM content of alfalfa hay proposed by the present invention, its specific implementation, structure, characteristics and effects as follows in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0047] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0048] The specific scheme of the modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy provided by the present invention is described in detail below with reference to the accompanying drawings.

[0049] Embodiment 1:

[0050] The present invention proposes a modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy. Figure 1 , which shows a flow chart of the steps of a modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy provided by an embodiment of the present invention, the method comprising:

[0051] Step S1: Obtaining an infrared spectrum curve of an alfalfa hay sample.

[0052] This program mainly monitors the digestible organic matter content in alfalfa hay. The specific methods are as follows:

[0053] Firstly, alfalfa from different regions was collected; secondly, the alfalfa was placed in an experimental environment of 60 degrees Celsius for drying, and the drying time was set to 48 hours; then, the dried alfalfa was crushed by a blade crusher, and the crushed alfalfa was filtered through a 1 mm mesh screen, and the filtered alfalfa was mixed and put into a sample cup to obtain an alfalfa hay sample; then, the alfalfa hay sample was repeatedly scanned multiple times using an infrared spectrometer to obtain an original infrared spectrum curve for each scan; finally, the average spectrum curve of the original infrared spectrum curves of multiple scans was obtained, which was recorded as the infrared spectrum curve of the alfalfa hay sample, and any data point in the infrared spectrum curve was selected as the analysis point, and the amplitude of the analysis point was equal to the average of the amplitudes of the data points with the same wavelength as the analysis point in the multiple original infrared spectrum curves.

[0054] It should be noted that the infrared spectrum curve is equivalent to the infrared spectrum graph. The infrared spectrum curve can be regarded as a curve composed of multiple data points. The horizontal axis of the data point is the wavelength, and the vertical axis is the absorbance at the characteristic wavelength; the amplitude of the data point is the horizontal axis of the data point.

[0055] In the process of spectral collection of alfalfa hay samples, abnormal values ​​may appear on the detected infrared spectrum curve due to instrument failure, improper operation and noise. In order to ensure the accuracy of monitoring the digestible organic matter content in alfalfa hay, it is necessary to first identify the abnormal points on the infrared spectrum curve and then correct the abnormal points to reduce the interference of instrument failure and improper operation on the infrared spectrum data of alfalfa licorice.

[0056] Step S2: Divide the infrared spectrum curve into different sub-curves, and merge the sub-curves according to the amplitude difference between each sub-curve and the data points on its adjacent sub-curves, as well as the length of each sub-curve, to obtain different characteristic curves; divide the sub-curve into different local curves, and determine the adjusted sampling frequency of the corresponding local curve according to the inclination and length of each local curve of the sub-curve; and obtain the characteristic points on each local curve by adjusting the sampling frequency.

[0057] In the process of spectrum acquisition of alfalfa hay samples, the information at certain wavelengths on the infrared spectrum curve of the alfalfa hay sample may be reduced due to instrument failure and improper operation, resulting in a minimum point, so that the spectrum curve representing the same digestible organic matter in the infrared spectrum curve is divided into multiple curves; at the same time, due to the difference in the content of different digestible organic matter in the alfalfa hay sample, there are also minimum points between the spectrum curves representing different digestible organic matter. Therefore, this embodiment obtains the minimum points on the infrared spectrum curve, and records the curve between every two adjacent minimum points as a sub-curve.

[0058] Since the fluctuation of the spectrum curve representing the same digestible organic matter in the infrared spectrum curve is relatively stable, the abnormal degree of the abnormal point in the spectrum curve representing the same digestible organic matter is more prominent, and it is easier and more accurate to identify the abnormal point. Therefore, it is necessary to merge the sub-curves representing the same digestible organic matter to obtain the characteristic curve.

[0059] See also Figure 2 , which shows a flow chart of steps of a characteristic curve acquisition method provided by an embodiment of the present invention, the method comprising:

[0060] Step S210: Obtain the maximum point on each sub-curve of the infrared spectrum curve; for the sub-curves other than the first sub-curve of the infrared spectrum curve, obtain the merging index between each sub-curve and its adjacent previous sub-curve according to the amplitude difference between the maximum point on each sub-curve and its adjacent previous sub-curve, and the wavelength difference between the two endpoints of each sub-curve.

[0061] The fluctuations of the sub-curves of the same digestible organic matter in the alfalfa hay sample are relatively similar. The fluctuations of the sub-curves representing different digestible organic matter are quite different due to the differences in the contents of different digestible organic matter. Due to instrument failure, improper operation and noise, the abnormal values ​​on the infrared spectrum curve are relatively random, so the spectrum curve of the same digestible organic matter may be divided into multiple sub-curves, and the lengths of these sub-curves are relatively short; and the reason why the spectrum curves of different digestible organic matter are divided into multiple sub-curves is that there are differences in the organic matter content, which will not affect the division of the spectrum curve of a single digestible organic matter, so the lengths of the sub-curves divided due to different organic matter contents are longer.

[0062] The amplitude of the maximum point on the sub-curve represents the extreme fluctuation of the sub-curve. The difference in amplitude between the maximum point of each sub-curve and its adjacent sub-curve shows the similarity of the fluctuations of the two sub-curves. Combined with the length of the sub-curve, the possibility of merging each sub-curve with its adjacent sub-curve is analyzed to obtain the merging index.

[0063] In an embodiment of the present invention, the method for obtaining the merging index is: negatively correlate and normalize the product of the absolute value of the difference between the amplitude of each sub-curve and the maximum point on the adjacent previous sub-curve and the absolute value of the difference between the wavelengths of the two endpoints of each sub-curve to obtain the merging index between each sub-curve and the adjacent previous sub-curve. It should be noted that because the sub-curve is a curve between two adjacent minimum points, there is a maximum point on the sub-curve.

[0064] The absolute value of the difference between the amplitude of the maximum point on the sub-curve and its adjacent previous sub-curve is used to measure the similarity of the fluctuations of the two sub-curves, and the absolute value of the difference between the wavelengths of the two endpoints of the sub-curve represents the length of the sub-curve. If the absolute value of the difference between the amplitude of the maximum point on each sub-curve and its adjacent previous sub-curve is smaller, and the absolute value of the difference between the wavelengths of the two endpoints of each sub-curve is smaller, it means that the fluctuations of the sub-curve and its adjacent previous sub-curve are more similar and the length of the sub-curve is shorter, which further indicates that the possibility that the two sub-curves represent the spectral curves of the same digestible organic matter is greater, and each sub-curve should be merged with its adjacent previous sub-curve, and the merging index between the two sub-curves is greater. On the contrary, if the absolute values ​​of the above two differences are both larger, it means that the possibility that the two sub-curves represent the spectral curves of different digestible organic matter is greater. In order to ensure the accuracy of abnormal point extraction, each sub-curve should not be merged with its adjacent previous sub-curve, and the merging index between the two sub-curves is smaller.

[0065] It should be noted that this embodiment uses an exponential function with a natural constant as the base for negative correlation mapping; the Norm function is used for normalization processing, and other normalization methods may also be selected, such as function transformation, maximum and minimum normalization, etc., which are not limited here. The specific operation of the negative correlation mapping is: first take the inverse of the product of the absolute value of the difference between the amplitude of each sub-curve and the maximum point on the adjacent previous sub-curve, and the absolute value of the difference between the wavelengths of the two endpoints of each sub-curve, and use the inverse as the exponent of the exponential function with a natural constant as the base, so as to achieve negative correlation mapping.

[0066] Step S220: a similar sequence is formed by the first sub-curve of the infrared spectrum curve, and the second sub-curve is used as the sub-curve to be updated. When the merging index between the sub-curve to be updated and its adjacent previous sub-curve meets the preset condition, the sub-curve to be updated is added to the similar sequence, the similar sequence is updated, and the adjacent next sub-curve of the sub-curve to be updated is used as the next sub-curve to be updated; when the merging index does not meet the preset condition, the similar sequence is used as the merged sequence, and a new similar sequence is formed by the sub-curve to be updated, and the adjacent next sub-curve of the sub-curve to be updated is used as the new sub-curve to be updated, and it is determined whether the merging index between the new sub-curve to be updated and its adjacent previous sub-curve meets the preset condition, all sub-curves of the infrared spectrum curve are traversed, and the sub-curves of the infrared spectrum curve are divided into a plurality of merged sequences.

[0067] The merging index between every two adjacent sub-curves in each merging sequence meets the preset condition, and the sub-curves in each merging sequence represent the infrared spectrum of the same digestible organic matter of the alfalfa hay sample. The preset condition is: the merging index between the sub-curve to be updated and its adjacent previous sub-curve is greater than the preset merging threshold; in the embodiment of the present invention, the preset merging threshold is an empirical value of 0.7, and the implementer can set it according to the specific situation.

[0068] Step S230: merging the sub-curves in each merging sequence to obtain a characteristic curve.

[0069] The specific operation of merging the sub-curves in each merge sequence is: for every two adjacent sub-curves, the right end point of the previous sub-curve is used as the left end point of the next sub-curve. Ideally, each digestible organic matter content in the alfalfa hay sample corresponds to a characteristic curve.

[0070] At this point, the division of the characteristic curve of the infrared spectrum curve is completed.

[0071] The amount of calculation required to directly perform anomaly detection on all data points on the characteristic curve is large. In order to reduce the amount of calculation and improve the calculation efficiency, some data points are selected from all data points on the characteristic curve for anomaly detection. Since different organic matter in alfalfa hay has different light absorption in different bands, the simple equal interval method for sampling cannot fully retain the important information on the characteristic curve.

[0072] Since the fluctuation difference of the curves on both sides of the maximum point on the sub-curve is quite obvious, in order to improve the accuracy of the feature analysis of different positions of the infrared spectrum curve, each sub-curve is divided into two local curves based on the maximum point on each sub-curve.

[0073] The inclination and length of the local curve can show the amplitude variation of the local curve within the unit wavelength band. The amplitude variation of the local curve affects the possibility of abnormal points appearing, and thus affects the number of sampling points on the local curve. Therefore, the adjustment sampling frequency of the local curve is obtained by combining the inclination and length of the local curve.

[0074] Preferably, in some possible implementation modes of the embodiments of the present invention, the method for obtaining the adjusted sampling frequency of the local curve includes: for each local curve of each sub-curve, taking the ratio of the absolute value of the difference in amplitude between the two endpoints of the local curve to the absolute value of the difference in wavelength as the tilt index of the local curve; recording the ratio of the absolute value of the difference in wavelength between the two endpoints of the local curve to the absolute value of the difference in wavelength between the two endpoints of the sub-curve in which the local curve is located as the length ratio index of the local curve; obtaining the sampling index of the local curve according to the tilt index and the length ratio index; the tilt index is positively correlated with the sampling index, and the length ratio index is negatively correlated with the sampling index; using the sampling index to weight the preset sampling frequency corresponding to the local curve, and rounding the weighted result to obtain the adjusted sampling frequency of the local curve.

[0075] The tilt index reflects the tilt degree of the local curve, and the length ratio index presents the length ratio of the local curve in the sub-curve in which it is located. If the tilt index is larger and the length ratio index is smaller, it means that the amplitude of the local curve changes more greatly within the unit wavelength band, and the possibility of abnormal points appearing on the local curve is greater. It is necessary to perform fine sampling on the local curve. The more sampling points are required on the local curve, and the larger the sampling index is; conversely, the slower the amplitude of the local curve changes within the unit wavelength band, the smaller the possibility of abnormal points appearing on the local curve. In order to reduce the amount of calculation, the local curve can be roughly sampled. The fewer sampling points are required on the local curve, the smaller the sampling index is. Therefore, the tilt index is positively correlated with the sampling index, and the length ratio index is negatively correlated with the sampling index.

[0076] It should be noted that in the embodiment of the present invention, the preset sampling frequency is to sample once every 10 feature points, and the implementer can set it according to the specific situation.

[0077] In a specific implementation of the embodiment of the present invention, the adjustment sampling frequency of the local curve is expressed by the formula:

[0078]

[0079]

[0080]

[0081] Where TN is the adjustment sampling frequency of the local curve; K is the tilt index of the local curve; is the length ratio index of the local curve; N is the preset sampling number of the local curve; is the sampling index of the local curve; A_L is the amplitude of the left endpoint of the local curve; A_R is the amplitude of the right endpoint of the local curve; B_L is the wavelength of the left endpoint of the local curve; B_R is the wavelength of the right endpoint of the local curve; B_L_z is the wavelength of the left endpoint of the sub-curve where the local curve is located; B_R_z is the wavelength of the right endpoint of the sub-curve where the local curve is located; Norm is the normalization function; It should be noted that since the local curve and the sub-curve have a certain length, and Cannot be zero.

[0082] Starting from the first data point on the local curve, the data points on the local curve are sampled at equal intervals by adjusting the sampling frequency, and the sampled data points are recorded as feature points. Since the larger the sampling frequency, the smaller the interval between the sampling points, the larger the number of feature points on the local curve.

[0083] The greater the amplitude variation within a unit wavelength band, the greater the sampling frequency of the local curve, and the greater the number of feature points on the local curve; the smaller the amplitude variation within a unit wavelength band, the smaller the sampling frequency of the local curve, and the smaller the number of feature points on the local curve. The above method is used to adaptively collect feature points for local curves with different amplitude variations, which helps to retain important information on the infrared spectrum curve during the sampling process.

[0084] Step S3: Establish several isolated trees based on the feature points on each feature curve, and obtain the abnormal evaluation index of each feature point on each feature curve according to the depth difference of each feature point in all the isolated trees in which it is located, and the depth of each feature point in the isolated tree in which it is located; divide the feature points on each feature curve into normal feature points and abnormal feature points based on the abnormal evaluation index.

[0085] Since the fluctuations of the partial spectral curves representing the same digestible organic matter in the infrared spectral curve are relatively close, the abnormal degree of the abnormal point in the spectral curve representing the same digestible organic matter is more prominent, and it is easier and more accurate to identify the abnormal point. Therefore, based on the characteristic points on each characteristic curve, at least two isolated trees are established using the isolation forest algorithm, specifically: the characteristic points on the characteristic curve are randomly selected multiple times, and an isolated tree is constructed based on the randomly selected characteristic points each time. Among them, the isolation forest algorithm is a well-known technology for those skilled in the art and will not be described in detail here.

[0086] The outliers caused by instrument failure and improper operation account for a small part of the data points on the characteristic curve. The feature points with smaller abnormalities show similar characteristics under multiple random selections, while the feature points with larger abnormalities show large differences in characteristics under multiple random selections. According to the depth difference of each feature point in its isolated tree and the depth of each feature point in its isolated tree, the abnormal evaluation index is determined to measure the degree of abnormality of the feature point.

[0087] Preferably, in some possible implementation modes of the embodiments of the present invention, the method for obtaining the abnormality evaluation index includes: for all feature points on each feature curve, obtaining the depth of each feature point in each isolated tree in which it is located; recording the variance of the depth of each feature point in all isolated trees in which it is located as the depth discrete index of each feature point; taking the ratio of the depth of each feature point in each isolated tree in which it is located to the depth of the isolated tree as the local depth index of each feature point in each isolated tree in which it is located; recording the cumulative sum of the deep local depth indexes of each feature point in all isolated trees in which it is located as the comprehensive depth index of each feature point; and obtaining the abnormality evaluation index of each feature point based on the depth discrete index and the comprehensive depth index.

[0088] Since feature points with less abnormality show similar characteristics in multiple random selections, and feature points with greater abnormality show greater changes in characteristics in multiple random selections, the isolated path lengths of feature points with less abnormality in multiple isolated trees are closer, and the isolated path lengths of feature points with greater abnormality in multiple isolated trees have greater changes. The depth dispersion index reflects the degree of difference in the depth of a feature point in all isolated trees in which it is located. If the depth dispersion index is smaller, the depth of the feature point in multiple isolated trees is closer, and the abnormality of the feature point is smaller.

[0089] The smaller the local depth index, the smaller the proportion of the depth of the feature point in each isolated tree in which it is located in the depth of the isolated tree, and the shorter the length of the isolated path of the feature point in the isolated tree in which it is located, the greater the abnormality of the feature point in each isolated tree in which it is located. The degree of abnormality of the feature point in all the isolated trees in which it is located is comprehensively analyzed to obtain the comprehensive depth index of the feature point. The larger the comprehensive depth index, the greater the overall abnormality of the feature point in all the isolated trees in which it is located.

[0090] Therefore, the depth discrete index is positively correlated with the abnormal evaluation index, and the comprehensive depth index is negatively correlated with the abnormal evaluation index. In a specific implementation of the embodiment of the present invention, the abnormal evaluation index is expressed by the formula:

[0091]

[0092] In the formula, PR is the abnormal evaluation index of each feature point; LS is the depth discrete index of each feature point; A is the total number of isolated trees where each feature point is located; is the depth of each feature point in the ath isolated tree; is the depth of the ath isolated tree where each feature point is located; is the local depth index of each feature point in the ath isolated tree; is the comprehensive depth index of each feature point; exp is an exponential function with a natural constant as the base; Norm is the normalization function.

[0093] For all feature points on each feature curve, feature points with an abnormal evaluation index greater than a preset abnormal threshold are recorded as abnormal feature points, and feature points with an abnormal evaluation index less than or equal to the preset abnormal threshold are recorded as abnormal feature points. It should be noted that in the embodiment of the present invention, the preset abnormal threshold is an empirical value of 0.7, and the implementer can set it according to the specific situation.

[0094] Step S4: According to the amplitude difference between the abnormal feature point and the normal feature point on the infrared spectrum curve, and the abnormal evaluation index of the abnormal feature point, the infrared spectrum curve is corrected to obtain a corrected infrared spectrum curve; and modeling is performed based on the corrected infrared spectrum curve.

[0095] The amplitude difference between abnormal feature points and normal feature points reflects the abnormal part of the amplitude of the abnormal feature points compared with the normal feature points. The abnormal evaluation index presents the degree of amplitude abnormality of the abnormal feature points. The abnormal feature points on the infrared spectrum curve are corrected by combining the two factors to improve the accuracy of the correction of abnormal feature points, effectively solve the problem of poor quality of infrared spectrum data of alfalfa and licorice due to instrument failure and improper operation, and improve the accuracy of subsequent models.

[0096] Preferably, in some possible implementation modes of the embodiments of the present invention, the method for obtaining the corrected amplitude of the abnormal feature point includes: recording the adjacent previous normal feature point of each abnormal feature point on the infrared spectrum curve as the reference point of each abnormal feature point; using the abnormal evaluation index of each abnormal feature point, weighting the absolute value of the difference between the amplitude of each abnormal feature point and its reference point to obtain the abnormal correction value of each abnormal feature point; if the amplitude of each abnormal feature point is greater than the amplitude of its reference point, then taking the difference between the amplitude of each abnormal feature point and the abnormal correction value as the corrected amplitude of the corresponding abnormal feature point; if the amplitude of each abnormal feature point is less than the amplitude of its reference point, then taking the sum of the amplitude of each abnormal feature point and the abnormal correction value as the corrected amplitude of the corresponding abnormal feature point; and determining the correction point of each abnormal feature point, the amplitude of the correction point being the corrected amplitude of each abnormal feature point.

[0097] The absolute value of the difference between the amplitude of the abnormal feature point and its reference point reflects the abnormal part of the amplitude of the abnormal feature point compared with the normal feature point. If the amplitude of the abnormal feature point is greater than the amplitude of its reference point, it means that the amplitude of the abnormal feature point is higher than that of the normal feature point, and it is necessary to suppress the abnormal feature point, that is, reduce the amplitude of the abnormal feature point, and then the difference between the amplitude of the abnormal feature point and the abnormal correction value is used as the correction amplitude of the corresponding abnormal feature point. If the amplitude of the abnormal feature point is less than the amplitude of its reference point, it means that the amplitude of the abnormal feature point is lower than that of the normal feature point, and it is necessary to enhance the abnormal feature point, that is, increase the amplitude of the abnormal feature point, and then the sum of the amplitude of the abnormal feature point and the abnormal correction value is used as the correction amplitude of the corresponding abnormal feature point.

[0098] It should be noted that since the reference point is a normal feature point, the amplitude of the abnormal feature point and its reference point is not equal. The wavelength of the abnormal feature point and its correction point is equal, only the amplitude is different; each abnormal feature point has only one correction point. The feature points on the infrared spectrum curve are arranged from small to large according to the wavelength to obtain a feature point sequence; any abnormal feature point in the feature point sequence is recorded as the target point. If there is no normal feature point in the feature point before the target point, the next normal feature point after the target point is recorded as the reference point of the target point.

[0099] In a specific implementation of the embodiment of the present invention, the correction amplitude of the abnormal feature point is expressed by the formula:

[0100]

[0101] In the formula, is the correction amplitude of each abnormal feature point; F is the amplitude of each abnormal feature point; is the amplitude of the reference point for each abnormal feature point; is the abnormal evaluation index for each abnormal feature point; is the abnormal correction value for each abnormal feature point; is the absolute value function.

[0102] The least square method is used to perform curve fitting on the normal characteristic points and the correction points of the abnormal characteristic points on the infrared spectrum curve to obtain a corrected infrared spectrum curve. The least square method is a well-known technology for those skilled in the art and will not be described in detail here.

[0103] At this point, the abnormality detection and correction of the infrared spectrum curve of the alfalfa hay sample is completed.

[0104] Model building and model verification were performed using modeling software to complete the near-infrared spectroscopy rapid detection of DOM content in alfalfa hay, as follows:

[0105] First, the Kennard-Stone algorithm (Kolmogorov-Smirnov, KS) is used to The alfalfa hay samples were divided into a calibration set and a validation set according to the ratio of , and the model was established; after the calibration model was established, the calibration set used the cross-validation determination coefficient, calibration standard analysis error, and cross-validation standard error to determine the quality of the calibration model. The smaller the difference between the calibration standard analysis error and the cross-validation standard error and the larger the cross-validation determination coefficient, the more reliable the model; then, the prediction determination coefficient was used to verify the model. When the prediction determination coefficient was equal to the constant 1, it meant that the change in the concentration of the calibration set was 100% explained; finally, the accuracy of the prediction model was evaluated by external verification of the relative analysis error. The larger the relative analysis error, the better the prediction effect of the calibration model.

[0106] So far, the present invention is completed.

[0107] Embodiment 2:

[0108] The present invention proposes a modeling system for rapid near-infrared spectroscopy detection of DOM content in alfalfa hay, as provided in an embodiment. Figure 3 , which shows a system structure diagram of a modeling system for rapid near-infrared spectrum detection of DOM content in alfalfa hay provided by an embodiment of the present invention, the system comprising:

[0109] The data acquisition module 510 is used to obtain the infrared spectrum curve of the alfalfa hay sample;

[0110] The feature point selection module 520 is used to divide the infrared spectrum curve into different sub-curves, merge the sub-curves according to the amplitude difference between the data points on each sub-curve and its adjacent sub-curves, and the length of each sub-curve to obtain different feature curves; divide the sub-curve into different local curves, and determine the adjustment sampling frequency of the corresponding local curve according to the inclination and length of each local curve of the sub-curve; and obtain the feature points on each local curve by adjusting the sampling frequency;

[0111] The feature point division module 530 is used to establish a plurality of isolated trees based on the feature points on each feature curve, and obtain an abnormal evaluation index of each feature point on each feature curve according to the depth difference of each feature point in all the isolated trees in which it is located, and the depth of each feature point in the isolated tree in which it is located; and divide the feature points on each feature curve into normal feature points and abnormal feature points based on the abnormal evaluation index;

[0112] The modeling module 540 is used to correct the infrared spectrum curve according to the amplitude difference between the abnormal feature points and the normal feature points on the infrared spectrum curve, and the abnormal evaluation index of the abnormal feature points to obtain a corrected infrared spectrum curve; and to perform modeling based on the corrected infrared spectrum curve.

[0113] It should be noted that: the device provided in the above embodiment is only illustrated by the division of the above functional modules. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the computer device is divided into different functional modules to complete all or part of the functions described above. In addition, the modeling system for the near-infrared spectrum rapid detection of the DOM content of alfalfa hay provided in the above embodiment and the modeling method embodiment for the near-infrared spectrum rapid detection of the DOM content of alfalfa hay belong to the same concept. The specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0114] Embodiment 3:

[0115] Figure 4 A computer device schematic diagram of a modeling device for rapid near-infrared spectroscopy detection of DOM content in alfalfa hay provided by an embodiment of the present invention. Figure 4 As shown, the computer device includes: a memory 601, a processor 602, and a computer program 603 stored in the memory 601 and running on the processor 602, wherein when the processor 602 executes the computer program 603, the computer device can execute any of the aforementioned modeling methods for rapid near-infrared spectroscopy detection of DOM content in alfalfa hay.

[0116] In addition, an embodiment of the present application also protects a device, which may include a memory and a processor, wherein the memory stores an executable program code, and the processor is used to call and execute the executable program code to execute a modeling method for rapid near-infrared spectroscopy detection of DOM content in alfalfa hay provided in an embodiment of the present application.

[0117] In this embodiment, the functional modules of the device can be divided according to the above method example. For example, each functional module can be corresponded, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0118] It should be understood that the device provided in this embodiment is used to execute the above-mentioned modeling method for rapid detection of DOM content in alfalfa hay by near-infrared spectroscopy, and thus can achieve the same effect as the above-mentioned implementation method.

[0119] In the case of an integrated unit, the device may include a processing module and a storage module. When the device is applied to a device, the processing module may be used to control and manage the actions of the device. The storage module may be used to support the device to execute mutual program codes, etc.

[0120] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits included in the disclosure of this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.

[0121] It should be noted that the sequence of the above embodiments of the present invention is for description only and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying 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.

[0122] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0123] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy, characterized in that: The method includes: Obtain infrared spectrum curve of alfalfa hay sample; The infrared spectrum curve is divided into different sub-curves, and the sub-curves are merged according to the amplitude difference between each sub-curve and the data points on the adjacent sub-curves and the length of each sub-curve to obtain different characteristic curves; the sub-curve is divided into different local curves, and the adjustment sampling frequency of the corresponding local curve is determined according to the inclination and length of each local curve of the sub-curve; the characteristic points on each local curve are obtained at the adjusted sampling frequency; Establishing a number of isolated trees based on the feature points on each feature curve, obtaining an abnormality evaluation index for each feature point on each feature curve according to the depth difference of each feature point in all the isolated trees in which it is located, and the depth of each feature point in the isolated tree in which it is located; dividing the feature points on each feature curve into normal feature points and abnormal feature points based on the abnormality evaluation index; According to the amplitude difference between the abnormal feature point and the normal feature point on the infrared spectrum curve, and the abnormal evaluation index of the abnormal feature point, the infrared spectrum curve is corrected to obtain a corrected infrared spectrum curve; and modeling is performed based on the corrected infrared spectrum curve; The step of dividing the infrared spectrum curve into different sub-curves includes: Obtain the minimum value points on the infrared spectrum curve, and record the curve between every two adjacent minimum value points as a sub-curve; The step of dividing the sub-curve into different local curves includes: Divide each sub-curve into two local curves based on the maximum point on each sub-curve; The sub-curves are merged according to the amplitude difference between each sub-curve and the data points on its adjacent sub-curves, and the length of each sub-curve, to obtain different characteristic curves, including: Obtain the maximum point on each sub-curve of the infrared spectrum curve; for the sub-curves other than the first sub-curve of the infrared spectrum curve, obtain the merging index between each sub-curve and its adjacent previous sub-curve according to the amplitude difference between the maximum point on each sub-curve and its adjacent previous sub-curve, and the wavelength difference between the two end points of each sub-curve; A similar sequence is formed by the first sub-curve of the infrared spectrum curve, and the second sub-curve is used as the sub-curve to be updated. When the merging index between the sub-curve to be updated and its adjacent previous sub-curve meets a preset condition, the sub-curve to be updated is added to the similar sequence, the similar sequence is updated, and the adjacent next sub-curve of the sub-curve to be updated is used as the next sub-curve to be updated; when the merging index does not meet the preset condition, the similar sequence is used as the merging sequence, and a new similar sequence is formed by the sub-curve to be updated, and the adjacent next sub-curve of the sub-curve to be updated is used as the new sub-curve to be updated, and it is determined whether the merging index between the new sub-curve to be updated and its adjacent previous sub-curve meets the preset condition, all sub-curves of the infrared spectrum curve are traversed, and the sub-curves of the infrared spectrum curve are divided into a plurality of merging sequences; Merging the sub-curves in each of the merged sequences to obtain a characteristic curve; The step of determining the adjustment sampling frequency of the corresponding local curve according to the inclination and length of each local curve of the sub-curve comprises: For each local curve of each sub-curve, the ratio of the absolute value of the difference between the amplitudes of the two end points of the local curve to the absolute value of the difference between the wavelengths is used as the inclination index of the local curve; the ratio of the absolute value of the difference between the wavelengths of the two end points of the local curve to the absolute value of the difference between the wavelengths of the two end points of the sub-curve where the local curve is located is recorded as the length ratio index of the local curve; According to the tilt index and the length ratio index, a sampling index of the local curve is obtained; the tilt index and the sampling index are positively correlated, and the length ratio index and the sampling index are negatively correlated; The preset sampling frequency corresponding to the local curve is weighted by using the sampling index, and the weighted result is rounded to obtain the adjusted sampling frequency of the local curve.

2. A modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy according to claim 1, characterized in that: The step of obtaining an abnormality evaluation index for each characteristic point on each characteristic curve includes: For all feature points on each feature curve, obtain the depth of each feature point in each isolated tree where it is located; The variance of the depth of each feature point in all isolated trees in which it is located is recorded as the depth dispersion index of each feature point; The ratio of the depth of each feature point in each isolated tree where it is located to the depth of the isolated tree is used as the local depth index of each isolated tree where each feature point is located; the cumulative sum of the local depth indexes of all isolated trees where each feature point is located is recorded as the comprehensive depth index of each feature point; According to the depth discrete index and the comprehensive depth index, an abnormality evaluation index of each feature point is obtained; the depth discrete index and the abnormality evaluation index are positively correlated, and the comprehensive depth index and the abnormality evaluation index are negatively correlated.

3. A modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy according to claim 1, characterized in that: The method of correcting the infrared spectrum curve according to the amplitude difference between the abnormal feature point and the normal feature point on the infrared spectrum curve and the abnormal evaluation index of the abnormal feature point to obtain the corrected infrared spectrum curve includes: The adjacent previous normal feature point of each abnormal feature point on the infrared spectrum curve is recorded as the reference point of each abnormal feature point; using the abnormal evaluation index of each abnormal feature point, the absolute value of the difference between the amplitude of each abnormal feature point and its reference point is weighted to obtain the abnormal correction value of each abnormal feature point; If the amplitude of each abnormal feature point is greater than the amplitude of its reference point, the difference between the amplitude of each abnormal feature point and the abnormal correction value is used as the correction amplitude of the corresponding abnormal feature point; if the amplitude of each abnormal feature point is less than the amplitude of its reference point, the sum of the amplitude of each abnormal feature point and the abnormal correction value is used as the correction amplitude of the corresponding abnormal feature point; Determine a correction point for each abnormal feature point, wherein the amplitude of the correction point is the correction amplitude of each abnormal feature point; Curve fitting is performed on the correction points of the normal characteristic points and the abnormal characteristic points on the infrared spectrum curve to obtain a corrected infrared spectrum curve.

4. A modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy according to claim 1, characterized in that: The step of obtaining a merging index between each sub-curve and its adjacent previous sub-curve includes: The absolute value of the difference between the amplitude of each sub-curve and the maximum point on the previous sub-curve and the product of the absolute value of the difference between the wavelengths of the two endpoints of each sub-curve are negatively correlated and normalized to obtain the merging index between each sub-curve and its previous sub-curve.

5. A modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy according to claim 1, characterized in that: The preset condition is that the merging index between the sub-curve to be updated and its adjacent previous sub-curve is greater than a preset merging threshold.

6. A modeling method for rapid detection of DOM content in alfalfa hay by near infrared spectroscopy according to claim 1, characterized in that: The dividing the characteristic points on each characteristic curve into normal characteristic points and abnormal characteristic points based on the abnormal evaluation index comprises: For all feature points on each feature curve, feature points whose abnormal evaluation index is greater than a preset abnormal threshold are recorded as abnormal feature points, and feature points whose abnormal evaluation index is less than or equal to the preset abnormal threshold are recorded as abnormal feature points.

Citation Information

Patent Citations

  • Construction and application of prediction model for effective components of alfalfa hay

    CN110208210A

  • Method, apparatus, server and system for real-time vital sign detection and monitoring

    US20190178980A1