Oil product detection method, system, equipment and medium based on near infrared spectrum

Through near-infrared spectroscopy combined with small sample machine learning algorithms, the characteristic absorption peaks of oil products are extracted and the oil product detection model is constructed, solving the complex and time-consuming problems of traditional detection methods and achieving fast and accurate oil product composition analysis.

CN120253745AInactive Publication Date: 2025-07-04TIANJIN INST OF PROD QUALITY SUPERVISION & TESTING TECH +2

Patent Information

Application Number
CN202510756454.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-09
Publication Date
2025-07-04
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional oil product detection methods are complex, time-consuming and difficult to achieve large-scale real-time detection. Near-infrared spectroscopy technology requires a large number of samples to model in oil product detection, which limits its wide application.

Method used

The characteristic absorption peaks are extracted by near-infrared spectroscopy technology, combined with partial least squares method and small sample machine learning algorithm, and the characteristic absorption peaks are extracted through UVE spectral line screening and SPA continuous projection algorithm, and the oil product detection model is constructed using SPXY dataset division and partial least squares method to realize the modeling of a small number of samples.

Benefits of technology

It improves the accuracy and robustness of the detection, reduces detection errors, and realizes fast and accurate oil composition analysis, which is suitable for instant detection of ethanol gasoline and diesel.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120253745A_ABST
    Figure CN120253745A_ABST
Patent Text Reader

Abstract

The invention discloses a near infrared spectrum-based oil product detection method, system, equipment and medium, and relates to the technical field of oil product detection, and the method comprises the following steps: collecting the spectrum of an oil product; the method comprises the following steps: extracting a characteristic absorption peak of a near infrared spectrum, obtaining data samples, obtaining physical and chemical values and spectrum variables of the near infrared spectrum, calculating distances between the data samples according to the physical and chemical values and the spectrum variables, selecting the data sample with the largest distance between the data samples as a final data sample, and constructing a model by applying a partial least square method. And training the model through the training set to obtain a trained oil product detection model, processing the near infrared spectrum of an oil product to be detected into a final data sample, and inputting the final data sample obtained through processing into the trained oil product detection model to obtain an oil product detection result. The absolute error and the relative error between the model prediction result and the standard test result are both controlled at a low level, various detection parameters in the oil product can be accurately analyzed, and powerful support is provided for oil product quality supervision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of oil product detection, and particularly to an oil product detection method, system, device and medium based on near-infrared spectroscopy. Background Art

[0002] Both infrared rays and visible light belong to electromagnetic waves. Infrared rays are a section of electromagnetic waves between visible light and microwaves. According to the wavelength range, infrared light can be divided into three regions: near-infrared, mid-infrared, and far-infrared. A near-infrared spectrometer (Near-Infrared Spectrum Instrument, NIRS) is an electromagnetic radiation wave between visible light (VIS) and mid-infrared (MIR). The American Society for Testing and Materials (ASTM) defines the near-infrared spectral region as the region of 780 - 2526 nm, which is the first non-visible light region discovered in the absorption spectrum by people. The near-infrared spectral region is consistent with the absorption region of the combination frequencies and various overtones of the hydrogen-containing groups (O-H, N-H, C-H) in organic molecules. By scanning the near-infrared spectrum of a sample, the characteristic information of the hydrogen-containing groups in the organic molecules of the sample can be obtained. Moreover, analyzing samples using near-infrared spectroscopy technology has the advantages of convenience, rapidity, high efficiency, accuracy, and relatively low cost, without damaging the sample, consuming chemical reagents, or polluting the environment.

[0003] In modern society, oil products (such as ethanol gasoline, diesel) play a crucial role in fields such as transportation and industrial production. However, traditional oil product detection methods have many drawbacks. Taking the detection of ethanol gasoline by gas chromatography as an example, the pre-treatment process of its samples is extremely complex, the analysis speed is slow, the instrument maintenance cost is high, and it can only be completed by on-site sampling and sending the samples for inspection, making it difficult to achieve large-scale instant detection and feedback. Diesel detection also faces similar problems. Each parameter needs to be detected separately, the detection process is cumbersome and the cycle is long, which cannot meet the requirements of large-scale instant sampling and timely feedback of detection results. Although near-infrared spectroscopy technology has received attention in the field of oil product detection, traditional modeling methods have limitations in processing complex spectral data of oil products. Machine learning usually requires a large number of samples to complete modeling, which restricts the wide application of near-infrared spectroscopy technology in oil product detection. Summary of the Invention

