Tree classifier-based hydrogen production mode identification method and system
By using a tree classifier-based approach, leveraging the original composition and engineering characteristics of hydrogen samples, and combining minority class oversampling technology, the problem of rapid and accurate identification of hydrogen production process routes was solved, thereby improving the quality control and traceability management capabilities of the hydrogen energy industry chain.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA PETROLEUM & CHEMICAL CORP
- Filing Date
- 2025-12-24
- Publication Date
- 2026-05-08
AI Technical Summary
Existing technologies make it difficult to quickly and accurately identify hydrogen production processes, which hinders the fulfillment of needs such as quality control, safety supervision, and carbon footprint tracking in the hydrogen energy industry chain.
A tree-based classifier approach is adopted. By extracting the original component content of hydrogen samples, engineering features are constructed and data is cleaned. Minority oversampling technology is used to identify hydrogen production methods, including component proportion, composition entropy, logarithmic transformation and principal component analysis, and classification is performed in combination with decision trees.
It enables rapid and accurate identification of hydrogen production methods for hydrogen samples, improves the generalization ability of the classification model, and supports quality control and traceability management of the hydrogen energy industry chain.
Smart Images

Figure CN121995003A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of hydrogen analysis technology, specifically relating to a method and system for identifying hydrogen production methods based on a tree classifier. Background Technology
[0002] Hydrogen is a colorless, transparent, odorless, and highly flammable light gas with the chemical formula H₂. It consists of two hydrogen atoms bonded together by covalent bonds. As the lightest and least dense gaseous element in nature, hydrogen has a density of only 0.0899 g / L under standard conditions, exhibiting extremely strong diffusivity and permeability. These unique physicochemical properties make it play an irreplaceable and vital role in many fields, including industrial manufacturing, energy storage, and aerospace.
[0003] Currently, various industrial hydrogen production processes are employed, primarily including the following technological pathways: hydrogen production through water electrolysis, hydrogen production through reforming fossil fuels (such as natural gas and coal), hydrogen production through purification of industrial by-product gases (such as chlor-alkali industry and coke oven gas), and novel green hydrogen production technologies such as biomass hydrogen production and photocatalytic hydrogen production. Among these, water electrolysis, although energy-intensive, produces high-purity products and can be coupled with renewable energy power generation systems, making it considered the most promising clean hydrogen production method. Meanwhile, fossil fuel reforming, with its mature technology and lower production costs, currently dominates the global hydrogen supply. It is worth noting that with breakthroughs in proton exchange membrane electrolyzer technology and the continued decline in the cost of renewable energy power generation such as wind and solar power, the large-scale production of green hydrogen will gradually achieve breakthroughs in both economic feasibility and environmental friendliness in the future.
[0004] In the actual operation of the hydrogen energy industry chain, precise traceability of hydrogen sources is often required due to needs such as quality control, safety supervision, and carbon footprint tracking. For example, in the operation of hydrogen refueling stations, it is necessary to clarify the production process route of the hydrogen used; in chemical production processes, it is necessary to trace the purity and impurity content of raw material hydrogen; and in carbon emission accounting, it is necessary to distinguish the environmental attributes of hydrogen from different sources, such as gray hydrogen, blue hydrogen, and green hydrogen. These application scenarios all place clear technical requirements on the identification of hydrogen production methods in the early stages. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a method and system for identifying hydrogen production methods based on a tree classifier. Based on the original component content and engineering characteristics of a hydrogen sample, a tree classifier is used to quickly and accurately analyze the hydrogen production method.
[0006] The specific technical solution adopted in this invention is as follows: The primary objective of this patent is to provide a method for identifying hydrogen production methods based on a tree classifier, including: S1, the original component content of the extracted hydrogen sample; S2. Construct engineered features based on the original component content, wherein the engineered features include component proportion, composition entropy, logarithmic transformation, component interaction terms, and principal components; S3. Hydrogen production method identification: Using the aforementioned engineering features as input, a minority class oversampling is synthesized to alleviate class imbalance, and a tree classifier is used to determine the hydrogen production method.
[0007] Preferably, the original component content includes: H2O, O2, total hydrocarbons, He, N2, Ar, CO2, CO, total sulfur, HCHO, HCOOH, total halides, NH3, total non-hydrogen content, hydrogen purity, and maximum particulate matter concentration.
[0008] Preferably, S1 includes: S101. Extract hydrogen sample; S102. Detect the original component content in the hydrogen sample; S103. Perform data cleaning on the original component content; S104, Definition and mapping of target variables.
[0009] Preferably, S2 includes: S201. Construct 50 engineered features based on the original component content; S202. After merging the basic features, the total number of features in the engineering feature set is 66.
[0010] Preferably, S201 includes: calculating the total component content, the total inert gas content, the ratio of hydrocarbons to carbon dioxide, the ratio of oxygen to water content, the compositional entropy, the count of zero-value components, and the count of missing values based on the original component content; calculating the proportion of each original component content in the total component content, the value after log1p transformation, and the selected inter-component product interaction term for each component content; and extracting the scores of the first three principal components after standardizing the original component matrix to generate 50 engineered features.
[0011] Preferably, the basic features include raw composition data of the following components: water, oxygen, total hydrocarbons, helium, nitrogen, argon, carbon dioxide, carbon monoxide, total sulfur, formaldehyde, formic acid, total halides, ammonia, total non-hydrogen content, hydrogen purity, and maximum particulate matter concentration.
[0012] Preferably, the minority class oversampling includes: selecting k nearest neighbors in the feature space of minority class samples, generating synthetic samples by linear interpolation of minority class samples and their nearest neighbors, until the number of minority class samples is equal to the number of majority class samples, thereby achieving class balance in the training dataset, thereby enhancing the tree classifier's sensitivity to minority class recognition and improving overall classification performance.
[0013] The second objective of this patent is to provide a hydrogen production method identification system based on a tree classifier, comprising: The data extraction module extracts the original component content of the hydrogen sample; The feature generation module constructs engineered features based on the original component content. The engineered features include component proportion, composition entropy, logarithmic transformation, component interaction terms, and principal components. The identification module identifies the hydrogen production method by using the aforementioned engineering features as input, synthesizing minority class oversampling to alleviate class imbalance, and then using a tree classifier to determine the hydrogen production method.
[0014] The third objective of this patent is to provide a computer program product, including a computer program that, when executed by a processor, provides the aforementioned method for identifying hydrogen production methods based on a tree classifier.
[0015] The fourth objective of this patent is to provide an information data processing terminal that implements the above-mentioned hydrogen production method identification method based on a tree classifier.
[0016] The fifth objective of this patent is to provide a computer-readable storage medium, including instructions that, when executed on a computer, cause the computer to perform the aforementioned hydrogen production method identification method based on a tree classifier.
[0017] The advantages and positive effects of this invention are as follows: By adopting the above technical solution, the present invention has the following technical effects: This invention first employs high-precision gas detection instruments or chemical analysis methods to conduct comprehensive compositional analysis of hydrogen samples, accurately acquiring the content data of various raw components in the hydrogen samples, including but not limited to key indicators such as water, oxygen, and the types and concentrations of impurity gases. After acquiring the raw component content data, this invention preprocesses these raw component contents, subsequently constructing a series of engineered features with clear physical meaning and discriminative value. These engineered features can fully reflect the unique chemical fingerprint characteristics of different hydrogen production processes. Subsequently, this invention uses an ensemble classification algorithm based on decision trees, combined with a specially designed minority class oversampling technique, to perform intelligent pattern recognition and classification analysis on the constructed engineered feature dataset. Through this comprehensive data processing method, the system can effectively overcome the sample imbalance problem, significantly improve the generalization ability of the classification model, thereby achieving rapid and accurate identification of hydrogen production methods in hydrogen samples, providing reliable technical support for quality control and traceability management in the hydrogen energy industry chain. Attached Figure Description
[0018] Figure 1 A flowchart of a preferred embodiment of the present invention; Figure 2The diagram shows a tree classifier structure in a preferred embodiment of the present invention where the baseline features do not use oversampling. The baseline features refer to the original features, i.e., the sample report data after only data processing. Figure 3 In a preferred embodiment of the present invention, the baseline features do not use an oversampled Gini importance histogram; Figure 4 This is a diagram of a tree classifier structure using oversampled baseline features in a preferred embodiment of the present invention. Figure 5 In a preferred embodiment of the present invention, an oversampled Gini importance histogram is used for the baseline features; Figure 6 This is a diagram of a tree classifier structure in a preferred embodiment of the present invention that does not use oversampling for engineered features; Figure 7 In a preferred embodiment of the present invention, the engineered features do not use oversampled Gini importance histograms; Figure 8 This is a diagram of an oversampled tree classifier structure used in a preferred embodiment of the present invention. Figure 9 In a preferred embodiment of the present invention, an oversampled Gini importance histogram is used for the engineering features; Figure 10 This is a two-dimensional projection diagram of PCA in a preferred embodiment of the present invention; Figure 11 This is a PCA three-dimensional projection diagram in a preferred embodiment of the present invention. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Please see Figure 1 ; The first embodiment, a method for identifying hydrogen production methods based on a tree classifier, mainly includes: S1, the original component content of the extracted hydrogen sample; For example, high-precision gas detection instruments or chemical analysis methods can be used to perform comprehensive component analysis on hydrogen samples, accurately obtaining the content data of various original components in the hydrogen sample. Specifically, precise instruments such as gas chromatographs and mass spectrometers, combined with standardized detection procedures and strict quality control measures, can be used to quantitatively determine trace impurities in hydrogen samples. The content of the original components includes, but is not limited to: H2O (moisture content), O2 (oxygen content), total hydrocarbons (total of all hydrocarbons), He (helium content), N2 (nitrogen content), Ar (argon content), CO2 (carbon dioxide content), CO (carbon monoxide content), total sulfur (total of all sulfides), HCHO (formaldehyde content), HCOOH (formic acid content), total halides (total of all halogen compounds), NH3 (ammonia content), total non-hydrogen (total of all non-hydrogen components), hydrogen purity (volume percentage of hydrogen), and maximum particulate matter concentration (maximum content of solid particles). The accurate determination of these indicators is of great significance for assessing hydrogen quality and identifying subsequent hydrogen production methods.
[0021] S2. Construct engineered features based on the original component content, wherein the engineered features include component proportion, composition entropy, logarithmic transformation, component interaction terms, and principal components; This step is one of the core steps of this invention, for example: The process of constructing the component percentages is as follows: After filling the original component columns with missing numerical values (using the column median) and converting each component column to numerical values, the component sum (components_sum) for each sample is calculated: components_sum=Σ_{c∈C}component_c; Where C is the set of component columns used for construction; let ε = 1 × 10 -9 To prevent division by zero, a percentage feature frac_c = component_c / (components_sum + ε) is constructed for each component c, and recorded with the name frac_<component name>; all percentages are constructed column by column according to the above formula to form a set of percentage features.
[0022] The process of constructing the entropy is as follows: Based on the already constructed proportion of each component frac_c, first replace all 0 values in frac_c with ε (as above, ε = 1 × 10). -9 ), denoted as frac'_c=max(frac_c,ε); then calculate the composition entropy for each sample. (ln is the natural logarithm), and composition_entropy is used as the single scalar feature record for this sample.
[0023] The construction process of the logarithmic transformation is as follows: for each original component column c, first replace the missing values with 0 (component_c.fillna(0)), and then calculate log1p_c = ln(1 + component_c) according to the log1p transformation of the natural logarithm (i.e., np.log1p in numpy), and name and save the transformation result as log1p_<component name>; this transformation is used to alleviate the impact of the long-tailed distribution on the model and is generated column by column for all components in the script.
[0024] The construction process of the component interaction terms is as follows: let comp_cols be an ordered list of component columns, and the script enumerates non-repeating unordered component pairs (c_i, c_j) (i < j) in order of index, and selects the first N pairs to construct interaction terms; in the code, N is specified by the parameter n_interactions (N = 8 is used in the experiment), and construct interaction features for each selected pair (that is, directly multiply the original numerical values after filling with 0); the interaction terms are named int_<component A>_x_<component B> and added to the feature set. Note: The candidate pairs of the interaction terms are determined by the order listed in comp_cols (the script starts from i = 0, j starts from i + 1, and enumerates until N pairs are reached).
[0025] The construction process of the principal components is as follows: take the original component matrix M corresponding to comp_cols (fill the missing values with 0 and convert to floating point numbers), first apply StandardScaler to this matrix (that is, calculate the training set mean μ and standard deviation σ for each column, and standardize with z = (x - μ) / σ); then perform PCA on the standardized matrix, set the number of principal components to be taken as n_components = min(3, number_of_comp_cols), and calculate the principal component score matrix P; take the first, second, and third principal component scores as features pc_comp_1, pc_comp_2, pc_comp_3 respectively and add them to the feature set; the script also saves the scaler used for standardization and the fitted PCA model on the generated data structure (for outputting loadings and reproducing the linear combination expression), where each principal component score is calculated according to , where w_{j,c} is the loading coefficient of PCA.
[0026] S3. Hydrogen production method identification: Taking the engineered features as input, synthetic minority over-sampling is used to alleviate class imbalance, and a tree classifier is used to judge the hydrogen production method.
[0027] For a better understanding of the technical solution of the present invention, the following is a non-limiting elaboration: S1 includes: S101. Extract hydrogen samples; S102. Detect the original component content in the hydrogen sample; S103. Perform data cleaning on the original component content; data cleaning includes: After data deduplication, duplicate data is removed. Delete rows with a high number of missing rows; S104. Definition and mapping of target variables; For example, hydrogen production methods include electrolysis and natural gas. After mapping, electrolysis is defined as the positive class and natural gas is defined as the negative class. The sample distribution after mapping is: 0=24, 1=12, that is, 24 negative samples and 12 positive samples. After cleaning the original sample set, there are a total of 24 samples of natural gas hydrogen production and 12 samples of water electrolysis hydrogen production.
[0028] S2 includes: S201. Construct 50 engineered features based on the original component content; specifically: Based on the original component content, calculate the total component content, total inert gas content, hydrocarbon to carbon dioxide ratio, oxygen to water ratio, composition entropy, zero-value component count, and missing value count; calculate the proportion of each original component content in the total component content, the value after log1p transformation, and the selected inter-component product interaction term; after standardizing the original component matrix, extract the scores of the first three principal components to generate 50 engineered features.
[0029] Please refer to Table 2. The engineered characteristics include: components_sum, inert_sum, hc_co2_ratio, o2_over_h2o, composition_entropy, zero_count, missing_count, frac_water(H2O), frac_oxygen(O2), frac_total hydrocarbons, frac_helium(He), frac_nitrogen(N2), frac_argon(Ar), frac_carbon dioxide(CO2), frac_carbon monoxide(CO), frac_total sulfur (as H2S), frac_formaldehyde(HCHO), frac_formic acid(HCOOH), frac_total halides, frac_ammonium(NH3), frac_total non-hydrogen, frac_hydrogen purity, frac_maximum particulate matter concentration, log1p_water(H2O), log1p_oxygen(O2), log1p_total hydrocarbons, log1p_helium(He), lo g1p_Nitrogen (N2), log1p_Argon (Ar), log1p_Carbon Dioxide (CO2), log1p_Carbon Monoxide (CO), log1p_Total Sulfur (as H2S), log1p_Formaldehyde (HCHO), log1p_Formic Acid (HCOOH), log1p_Total Halides, log1p_Ammonia (NH3), log1p_Total Non-Hydrogen Gases, log1p_Hydrogen Purity, log1p_Maximum Particulate Matter Concentration, int_Water (H2O)_x_Oxygen (O2), int_water(H2O)_x_total hydrocarbons, int_water(H2O)_x_helium(He), int_water(H2O)_x_nitrogen(N2), int_water(H2O)_x_argon(Ar), int_water(H2O)_x_carbon dioxide(CO2), int_water(H2O)_x_carbon monoxide(CO), int_water(H2O)_x_total sulfur (as H2S), pc_comp_1, pc_comp_2, pc_comp_3.
[0030] Calculate overall and summary features: Calculate the sum of all numerical items considered as "components" (components_sum); calculate the sum of inert gases (inert gases include N2, He, Ar, etc.); calculate the ratio of hydrocarbons to CO2 (hc_co2_ratio) (set to 0 if the denominator is 0); calculate the ratio of oxygen to water (o2_over_h2o); calculate the missing / zero value indicators (zero_count, missing_count). Calculate the component proportion characteristics (frac_<component>): For each original component i, calculate its proportion frac_i = component_i / (components_sum + ε) (ε is a very small positive number to prevent division by zero); construct proportion characteristics for the following original components respectively: water (H2O), oxygen (O2), total hydrocarbons, helium (He), nitrogen (N2), argon (Ar), carbon dioxide (CO2), carbon monoxide (CO), total sulfur (calculated as H2S), formaldehyde (HCHO), formic acid (HCOOH), total halides, ammonia (NH3), total non-hydrogen, hydrogen purity, and maximum particulate matter concentration; Logarithmic transformation feature (log1p_<component>) is performed on each original component: construct log1p_x=ln(1+x) (natural logarithm), and construct corresponding log1p features for the 16 original components listed above to mitigate the influence of long-tailed distribution on the model; Constructing interactive items Using water (H2O) as the baseline, multiplicative interaction terms are constructed with several key components to capture synergistic effects. These include at least: int_water_x_oxygen, int_water_x_total hydrocarbons, int_water_x_helium, int_water_x_nitrogen, int_water_x_argon, int_water_x_CO2, int_water_x_CO, and int_water_x_total sulfur. The interaction terms are calculated by direct multiplication of the original values, and are first standardized before multiplication to control for scale differences. (Because one of the hydrogen production methods is water electrolysis, and water has a large information entropy, water is used as the baseline interaction term.) Calculate composition entropy: Calculate information entropy based on the proportion frac_i. This is to reflect the uniformity or complexity of the sample component distribution; Principal Component Analysis (PCA) is performed on the component matrix: Principal components are extracted from the standardized original component matrix (z(component_i)), and the scores of the first to third principal components, pc_comp_1, pc_comp_2, and pc_comp_3, are introduced as features; where each principal component score is... Calculate, where w_{j,i} is the corresponding load factor; The engineered feature set generated by the above steps includes: components_sum, inert_sum, hc_co2_ratio, o2_over_h2o, composition_entropy, zero_count, missing_count (7 items), 16 frac_ (16 items), 16 log1p_ (16 items), and 8 Interactive items (8 items), and 3 interactive items. (3 items), adding a total of 50 new engineering features.
[0031] S202. After merging the basic features, the total number of features in the engineering feature set is 66.
[0032] The basic features are the original detection items used to construct engineered features, and include the following items, which are uniformly preprocessed before constructing engineered features; The basic characteristics include: water (H2O), oxygen (O2), total hydrocarbons, helium (He), nitrogen (N2), argon (Ar), carbon dioxide (CO2), carbon monoxide (CO), total sulfur (as H2S), formaldehyde (HCHO), formic acid (HCOOH), total halides, ammonia (NH3), total non-hydrogen content, hydrogen purity, and maximum particulate matter concentration in the original sample report data.
[0033] First, the original component data of all samples are preprocessed and imputed uniformly, including but not limited to: removing samples with excessively high missing values, imputing missing values based on similar samples or column median / mean imputation, and performing necessary extreme value removal and standardization (z-score) on numerical components.
[0034] The minority class oversampling includes: selecting k nearest neighbors in the feature space of minority class samples, generating synthetic samples by linear interpolation between the minority class samples and their nearest neighbors, until the number of minority class samples is equal to the number of majority class samples, thereby achieving class balance in the training dataset, which enhances the tree classifier's sensitivity to minority class (electrolysis-based hydrogen production methods) and improves overall classification performance.
[0035] Data preprocessing: First, perform deduplication on the original samples, remove rows by missing row rate (threshold 0.5), map the target variable to binary labels and delete rows that cannot be mapped, and then perform median imputation on the numerical columns; Construct and standardize engineering features: Based on the cleaned data, construct the engineering feature set as described in claim 5 (including 50 newly added features such as components_sum, frac_, log1p_, int_, pc_comp_, etc.). Before entering oversampling, perform median interpolation and z-score standardization on the numerical features, and perform missing filling and One-Hot encoding on the categorical features. Oversampling and experimental work: Intra-fold oversampling is used within the training set: within each training fold of repeated stratified cross-validation, synthetic minority class oversampling is performed in a pipelined manner after preprocessing and before classifier training; the pipeline structure is: ColumnTransformer (numerical columns use SimpleImputer(strategy="median")+StandardScaler, class columns use SimpleImputer(strategy="most_frequent")+OneHotEncoder) → convert to dense array → SMOTE → RandomForestClassifier; the oversampling operation only applies to the training fold, and synthetic samples are not applied to the validation or test folds; Synthesis Algorithm and Parameter Determination: The synthetic minority oversampling adopts SMOTE (Synthetic Minority Over-Sampling Technique). In the standardized feature space, k=5 nearest neighbors are selected for each minority sample, and synthetic samples are generated by linear interpolation along the lines connecting the samples. SMOTE is initialized with random_state=42, and sampling_strategy is set to 'auto' (i.e., the minority class is upsampled to the majority class or to the algorithm's default configuration according to the library's default strategy). Validation and Repetition Strategy: Oversampling is performed within each training fold of RepeatedStratifiedKFold(n_splits=5,n_repeats=5,random_state=42), and model training uses RandomForestClassifier(n_estimators=200,random_state=42). Performance metrics (accuracy, precision, recall, F1) are evaluated at each corresponding validation fold. In the permutation importance phase, permutation_importance(n_repeats=10,scoring=F1) is used to quantify the impact of features on F1. in conclusion: Operating Environment Requirements and Implementation Results: Execute the above SMOTE process in an environment with imbalanced-learn installed. Based on the results of the given example (engineered feature set + SMOTE), the model, under cross-validation, achieved an average recall of ≈0.9800, an average F1 score of ≈0.8719, and an average precision of ≈0.8964. Furthermore, through permutation_importance, the following parameters can be observed: pc_comp_1 / pc_comp_3, frac_total sulfur, frac_total halides, and several others. The interaction items rank higher when oversampling is enabled, thus proving that the synthetic oversampling directly improves the recognition ability of minority classes in this embodiment.
[0036] The following is a detailed explanation using specific examples: S1, the original component content of the extracted hydrogen sample; First, a hydrogen sample was extracted; then the content of the original components in the hydrogen sample was detected, resulting in a data file: baseData.csv; initial sample size: 41 records × 17 columns; Then, data cleaning is performed. After deduplication, 39 records remain; Delete rows with a high percentage of missing rows (>50%): 36 rows remain; Target variable definition and mapping; S2. Construct engineered features based on the original component content, wherein the engineered features include component proportion, composition entropy, logarithmic transformation, component interaction terms, and principal components; Data preprocessing and feature engineering The following loads are all based on the principal components calculated after standardizing the component matrix (z(...) represents the standardized variables).
[0037] Loadings refer to the loading coefficients in Principal Component Analysis (PCA), which are the linear weighting coefficients between each principal component and the original variables (standardized component content), essentially standardized correlation coefficients (ranging from -1 to 1). They represent the degree of contribution of the original variables to the principal component (positive values indicate a positive contribution, negative values indicate a negative contribution). These loadings are calculated based on the standardization of the component matrix (z-score transformation) and are used to project the high-dimensional original components into the low-dimensional principal component space, thereby capturing the main variability information of the data. For example,
[0038] When the formaldehyde content (standardized z-value) in the sample increases, pc_comp_1 also increases by a coefficient of 0.367; the total amount of non-hydrogen gas is a loading in pc_comp_1 (-0.149), indicating that an increase in this variable will decrease pc_comp_1.
[0039] The following are some of the top contribution features and approximately linear expressions of each principal component (see Appendix for details).
[0040] Contributions before pc_comp_1 (the first principal component): Formaldehyde (HCHO): 0.366712; Total halides: 0.360437; Carbon monoxide (CO): 0.338248; Total hydrocarbons: 0.316178; Total sulfur (as H2S): 0.304242; Ammonia (NH3): 0.302006; Oxygen (O2): 0.257617; Maximum particulate matter concentration: 0.248881; Formic acid (HCOOH): 0.243927; Carbon dioxide (CO2): 0.239584; Hydrogen purity: 0.201957; Total non-hydrogen content: -0.149408;
[0041] Contributions before pc_comp_2 (the second principal component): Helium (He): 0.414617; Argon (Ar): -0.371011; Nitrogen (N2): -0.357082; Total non-hydrogen content: 0.352230; Hydrogen purity: -0.347930; Total sulfur (as H2S): 0.284124; Total hydrocarbons: 0.259759; Maximum particulate matter concentration: -0.244470; Carbon monoxide (CO): 0.224995; Water (H2O): -0.176581; Oxygen (O2): -0.104131; Formaldehyde (HCHO): 0.102279;
[0042] Contributions before pc_comp_3 (the 3rd principal component): Total non-hydrogen content: 0.411915; Argon (Ar): 0.408399; Nitrogen (N2): 0.407142; Ammonia (NH3): 0.331830; Hydrogen purity: -0.327901; Helium (He): 0.319332; Carbon dioxide (CO2): 0.263161; Total sulfur (as H2S): -0.162658; Maximum particulate matter concentration: 0.150656; Total halides: -0.121229; Formaldehyde (HCHO): -0.120111; Formic acid (HCOOH): 0.096513;
[0043] S3. Hydrogen production method identification: Using the aforementioned engineering features as input, a minority class oversampling is synthesized to alleviate class imbalance, and a tree classifier is used to determine the hydrogen production method.
[0044] Model Evaluation and Performance Summary Validation method: repeated stratified cross-validation (5-fold multiplication each time, repeated 5 times); classifier: random forest (200 trees); evaluation metrics: accuracy, precision, recall, and harmonic mean score (F1). The mean and standard deviation were calculated for each configuration. The four configurations are shown in the table below:
[0045] As shown in Table 1, engineered features improved or maintained classification performance in most configurations. Engineered features plus oversampling achieved a high recall rate (0.98) and a high overall F1 score (0.8719) in this run.
[0046] Using synthetic oversampling can significantly improve recall, but there is a possibility of overfitting.
[0047] Compared to using only the original features, engineered features also improve the F1 score (from 0.8070 to 0.8390) without oversampling.
[0048] Please see Figure 2 and Figure 3 , Baseline characteristics refer to the original characteristics before engineering: water (H2O), oxygen (O2), total hydrocarbons, helium (He), nitrogen (N2), argon (Ar), carbon dioxide (CO2), carbon monoxide (CO), total sulfur (as H2S), formaldehyde (HCHO), formic acid (HCOOH), total halides, ammonia (NH3), total non-hydrogen content, hydrogen purity, and maximum particulate matter concentration.
[0049] The top features (ranked by Gini importance, top 16) are as follows: Nitrogen (N2) > Oxygen (O2) > Formaldehyde (HCHO) > Helium (He) > Total non-hydrogen > Argon (Ar) > Total halides > Hydrogen purity > Water (H2O) > CO2 > HCOOH > Maximum particulate matter concentration > Total hydrocarbons > CO > Total sulfur > NH3. The surrogate tree consistency is approximately 0.972. The substitution importance also supports the high ranking of N2, HCHO, and total halides.
[0050] When the model uses only the raw numerical values for the detection items and does not perform SMOTE, nitrogen (N2) is identified as the most important single feature, indicating that the N2 content in the sample is of great information in distinguishing between "electrolysis hydrogen production vs. natural gas hydrogen production" (which may reflect the difference in dilution / inert gas content).
[0051] Oxygen (O2) and formaldehyde (HCHO) followed closely behind, indicating that oxygen-containing compounds and certain organic impurities are clearly related to the hydrogen production method.
[0052] Nitrogen (N2): An inert gas, often used as a dilution or residual gas. Natural gas-to-hydrogen samples may contain relatively high levels of N2 (or variations due to dilution caused by different gas sources).
[0053] Oxygen (O2): May indicate differences in sampling / treatment or detection differences related to leakage / oxidation; O2 residues or impurity patterns differ in electrolytic hydrogen production and natural gas-based hydrogen production processes.
[0054] Formaldehyde (HCHO): An indicator of organic impurities, which may be related to raw materials or processes (combustion, catalysis). If there is more organic pollution in the natural gas to hydrogen production process, it can become a distinguishing signal.
[0055] Helium (He) / Argon (Ar) / Total non-hydrogen components: These reflect the inert gases or the total non-H2 components and are sensitive to the degree of dilution and gas source characteristics.
[0056] Total halides, total hydrocarbons, CO, CO2, total sulfur, NH3, formic acid, etc.: These are all typical "pollutant / component characteristics," many of which are related to raw materials or processes and can carry distinguishing signals.
[0057] Please see Figure 4 and Figure 5 , The top features are: formaldehyde (HCHO) > oxygen (O2) > total halides > total non-hydrogen > nitrogen (N2) ... > total sulfur (as H2S). After SMOTE, the class balance (1:1) is achieved, and the surrogate tree consistency is approximately 0.979. The substitution importance also prioritizes HCHO.
[0058] Oversampling (SMOTE) alters the class distribution of the training set, making the model more sensitive to the discrimination signals of the originally "minority class". In the results, formaldehyde (HCHO) jumped to the primary feature after using SMOTE, indicating that the features that are more discriminative to the minority class (electrolysis class) have been amplified in weight.
[0059] Formaldehyde (HCHO) (rising to the top): This indicates that HCHO has strong discriminative power in a minority of samples, or is amplified in synthetic samples.
[0060] Oxygen (O2), total halides, and total non-hydrogen: similar to the baseline without SMOTE, but with a change in relative order, reflecting the altered sensitivity of the model to different features after oversampling.
[0061] Nitrogen (N2) dropping to 5th place: This does not mean that N2 is unimportant, but rather that SMOTE causes the model to rely more on features that are more significantly different in the minority classes (such as HCHO). Please see Figure 6 and Figure 7 , The top features are pc_comp_3, frac_carbon monoxide (CO), pc_comp_1, pc_comp_2, frac_total hydrocarbons, frac_total halides, log1p_nitrogen (N2)...helium (He). The surrogate tree consistency is 1.0000. pc_comp_2 / pc_comp_1 is also very important in the substitution importance.
[0062] In the engineered feature set, the principal components (pc_comp_1 / 2 / 3) and the proportions of several other components are shown. The fact that it becomes the most important feature indicates that the linear combination (composite signal) generated by PCA captures more stable and stronger discriminative information from the original features.
[0063] pc_comp_3 / pc_comp_1 / pc_comp_2 (Principal Components): These are comprehensive indices resulting from the linear combination of multiple original components. When the principal components appear first, it indicates that the model relies on the composite signal of multiple original components, rather than a single component. For example, pc_comp_1 in the appendix is contributed by HCHO, total halides, CO, and total hydrocarbons, which is consistent with the appearance of these terms in the univariate importance. See the appendix for details; the appendix helps map the "black box" importance back to specific chemical quantities.
[0064] frac_carbon monoxide (CO), frac_total hydrocarbons, frac_total halides: the percentage of components is often better at capturing relative compositional differences than the absolute content (especially effective when the sample dilution is inconsistent).
[0065] log1p_nitrogen(N2) / inert_sum / composition_entropy: These engineering characteristics indicate that composite indicators such as the proportion of inert gases and compositional entropy (uniformity of component distribution) also participate in the discrimination.
[0066] Please see Figure 8 and Figure 9 , The top features are predominantly frac_carbon monoxide (CO), frac_formaldehyde (HCHO), pc_comp_1, pc_comp_3, frac_total sulfur, frac_total halides…pc_comp_2, with a surrogate tree consistency of 1.0000. The substitution importance also shows that frac_total sulfur and pc_comp_1 are important.
[0067] After combining engineering features and SMOTE, the model relies most heavily on the fractions of several components and principal components, among which CO, HCHO, and total sulfur still have a prominent proportion.
[0068] frac_carbon monoxide (CO) (first): indicates that the relative proportion of CO in the sample composition is very sensitive to distinguishing between the two classes.
[0069] frac_formaldehyde (HCHO): remains a key indicator of organic impurities.
[0070] pc_comp_1 / pc_comp_3: This indicates that the composite principal components still provide robust information.
[0071] frac_total sulfur / frac_total halides / interactions (int_water_x_total hydrocarbons, etc.): Engineered interactions and percentages are given higher weights after oversampling, possibly because synthetic samples are better able to distinguish between the two classes in these dimensions.
[0072] Gini importance describes the decrease in impurity caused by intra-tree partitioning (affected by feature distribution and collinearity); permutation importance better reflects the contribution of features to the model's generalization performance (F1).
[0073] Importance of substitution Permutation importance measures the average decrease in F1 score after permuting a feature (the higher the value, the more important the feature is to the model). The following is an excerpt of the permutation importance for several key configurations (only the top-ranked features are listed).
[0074] Baseline set (without oversampling): Nitrogen (N2): mean_imp=0.12217 std=0.15452 Formaldehyde (HCHO): mean_imp=0.05295 std=0.11933 Total halides: mean_imp=0.05029 std=0.10138 Argon (Ar): mean_imp=0.02558std=0.09292 Total non-hydrogen gas: mean_imp=0.01749 std=0.08567 Baseline set (using oversampling) Formaldehyde (HCHO): mean_imp=0.10775 std=0.12208 Nitrogen (N2): mean_imp=0.05524 std=0.09033 Total halides: mean_imp=0.04488std=0.08579 Argon (Ar): mean_imp=0.03194std=0.07651 Total non-hydrogen gas: mean_imp=0.02720 std=0.08410 Engineered collection (without oversampling) pc_comp_2:mean_imp=0.05819std=0.12803 pc_comp_1:mean_imp=0.03047std=0.09699 frac_carbon monoxide (CO): mean_imp=0.02653std=0.06304 log1p_nitrogen(N2): mean_imp=0.02416 std=0.10478 Nitrogen (N2): mean_imp=0.02400 std=0.10478 pc_comp_3:mean_imp=0.02286std=0.08194 frac_total halides: mean_imp=0.02199std=0.05855 Engineered collection (using oversampling) frac_total sulfur (as H2S): mean_imp=0.04307std=0.15049 pc_comp_1:mean_imp=0.03707std=0.13823 Total halides (FRAC): mean_imp=0.03677 std=0.13327 pc_comp_3:mean_imp=0.03621std=0.13618 int_water_x_total hydrocarbons: mean_imp=0.03467std=0.13482 int_water_x_nitrogen(N2): mean_imp=0.03467std=0.13482 log1p_formaldehyde(HCHO): mean_imp=0.03227 std=0.13237 Formaldehyde (HCHO): mean_imp=0.03120 std=0.13273 Total halides: mean_imp=0.03120 std=0.13273 Conclusion: Principal components (especially pc_comp_2, pc_comp_1, and pc_comp_3) consistently ranked highly in the engineered set, indicating that the composite linear combination significantly contributes to the discrimination. Certain single original detection items (such as formaldehyde, total halides, nitrogen, and total sulfur) also showed high importance, suggesting that the original items themselves contain discriminative information.
[0075] Under the current sample and detection conditions, component-based engineered features can improve the performance of hydrogen production method identification; the proportion of principal components and partial components are discriminant factors that the model relies on; synthetic oversampling can significantly improve recall.
[0076]
[0077]
[0078] components_sum: The sum of all numerical items that are considered "components" (used for normalization and percentage calculation).
[0079] inert_sum: The sum of the contents of inert gases (such as N2, He, Ar, etc.) (reflecting the amount of dilution / inert components).
[0080] hc_co2_ratio: The ratio of hydrocarbons (total hydrocarbons) to CO2 (set to 0 if the corresponding column is missing).
[0081] o2_over_h2o: Total oxygen / total water (used to distinguish oxygen content from water content).
[0082] composition_entropy: Composition entropy based on component proportions (reflecting the uniformity / complexity of component distribution).
[0083] zero_count: The number of items in the original composition that are equal to 0 (indicating the number of extremely low / undetectable components).
[0084] missing_count: The number of missing values in the original component (data integrity indicator).
[0085] frac_<component>: The percentage of a certain original component in the total components (captures relative content relationships).
[0086] log1p_<component>: The value of the original component after log1p transformation (mitigating the long tail effect).
[0087] int_<component A>_x_<component B>: The product interaction term of components A and B (capturing the collaborative / interactive information between the two).
[0088] pc_comp_1 / 2 / 3: The scores of the first three principal components (compound linear combination features) extracted after standardizing the original component matrix.
[0089]
[0090]
[0091] Please see Figure 10 and Figure 11 This allows for a direct visual observation of the differences in the "comprehensive compositional characteristics" of hydrogen samples. Electrolysis-based hydrogen production and natural gas-based hydrogen production exhibit a clear distinction in the principal component space, validating the feasibility of classification based on composition.
[0092] A second embodiment provides a hydrogen production method identification system based on a tree classifier, used to execute the method of the first embodiment, including: The data extraction module extracts the original component content of the hydrogen sample; The feature generation module constructs engineered features based on the original component content. The engineered features include component proportion, composition entropy, logarithmic transformation, component interaction terms, and principal components. The identification module identifies the hydrogen production method by using the aforementioned engineering features as input, synthesizing minority class oversampling to alleviate class imbalance, and then using a tree classifier to determine the hydrogen production method.
[0093] A third embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned hydrogen production method identification method based on a tree classifier.
[0094] Fourth embodiment: A computer program product, including a computer program that, when executed by a processor, implements the above-described hydrogen production method identification method based on a tree classifier.
[0095] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented, in whole or in part, as a computer program product, the computer program product includes one or more computer instructions. When the computer program instructions are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0096] The above description is only a preferred embodiment of the present invention. It should be noted that, for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for identifying hydrogen production methods based on a tree classifier, characterized in that, include: S1, the original component content of the extracted hydrogen sample; S2. Construct engineered features based on the original component content, wherein the engineered features include component proportion, composition entropy, logarithmic transformation, component interaction terms, and principal components; S3. Hydrogen production method identification: Using the aforementioned engineering features as input, a minority class oversampling is synthesized to alleviate class imbalance, and a tree classifier is used to determine the hydrogen production method.
2. The hydrogen production method identification method based on a tree classifier according to claim 1, characterized in that, The original component contents include: H2O, O2, total hydrocarbons, He, N2, Ar, CO2, CO, total sulfur, HCHO, HCOOH, total halides, NH3, total non-hydrogen content, hydrogen purity, and maximum particulate matter concentration.
3. The hydrogen production method identification method based on a tree classifier according to claim 1, characterized in that, S1 includes: S101. Extract hydrogen sample; S102. Detect the original component content in the hydrogen sample; S103. Perform data cleaning on the original component content; S104, Definition and mapping of target variables.
4. The hydrogen production method identification method based on a tree classifier according to claim 1, characterized in that, S2 include: S201. Construct 50 engineered features based on the original component content; S202. After merging the basic features, the total number of features in the engineering feature set is 66.
5. The hydrogen production method identification method based on a tree classifier according to claim 4, characterized in that, S201 includes: calculating the total component content, total inert gas content, hydrocarbon to carbon dioxide ratio, oxygen to water content ratio, composition entropy, zero-value component count, and missing value count based on the original component content; calculating the proportion of each original component content in the total component content, the value after log1p transformation, and the selected inter-component product interaction term for each component content; and extracting the scores of the first three principal components after standardizing the original component matrix to generate 50 engineered features.
6. The hydrogen production method identification method based on a tree classifier according to claim 4, characterized in that, The basic characteristics include raw composition data for the following components: water, oxygen, total hydrocarbons, helium, nitrogen, argon, carbon dioxide, carbon monoxide, total sulfur, formaldehyde, formic acid, total halides, ammonia, total non-hydrogen content, hydrogen purity, and maximum particulate matter concentration.
7. The hydrogen production method identification method based on a tree classifier according to claim 1, characterized in that, The minority class oversampling includes: selecting k nearest neighbors in the feature space of minority class samples, generating synthetic samples by linear interpolation between the minority class samples and their nearest neighbors, until the number of minority class samples is equal to the number of majority class samples, thereby achieving class balance in the training dataset, enhancing the tree classifier's sensitivity to minority class recognition and improving overall classification performance.
8. A hydrogen production method identification system based on a tree classifier, characterized in that, include: The data extraction module extracts the original component content of the hydrogen sample; The feature generation module constructs engineered features based on the original component content. The engineered features include component proportion, composition entropy, logarithmic transformation, component interaction terms, and principal components. The identification module identifies the hydrogen production method by using the aforementioned engineering features as input, synthesizing minority class oversampling to alleviate class imbalance, and then using a tree classifier to determine the hydrogen production method.
9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it is the hydrogen production method identification method based on a tree classifier as described in any one of claims 1-7.
10. A computer-readable storage medium comprising instructions, when executed on a computer, causing the computer to perform the hydrogen production method identification method based on a tree classifier as described in any one of claims 1-7.