[0004] The purpose of the present invention is to provide an oil product detection method, system, device and medium based on near-infrared spectroscopy for solving the problems in the prior art in view of the above-mentioned deficiencies of the prior art.

[0005] The present invention specifically provides the following technical solutions: An oil product detection method based on near-infrared spectroscopy, comprising: Collecting the near-infrared spectrum of the oil product; Extract the characteristic absorption peaks of the near-infrared spectrum to obtain multiple data samples, and acquire the physicochemical values and spectral variables of the near-infrared spectrum. Calculate the distances between the data samples based on the physicochemical values and spectral variables, and select the data sample with the largest distance between data samples as the final data sample; Use the partial least squares method to construct an oil product detection model for the relationship between the oil product concentration and the intensity of the near-infrared spectral line, and use the final data sample to train the oil product detection model to obtain a trained oil product detection model; Process the near-infrared spectrum of the oil product to be measured into the final data sample, and input the processed final data sample into the trained oil product detection model to obtain the oil product detection result.

[0006] Preferably, the oil products include ethanol gasoline and diesel, and when extracting the characteristic absorption peaks of the near-infrared spectra of ethanol gasoline and diesel, the UVE spectral screening algorithm and the SPA successive projection algorithm are respectively used.

[0007] Preferably, using the UVE spectral screening algorithm to extract the characteristic absorption peaks of the near-infrared spectrum of ethanol gasoline includes: By adding an artificial noise matrix and establishing a partial least squares PLS model through cross-validation, calculate the ratio of the average value of the regression coefficients of each variable in the near-infrared spectrum of ethanol gasoline to the standard deviation; the specific expression is: ; Among them, h i is the ratio of the average value to the standard deviation, is the variable i is the average value of the regression coefficients, is the variable i is the standard deviation of the regression coefficients, is the regression coefficient, the variable i is a near-infrared spectral line; Use the maximum ratio of the average value of the variable regression coefficients to the standard deviation as the threshold, eliminate the near-infrared spectral lines with the ratio of the average value of the variable regression coefficients to the standard deviation less than the threshold, and extract the characteristic absorption peaks related to ethanol gasoline from the remaining near-infrared spectral lines.

[0008] Preferably, using the SPA successive projection algorithm to extract the characteristic absorption peaks of the near-infrared spectrum of diesel includes: Generate the hyperspectral data matrix of the near-infrared spectrum of diesel; Select a spectral vector from the hyperspectral data matrix as the first endmember, and calculate the projection lengths between the current candidate endmember set and each spectral vector in the hyperspectral data matrix; the specific expression is: ; Among them, Represents a spectral vector On the subspace spanned by the spectral vector The projection length obtained by orthogonal projection, S For the set, Represents a spectral vector And the spectral vector Inner product of, Indicates to first calculate the spectral vector Inner product with itself and take the reciprocal; Select the spectral vector with the minimum projection length as the new endmember to be added to the candidate set. When the number of selected endmembers reaches the predetermined number, the iteration is terminated, and the characteristic absorption peaks related to diesel in the near-infrared spectrum are extracted.

[0009] Preferably, the distance between data samples is calculated according to the physical and chemical values and spectral variables, and the specific expression is: ; ; ; Where, p And q Represent two different samples, N Represents the number of spectral wave points of the sample, Represents the distance between data samples in the spectral space, Represents the distance between data samples in the physical and chemical value space, Represents the distance between samples on the two-dimensional coordinate, x p Is the sample p Spectral variable of, x q Is the sample q Spectral variable of, y p Is the sample p Physical and chemical value of, y q Is the sample q Physical and chemical value of.

[0010] Preferably, the detection model for constructing the relationship between the oil product concentration and the near-infrared spectral line intensity by using the partial least squares method has the specific expression: ; Where, C Is the oil product concentration in the detection model, I i Is the wavelength variable, β i Is the regression coefficient, E is the residual, n Is the number of selected wavelengths.

[0011] Preferably, after taking the oil product out of the refrigerating chamber, using a cylindrical spectrophotometric cell with air as a reference, scanning is performed to collect the near-infrared spectrum of the oil product.

[0012] The present invention provides an oil product detection system based on near-infrared spectrum, comprising: An acquisition module, configured to acquire the near-infrared spectrum of the oil product; A feature extraction module, configured to extract the characteristic absorption peaks of the near-infrared spectrum, obtain a plurality of data samples, and acquire the physical and chemical values and spectral variables of the near-infrared spectrum, calculate the distances between the data samples according to the physical and chemical values and spectral variables, and select the data sample with the largest distance between the data samples as the final data sample; A model training module, configured to construct an oil product detection model for the relationship between the oil product concentration and the near-infrared spectral line intensity by using the partial least squares method, and train the oil product detection model with the final data sample to obtain a trained oil product detection model; A detection module, configured to process the near-infrared spectrum of the oil product to be measured into a final data sample, and input the processed final data sample into the trained oil product detection model to obtain an oil product detection result.

[0013] The present invention provides a computer device, comprising a memory and a processor, wherein a program is stored in the memory, and when the program is executed by the processor, the processor executes the steps of the above-mentioned oil product detection method based on near-infrared spectrum.

[0014] The present invention provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned oil product detection method based on near-infrared spectrum are implemented.

[0015] Compared with the prior art, the present invention has the following remarkable advantages: The present invention extracts the characteristic absorption peaks of the near-infrared spectrum to obtain data samples as the basis for analyzing the components of the oil product, calculates the distances between the data samples according to the physical and chemical values and spectral variables, and selects the data sample with the largest distance between the data samples as the final data sample, which can characterize the data sample distribution, ensure that the data samples can cover the diversity of the sample space in both the spectral and physical and chemical value dimensions, increase the sample difference and representativeness, and constructs a detection model for the relationship between the oil product concentration and the near-infrared spectral line intensity by using the partial least squares method. Through the above learning, the process of model building can be completed with only a small number of samples, solving the problem of large sample requirements for traditional machine learning model building, improving the robustness and prediction accuracy of the model at the same time, and effectively reducing the detection error. Description of the Drawings

[0016] Figure 1 For the mid-infrared spectral wavelength range and characteristics used in the present invention; Figure 2are the original spectral data and preprocessed spectral data of gasoline; among them, Figure 2 (a) of Figure 2 is the original spectral data of gasoline, Figure 2 (b) of Figure 2 is the preprocessed spectral data; Figure 3 are the original spectral data and preprocessed spectral data of diesel; among them, Figure 3 (a) of Figure 3 is the original spectral data of diesel, Figure 3 (b) of Figure 3 is the preprocessed spectral data; Figure 4 is the flowchart of an oil product detection method based on near-infrared spectroscopy according to the present invention. Specific embodiments

[0017] Next, in conjunction with the drawings in the present invention, the technical solutions of the embodiments of the present invention will be clearly and completely described. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all embodiments. Based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0018] Theoretically analyzed, the main energy level transition types in the near-infrared spectral range are the overtone absorptions of O-H, N-H, and C-H bonds. The main components of gasoline are C5-C12 aliphatic hydrocarbons and naphthenes, as well as a certain amount of aromatic hydrocarbons. Using a near-infrared spectrometer can achieve the component analysis of gasoline. Although the energy of near-infrared spectroscopy is relatively weak, only about 1 ml of the sample is required to complete the near-infrared spectral data sampling, and the sampling speed is extremely fast, the sample will not be damaged, and real-time sampling and real-time acquisition of analysis data can be achieved. Near-infrared spectroscopy can achieve rapid detection and analysis of the components of ethanol gasoline and diesel.

[0019] As Figure 1 and Figure 4 shown, an oil product detection method based on near-infrared spectroscopy in this embodiment includes the following steps: Step S1: Collect the near-infrared spectrum of the oil product.

[0020] Use a PerkinElmer Spectrum Two N Fourier transform infrared spectrometer to collect the spectrum of the oil product sample to be tested. After taking the sample out of the cold storage, let it stand for 1.5 hours in a room temperature environment (about 27 °C), and then use the Fourier transform infrared spectrometer to collect the spectrum of the oil product sample. The spectral sampling range is set to 4500 cm - ⁻¹ to 8000 cm - ⁻¹ (for diesel) or 8000 cm - ⁻¹ to 4500 cm - ⁻¹ (for ethanol gasoline), and the resolution is 2 cm -1. The number of scans was 8 times. Using air as a reference, scanning was performed with a supporting 8-mm cylindrical spectrophotometer cell to obtain the transmission spectrum data of the oil product.

[0021] After collecting the near-infrared spectrum of the oil product, the collected near-infrared spectral data (NIRS data) was preprocessed and transformed by using Savitzky-Golay (SG) spectral smoothing, multiplicative scatter correction (MSC), standard normal variate (SNV), first derivative (FD), and their combined methods to improve the resolution and signal-to-noise ratio of the spectral data and enhance the modeling performance.

[0022] Savitzky-Golay Filter processing: (1); In the formula: (2); In formula (2), H is the normalization factor, is the smoothing coefficient, is the Savitzky-Golay filter result, is the value of the input signal at position , is the weight coefficient of the filter kernel at offset , is the radius of the filter kernel in the horizontal direction. The SG smoothing filter is a digital filter that can improve data accuracy without changing the signal trend.

[0023] Multiplicative scatter correction (MSC) processing: Denote the average spectrum calculation formula: (3); Among them, is the total number of spectra participating in the average, is the value of the input signal at position , that is, the spectral vector at position .

[0024] Let the linear regression calculation formula: (4); Then the expression of the multiplicative scatter correction : (5); In formula (5): m i is the slope of the linear regression equation; b i is the intercept of the linear regression equation, is the result of linear regression. These two parameters are obtained by the least squares solution method. The MSC method can be regarded as a standardization method in spectral preprocessing. By adjusting the i and i values, the information of the original components can be retained, and the in-sample feature differences of the spectral data can be reduced. This method can eliminate the baseline drift and translation phenomena of the data.

[0025] Standard normal variate (SNV) processing: (6); In Equation (6), when the L1 norm is used, , which is the sum of all absolute values; when the L2 norm is used, , which is the L2 norm; when the max norm is used, , which is the largest .

[0026] First derivative (FD) processing: (7); In Equation (7): is the change at x i , and is the value of the input signal at position . Equation (7) is a commonly used method in infrared spectral preprocessing. This method can eliminate the baseline and reduce background interference, but it may also amplify noise at the same time.

[0027] Step S2: Extract the characteristic absorption peaks of the near-infrared spectrum, obtain multiple data samples, and obtain the physical and chemical values and spectral variables of the near-infrared spectrum. Calculate the distance between the data samples according to the physical and chemical values and spectral variables, and select the data sample with the largest distance between the data samples as the final data sample.

[0028] The oil products include ethanol gasoline and diesel. When extracting the characteristic absorption peaks of the near-infrared spectra of ethanol gasoline and diesel, the UVE spectral screening algorithm and the SPA sequential projection algorithm are used respectively.

[0029] By adding an artificial noise matrix and establishing a partial least squares (PLS) model through cross-validation, calculate the ratio of the average value to the standard deviation of the regression coefficients of each variable in the near-infrared spectrum of ethanol gasoline; the specific expression is: (8); Among them, h i is the ratio of the average value to the standard deviation, is a variable i the average value of the regression coefficient of is a variable i the standard deviation of the regression coefficient of is the regression coefficient, and the variable i is a near-infrared spectral line

[0030] Taking the maximum ratio of the average value to the standard deviation of the variable regression coefficient as the threshold, the near-infrared spectral lines with the ratio of the average value to the standard deviation of the variable regression coefficient less than the threshold are eliminated, and the characteristic absorption peaks related to ethanol gasoline are extracted from the remaining near-infrared spectral lines

[0031] The Successive Projection Algorithm (SPA) is a simple and effective algorithm for spectral separation. It is mainly applied to hyperspectral image processing for extracting endmembers in mixed spectral data. Endmembers refer to the spectral signatures of pure substances existing in hyperspectral images, and these signatures have important influences on the spectral data of mixed pixels

[0032] The basic principle of SPA is to gradually select spectral vectors that are as orthogonal to each other as possible through an iterative process. These vectors, as endmembers, can be used to decompose and interpret mixed spectral data

[0033] Generate the hyperspectral data matrix of the near-infrared spectrum of diesel. Select a spectral vector from the hyperspectral data matrix as the first endmember, and calculate the projection length between the current candidate endmember set and each spectral vector in the hyperspectral data matrix. The specific expression is: (9); where represents the projection length obtained by orthogonal projection of the spectral vector onto the subspace spanned by the spectral vector , S is a set, represents the inner product of the spectral vector and the spectral vector , represents first calculating the inner product of the spectral vector with itself and taking the reciprocal

[0034] Select the spectral vector with the minimum projection length as the new endmember and add it to the candidate set. When the number of selected endmembers reaches the predetermined number, the iteration is terminated, and the characteristic absorption peaks related to diesel in the near-infrared spectrum are extracted

[0035] SPA has a wide range of applications in the fields of hyperspectral remote sensing, environmental monitoring, agricultural research, etc. For example, SPA can be used to extract the spectral characteristics of different crop types in farmland, or to identify the components of pollutants in the environment. The Successive Projections Algorithm (SPA) is an effective method for extracting endmembers from hyperspectral images. By gradually selecting mutually orthogonal spectral vectors, it can well separate the pure substance spectra in the mixed spectral data. This algorithm is simple to calculate and has remarkable effects, so it has important application value in the field of hyperspectral data processing.

[0036] Using the SPXY algorithm, calculating the distance between samples according to two variables of physical and chemical values and spectra at the same time, and selecting the data sample with the largest distance between data samples as the final data sample can characterize the sample distribution to the greatest extent. Divide the data after feature extraction into a training set and a test set to ensure that the data samples can cover the sample space diversity in both the spectral and physical and chemical value dimensions. The specific expression for calculating the distance between samples according to two variables of physical and chemical values and spectra at the same time is: (10); (11); (12); Among them, p and q represent two different samples, N represents the number of spectral wave points of the sample, represents the distance between data samples in the spectral space, represents the distance between data samples in the physical and chemical value space, represents the distance between samples on the two-dimensional coordinate, x p is the spectral variable of sample p , x q is the spectral variable of sample q , y p is the physical and chemical value of sample p , y q is the physical and chemical value of sample q .

[0037] Step S3: Use the partial least squares method to construct an oil product detection model for the relationship between oil product concentration and near-infrared spectral line intensity, and use the final data sample to train the oil product detection model to obtain a trained oil product detection model.

[0038] This method can simultaneously extract the components of independent variables and dependent variables, effectively solve the problem of collinearity of independent variables, and reduce noise interference. Using the training set data as input, by continuously adjusting the model parameters, such as selecting the number of principal components (determined based on the root mean square error RMSE of the test set, and determining the optimal number of principal components by minimizing RMSEP), the model is trained to enable the model to learn the relationship between the oil product spectral data and the detection parameters.

[0039] The partial least squares method is used to construct the model, specifically as follows: PLS is an effective multivariate statistical method, which is essentially a regression method based on characteristic variables and is widely used in the processing of near-infrared spectral data. When decomposing the measurement matrix, the PLS model also orthogonally decomposes the response matrix and establishes a quantitative relationship between these two matrices, thus making it possible to predict multiple measurement responses.

[0040] PLS is a modeling method for multiple dependent variables with multiple independent variables. It can simultaneously extract components from independent variables and dependent variables, effectively solve the problem of collinearity of independent variables, and remove a part of noise interference. It is very suitable for analysis with a large number of independent variables in the full spectrum. In recent decades, it has developed rapidly in terms of theory, method, and application. Obtain the specific expressions of the partial least squares method PLS concentration and spectral line intensity: (13); Among them, C is the component content, that is, the oil product concentration in the detection model, I i is the wavelength variable, β i is the regression coefficient, E is the residual, n is the number of selected wavelengths.

[0041] Evaluation criteria (REMS and R 2 ): Evaluating the quality of the model is crucial for understanding the performance of the model, optimizing the model, selecting the best model, and predicting the effect of the model in practical applications. This model mainly uses the root mean square error RMSE (Root Mean Square Error) and the coefficient of determination R 2 (R-Square) as the basis for evaluating the results.

[0042] The root mean square error RMSE (Root Mean Square Error), as an index to evaluate the accuracy of the model, has been widely used in fields that require an intuitive understanding of the error magnitude, such as meteorological prediction, financial model analysis, engineering design, etc. Its high sensitivity to large errors is particularly helpful for optimizing applications that are particularly sensitive to errors.

[0043] RMSE is a statistic commonly used to measure the error of a prediction model. It represents the square root of the mean of the squares of the differences between the predicted values and the actual observed values. Simply put, RMSE is the square root of the mean squared error (MSE).

[0044] (14); In Equation (14), represents the actual value of the i-th observation, represents the predicted value of the i-th observation, and n is the total number of observations.

[0045] Coefficient of determination R 2 , also known as goodness of fit or correlation coefficient, is used to quantify how well a model fits the data. R 2 values range from 0 to 1, where 1 indicates that the model perfectly fits the data and 0 indicates that the model cannot explain any variation. The closer the R 2 value is to 1, the better the model's fitting effect, and the higher the proportion of the variation in the dependent variable that the independent variable can explain.

[0046] R 2 is calculated by subtracting the ratio of the sum of squared residuals (error sum of squares) to the sum of squared regression SSR (regression sum of squares) and the total sum of squared residuals from 1. The specific formula is as follows: (15); In Equation (15), SSE represents the error between the estimated value and the true value, reflecting the model's fitting degree; the denominator is the total sum of squared deviations (SST), which represents the error between the mean value and the true value, reflecting the degree of deviation from the mathematical expectation.

[0047] Step S4: Process the near-infrared spectrum of the oil sample to be tested into the final data sample, and input the processed final data sample into the trained oil quality detection model to obtain the oil quality detection result.

[0048] Model detection and application steps: Use the test set to verify the trained model and evaluate the prediction accuracy of the model. Input the oil sample data obtained from actual detection into the trained model, and the model outputs the predicted values of each detection parameter in the oil (such as sulfur content, ethanol content, aromatic hydrocarbon content, olefin content, density of ethanol gasoline; sulfur content, polycyclic aromatic hydrocarbon content, flash point, density, total pollution amount, etc. of diesel). By comparing the predicted values with the actual values, if the absolute error does not exceed 0.3 (for ethanol gasoline) or 0.1 (for diesel), and the relative error is not greater than 10%, it indicates that the model has good performance and can be used for actual oil quality detection.

[0049] Principle Analysis of the Present Invention: In the field of oil product detection, the combination of near-infrared spectroscopy technology and small-sample machine learning algorithms provides strong support for achieving rapid, efficient, and accurate detection. Its principle covers multiple key links.

[0050] 1. Basis of Near-Infrared Spectroscopy Technology: Near-infrared spectroscopy can interact with hydrogen-containing groups in oil products (such as C-H, O-H, N-H, etc.). When near-infrared light irradiates the oil product, these groups absorb light of specific wavelengths, causing molecular vibration and rotational energy level transitions, forming characteristic absorption peaks. Different oil product components and contents result in different absorption peaks, which is the basis for analyzing the components of oil products. This technology is easy to operate, has rapid detection, and low costs.

[0051] 2. Core Mechanism of Small-Sample Machine Learning Algorithms UVE Feature Extraction Algorithm (ethanol gasoline): UVE screens spectral lines based on the PLS regression coefficients. By adding a noise matrix and performing cross-validation to construct a PLS model, calculating the ratio of the average value of the variable regression coefficients to the standard deviation, using the maximum ratio as the threshold, and eliminating useless spectral lines smaller than the threshold, it accurately extracts the characteristic absorption peaks of the substances to be measured in ethanol gasoline, reducing the number and difficulty of modeling samples.

[0052] SPA Successive Projection Algorithm (diesel): SPA is used to extract the endmembers in the mixed spectrum of diesel. It iteratively selects orthogonal spectral vectors. First, a random vector is selected as the starting endmember, and then each time the projection lengths of the candidate endmember set and other vectors are calculated, and the vector with the minimum projection length is selected to be added to the set until the predetermined number is reached, effectively capturing the characteristic absorption peaks of diesel, which is conducive to small-sample modeling.

[0053] SPXY Dataset Partitioning: SPXY calculates the distance between samples based on physical and chemical values and spectral variables, can fully characterize the sample distribution, cover the multi-dimensional vector space, increase sample differences and representativeness, and improve the stability and generalization ability of the model.

[0054] Partial Least Squares (PLS) Modeling: PLS is suitable for multi-dependent variable to multi-independent variable modeling. There is a problem of independent variable collinearity in the spectral data of oil products, and PLS can solve this problem and reduce noise interference. By establishing the relationship between concentration and spectral line intensity, the number of principal components is selected based on the root mean square error of the test set to optimize the model performance and accurately predict the components of oil products. In the detection of real ethanol gasoline and diesel samples, both the absolute error and relative error between the model prediction results and the standard test results are controlled at a low level, and it can accurately analyze various detection parameters in oil products, providing strong support for the quality supervision of oil products. The spectral data of ethanol gasoline and diesel are as Figure 2 and Figure 3 shown. The comparison between the results obtained by the present invention and the traditional method of using the principal component analysis method for modeling on a large-scale dataset is shown in Tables 1 and 2.

[0055] Table 1 Comparison of the results obtained by using the principal component analysis method to model gasoline with the traditional method on a large-scale dataset

[0056] Table 2 Comparison of the results obtained by using the principal component analysis method to model diesel with the traditional method on a large-scale dataset

[0057] The present invention provides an oil product detection system based on near-infrared spectroscopy, comprising: a collection module, a feature extraction module, a model training module, and a detection module.

[0058] Among them, the collection module is used to collect the spectra of oil products; the feature extraction module is used to extract the characteristic absorption peaks of the near-infrared spectra, obtain a plurality of data samples, and obtain the physicochemical values and spectral variables of the near-infrared spectra, calculate the distances between the data samples according to the physicochemical values and spectral variables, and select the data sample with the largest distance between the data samples as the final data sample; the model training module is used to construct an oil product detection model for the relationship between the oil product concentration and the near-infrared spectral line intensity by using the partial least squares method, and use the final data sample to train the oil product detection model to obtain a trained oil product detection model; the detection module is used to process the near-infrared spectrum of the oil product to be measured into the final data sample, and input the processed final data sample into the trained oil product detection model to obtain the oil product detection result.

[0059] The present invention also provides a computer device, comprising a memory and a processor. When a program stored in the memory is executed by the processor, the processor executes the steps of an oil product detection method based on near-infrared spectroscopy.

[0060] According to the disclosed embodiments, the computer device can communicate with one or more external devices (such as a keyboard, a pointing device, Bluetooth communication, etc.), or communicate with any device (such as a router, a demodulator, etc.) that enables the computing device to communicate with one or more other computing devices.

[0061] The above content is a further detailed description of the present invention in combination with specific preferred embodiments. For those skilled in the art of the present invention, without departing from the concept of the present invention, several simple deductions or substitutions can be made, which should all be regarded as belonging to the protection scope of the present invention.

Claims

1. An oil detection method based on near-infrared spectroscopy, characterized in that, Comprising: Collecting the near-infrared spectrum of the oil product; Extracting the characteristic absorption peaks of the near-infrared spectrum to obtain a plurality of data samples, and obtaining the physicochemical values and spectral variables of the near-infrared spectrum. Calculating the distance between data samples according to the physicochemical values and spectral variables, and selecting the data sample with the largest distance between data samples as the final data sample; Using partial least squares method to construct an oil product detection model for the relationship between oil product concentration and near-infrared spectral line intensity, and using the final data sample to train the oil product detection model to obtain a trained oil product detection model; Processing the near-infrared spectrum of the oil product to be measured into a final data sample, and inputting the processed final data sample into the trained oil product detection model to obtain the oil product detection result.

2. The oil product detection method based on near-infrared spectroscopy according to claim 1, characterized in that, The oil products include ethanol gasoline and diesel oil, and when extracting the characteristic absorption peaks of the near-infrared spectra of ethanol gasoline and diesel oil, the UVE spectral screening algorithm and the SPA successive projection algorithm are respectively adopted.

3. The oil product detection method based on near-infrared spectroscopy according to claim 2, wherein Adopting the UVE spectral screening algorithm to extract the characteristic absorption peaks of the near-infrared spectrum of ethanol gasoline, including: By adding an artificial noise matrix and establishing a partial least squares PLS model through cross-validation, calculating the ratio of the average value of the regression coefficients of each variable in the near-infrared spectrum of ethanol gasoline to the standard deviation; the specific expression is: ; Among them, h i is the ratio of the mean value to the standard deviation, is the mean value of the regression coefficients of the variable i , is the standard deviation of the regression coefficients of the variable i , is the regression coefficient, and the variable i is a near-infrared spectral line; Taking the maximum ratio of the average value of the variable regression coefficient to the standard deviation as the threshold, eliminating the near-infrared spectral lines with the ratio of the average value of the variable regression coefficient to the standard deviation less than the threshold, and extracting the characteristic absorption peaks related to ethanol gasoline from the remaining near-infrared spectral lines.

4. The oil product detection method based on near-infrared spectroscopy according to claim 2, wherein Adopting the SPA successive projection algorithm to extract the characteristic absorption peaks of the near-infrared spectrum of diesel oil, including: Generating a hyperspectral data matrix of the near-infrared spectrum of diesel oil; Selecting a spectral vector from the hyperspectral data matrix as the first endmember, and calculating the projection length between the current candidate endmember set and each spectral vector in the hyperspectral data matrix; the specific expression is: ; Among them, represents the spectral vector On the subspace spanned by the spectral vector The projection length obtained by orthogonal projection, S is the set, represents the spectral vector and the spectral vector Inner product of, It means to first calculate the inner product of the spectral vector with itself and take the reciprocal; Selecting the spectral vector with the minimum projection length as the new endmember to be added to the candidate set, and terminating the iteration when the number of selected endmembers reaches a predetermined number, and extracting the characteristic absorption peaks related to diesel oil in the near-infrared spectrum.

5. The oil product detection method based on near-infrared spectroscopy according to claim 1, characterized in that, The calculation of the distance between data samples according to the physicochemical values and spectral variables, the specific expression is: ; ; ; Among them, p and q represent two different samples, N represents the number of spectral wave points of the sample, represents the distance between data samples in spectral space, represents the distance between data samples in the physical and chemical value space, represents the distance between samples in two-dimensional coordinates, x p is the spectral variable of sample p ; x q is the spectral variable of sample q ; y p is the physical and chemical value of sample p , y q is the physical and chemical value of sample q . It should be noted that there seems to be some inconsistent or incomplete expressions in the original text. This translation is based on the existing content as accurately as possible.

6. The oil product detection method based on near-infrared spectroscopy according to claim 1, characterized in that The use of partial least squares method to construct a detection model for the relationship between oil product concentration and near-infrared spectral line intensity, the specific expression is: ; Among them, C to detect the oil concentration in the model, I i is the wavelength variable, β i is the regression coefficient, and E is the residual, n is the number of selected wavelengths.

7. The oil product detection method based on near-infrared spectroscopy according to claim 1, characterized in that After taking the oil product out of the cold storage, using air as the reference and scanning with a cylindrical spectrophotometer cell to collect the near-infrared spectrum of the oil product.

8. An oil product detection system based on near-infrared spectroscopy, characterized in that, Comprising: A collection module for collecting the near-infrared spectrum of the oil product; A feature extraction module for extracting the characteristic absorption peaks of the near-infrared spectrum to obtain a plurality of data samples, and obtaining the physicochemical values and spectral variables of the near-infrared spectrum. Calculating the distance between data samples according to the physicochemical values and spectral variables, and selecting the data sample with the largest distance between data samples as the final data sample; A model training module for using partial least squares method to construct an oil product detection model for the relationship between oil product concentration and near-infrared spectral line intensity, and using the final data sample to train the oil product detection model to obtain a trained oil product detection model; The detection module is used to process the near-infrared spectrum of the oil to be tested into a final data sample, and input the obtained final data sample into the trained oil detection model to obtain the oil detection result.

9. A computer device, characterized in that, It includes a memory and a processor. A program is stored in the memory. When the program is executed by the processor, the processor is caused to execute the steps of the method for detecting oil based on near-infrared spectrum according to any one of claims 1 to 7.

10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the method for detecting oil based on near-infrared spectrum according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Millet origin traceability method based on mid-infrared spectrum technology and feature extraction

    CN113191618A

  • Fruit sugar degree nondestructive testing method based on spectral reflectivity reconstruction technology

    CN115015180A

  • Characteristic spectrum selection and gasoline ethanol content detection method based on chemical structure

    CN115236030A

  • Method and system for extracting net signal in near-infrared spectrum

    WO2023123329A1

Cited By

  • Methylal content analysis model training method and content analysis method based on methylal content analysis model training method

    CN122413357A