Sample generation method, apparatus, device, medium, and product
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-15
- Publication Date
- 2026-08-11
AI Technical Summary
[0004]本申请的目的是提供一种样本生成方法、装置、设备、介质及产品,可以解决现有技术在生成样本时存仅通过统计分布匹配生成数据,生成结果可能违背因果逻辑关系并且与真实土壤环境存在显著差的技术问题
本申请提供了一种样本生成方法、装置、设备、介质及产品,方法通过获取目标土壤实测样本数据并输入样本生成模型生成伪样本,样本生成模型依托生成器与判别器形成对抗训练机制,生成器第一损失函数同时引入因果结构约束与均方误差约束,判别器第二损失函数引入均方误差约束;因果结构约束能够表征土壤指标间固有的因果逻辑规律,约束生成过程遵循土壤内在作用机理,有效避免生成样本违背因果关联关系的问题,均方误差约束可表征相关土壤指标的数值差值统计特征,从局部微观维度拟合真实土壤指标间的数值关联特征,缩小伪样本与真实土壤环境的特征偏差;由此既摆脱了现有技术仅依靠单一统计分布匹配生成数据的局限,又兼顾了指标因果逻辑合理性与局部数值特征拟合精度,大幅提升生成伪样本的真实性、合理性与贴合度,更好地适配真实土壤环境的数据分布规律,进而解决了现有技术在生成样本时存仅通过统计分布匹配生成数据,生成结果可能违背因果逻辑关系并且与真实土壤环境存在显著差的技术问题。
Smart Images

Figure CN122548281A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and in particular to a sample generation method, apparatus, device, medium, and product. Background Technology
[0002] Currently, in the field of soil physicochemical index prediction, the prediction of most pH values, organic carbon (OC), nitrogen (N), potassium (K), and electrical conductivity (EC) content mainly relies on three types of methods: The first type is chemical methods based on traditional laboratory analysis. While these methods offer high accuracy, they have long testing cycles, high costs, and are difficult to implement in large-scale farmland or ecosystems. The second type uses methods such as inverse distance weighted interpolation, Kriging interpolation, and triangular mesh interpolation to predict nutrient distribution. Although these methods lay the foundation for spatial analysis of soil nutrients, they are highly dependent on the sample size; when the sample size is small, the error will be significantly amplified, and due to limitations in algorithm principles, they are difficult to capture the nonlinear relationships between soil nutrients. The third type uses deep learning techniques such as generative adversarial networks (GANs) to generate samples, solving the small sample dilemma. Currently, deep learning techniques such as GANs have become the mainstream approach.
[0003] However, traditional generative adversarial networks generate sample data solely through statistical distribution matching, which presents technical problems such as the generated results potentially violating causal logic and showing significant differences from the real soil environment. Summary of the Invention
[0004] The purpose of this application is to provide a sample generation method, apparatus, device, medium, and product that can solve the technical problem that existing technologies generate data by simply matching statistical distributions when generating samples, and the generated results may violate causal logic and have significant differences from the real soil environment.
[0005] To achieve the above objectives, this application provides the following solution: Firstly, this application provides a sample generation method, including: Obtain measured sample data of the target soil; The measured sample data is input into the pre-built sample generation model to generate multiple pseudo samples. The sample generation model includes a generator and a discriminator. The first loss function of the generator includes causal structure constraints and mean squared error constraints. The second loss function of the discriminator includes mean squared error constraints. Causal structure constraints are used to characterize the causal logic between soil indicators, and mean squared error constraints are used to characterize the statistical characteristics of the numerical differences between related soil indicators.
[0006] Optionally, the pre-construction of the sample generation model specifically includes: obtaining a training dataset, wherein the training dataset includes a first soil dataset corresponding to multiple geographical regions and a second soil dataset corresponding to a geographical region; determining the causal structure constraints between soil indicators based on the first soil dataset; determining the mean squared error constraints between soil indicators based on the second soil dataset; constructing a total loss function based on the causal structure constraints, the mean squared error constraints, and the native loss of the pre-set model, wherein the total loss function includes a first loss function and a second loss function; and training the sample generation model based on the second soil dataset and the total loss function.
[0007] Optionally, the training dataset includes a training set and a test set. Obtaining the training dataset specifically includes: obtaining an initial soil dataset; processing the initial soil dataset according to a preset data processing strategy to obtain a preprocessed dataset; extracting features from the preprocessed dataset to determine soil feature vectors; and dividing the soil feature vectors into a training set and a test set according to a preset partitioning rule.
[0008] Optionally, based on the first soil dataset, the causal structure constraints among soil indicators are determined, specifically including: processing the first soil dataset using a preset causal discovery algorithm to determine a list of conditionally independent constraints, wherein the list of conditionally independent constraints includes multiple conditional constraints, each conditional constraint including a first indicator variable, a second indicator variable, a condition set, and constraint weights; using a preset regression algorithm to determine the first residual and the second residual corresponding to the first indicator variable and the second indicator variable, respectively; determining the violation score of a single conditional constraint based on the first residual, the second residual, and the preset independence algorithm; and weighting the violation scores according to the constraint weights to obtain the causal structure constraints.
[0009] Optionally, based on the second soil dataset, the mean squared error constraint between soil indicators is determined, specifically including: constructing candidate ordered pairs based on the second soil dataset, wherein a candidate ordered pair is a pair of soil indicators with high correlation features pointing to low correlation features, where high correlation features refer to features among candidate indicator features whose correlation with preset target indicator features is greater than a preset threshold, and low correlation features refer to features among candidate indicator features whose correlation with preset target indicator features is less than or equal to a preset threshold, and the candidate indicator features are included in the second soil dataset; determining the true difference baseline based on the candidate ordered pairs, wherein the true difference baseline is used to characterize the feature difference of the candidate ordered pairs; and determining the mean squared error constraint based on the true difference baseline.
[0010] Optionally, a total loss function is constructed based on the causal structure constraint, the mean squared error constraint, and the native loss of the preset model. The total loss function includes a first loss function and a second loss function, specifically including: splitting the native loss into the generator basic loss and the discriminator basic loss; weighting and merging the generator basic loss, the causal structure constraint, and the mean squared error constraint to obtain the first loss function; and weighting and merging the discriminator basic loss and the mean squared error constraint to obtain the second loss function.
[0011] Secondly, this application provides a sample generation apparatus, comprising: The acquisition module is used to acquire measured sample data of the target soil. The generation module is used to input measured sample data into a pre-built sample generation model to generate multiple pseudo samples. The sample generation model includes a generator and a discriminator. The first loss function corresponding to the generator includes causal structure constraints and mean squared error constraints. The second loss function corresponding to the discriminator includes mean squared error constraints. Causal structure constraints are used to characterize the causal logic between soil indicators, and mean squared error constraints are used to characterize the statistical characteristics of the numerical differences between related soil indicators.
[0012] Thirdly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the sample generation method described in any one of the above.
[0013] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the sample generation method described in any one of the above.
[0014] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the sample generation method described in any one of the above descriptions.
[0015] According to the specific embodiments provided in this application, the following technical effects are disclosed: This application provides a sample generation method, apparatus, device, medium, and product. The method generates pseudo-samples by acquiring measured sample data of the target soil and inputting it into a sample generation model. The sample generation model relies on an adversarial training mechanism between the generator and the discriminator. The generator's first loss function simultaneously incorporates causal structure constraints and mean squared error constraints, while the discriminator's second loss function incorporates mean squared error constraints. Causal structure constraints can characterize the inherent causal logic between soil indicators, constraining the generation process to follow the soil's inherent mechanisms of action, effectively avoiding the problem of generated samples violating causal relationships. Mean squared error constraints can characterize the statistical characteristics of numerical differences between relevant soil indicators, fitting the numerical correlation characteristics between real soil indicators from a local microscopic dimension, and reducing the feature deviation between pseudo-samples and the real soil environment. This not only overcomes the limitations of existing technologies that rely solely on matching data using a single statistical distribution, but also takes into account the rationality of the causal logic of the indicators and the fitting accuracy of local numerical features, significantly improving the authenticity, rationality, and fit of the generated pseudo-samples, better adapting to the data distribution patterns of the real soil environment. Thus, it solves the technical problem of existing technologies that generate samples by only matching data using statistical distributions, resulting in generated results that may violate causal logic and have significant differences from the real soil environment. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a diagram illustrating the application environment of a sample generation method according to an embodiment of this application. Figure 2 A schematic flowchart illustrating a sample generation method provided in an embodiment of this application; Figure 3 This application provides an example diagram of a data processing flow in a sample generation method according to an embodiment of the present application. Figure 4 This is an example flowchart of a causal structure extraction process in a sample generation method provided in an embodiment of this application; Figure 5 This application provides an example diagram of the loss construction process in a sample generation method according to an embodiment of the present application; Figure 6 This application provides an example diagram of a model building process in a sample generation method according to an embodiment of the present application. Figure 7 This application provides an example diagram of a data processing flow in a sample generation method according to an embodiment of the present application. Figure 8 This is a schematic diagram of the structure of a sample generation device provided in one embodiment of this application; Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0020] The sample generation method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a grid. A data storage system can store the data that server 104 needs to process. The data storage system can be set up independently, integrated into server 104, or placed in the cloud or on another server. Terminal 102 can send measured sample data of the target soil to server 104. After receiving the measured sample data, server 104 inputs the measured sample data into a pre-built sample generation model to generate multiple pseudo-samples. The sample generation model includes a generator and a discriminator. The generator's first loss function includes causal structure constraints and mean squared error constraints, while the discriminator's second loss function includes mean squared error constraints. Causal structure constraints characterize the causal logical relationships between soil indicators, and mean squared error constraints characterize the statistical characteristics of the numerical differences between related soil indicators. Server 104 can feed back multiple pseudo-samples to terminal 102. In addition, in some embodiments, the sample generation method can also be implemented by the server 104 or the terminal 102 separately. For example, the terminal 102 can directly process the measured sample data of the target soil, or the server 104 can obtain the measured sample data of the target soil from the data storage system and process it.
[0021] The terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, and IoT devices. The server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers, or it can be a cloud server.
[0022] In one exemplary embodiment, such as Figure 2As shown, a sample generation method is provided. This method is executed by a computer device, specifically by a terminal or server alone, or by both a terminal and a server. In this embodiment, the method is applied to... Figure 1 Taking server 104 as an example, the explanation includes the following steps 201 to 205. Wherein: Step S201: Obtain measured sample data of the target soil.
[0023] In this embodiment, step S201 is used to specifically acquire measured sample data corresponding to the target soil within the research area to be tested. Actual soil field sampling is limited by terrain, sampling costs, manpower and material resources, and sampling scenarios, resulting in a limited number of valid measured soil samples that can be obtained. Therefore, this invention can acquire measured sample data through standardized sampling and indoor testing methods.
[0024] The obtained measured sample data covers the actual detection values of multiple core physicochemical indicators under the target soil system, specifically including key soil property parameters such as soil pH, organic carbon, total nitrogen, available potassium, and electrical conductivity. It fully preserves the actual numerical range, spatial distribution characteristics, and potential correlations between various physicochemical indicators of the target soil.
[0025] Understandably, measured sample data, as the original baseline data for model input, can objectively and truthfully reflect the actual physicochemical state and inherent property laws of the target soil in the study area. This provides a real, effective, and reliable data foundation for the subsequent input calculation, feature learning, and high-precision generation of pseudo-samples in the pre-constructed sample generation model, ensuring from the source that the subsequently generated pseudo-sample data conforms to the real environmental characteristics and distribution laws of the target soil.
[0026] Step S202: Input the measured sample data into the pre-built sample generation model to generate multiple pseudo samples. The sample generation model includes a generator and a discriminator. The first loss function corresponding to the generator includes causal structure constraint and mean square error constraint. The second loss function corresponding to the discriminator includes mean square error constraint. Causal structure constraint is used to characterize the causal logic between soil indicators. Mean square error constraint is used to characterize the statistical characteristics of the numerical difference of related soil indicators.
[0027] In this embodiment, the aforementioned measured sample data of the target soil is input into the sample generation model that has completed iterative training and parameter convergence in advance. The model continuously iterates and optimizes the operation by relying on the adversarial training mechanism between the built-in generator and discriminator, and generates a large number of pseudo sample data that are sufficient in quantity, complete in features, and adapted to the target soil scene.
[0028] The sample generation model consists of two main network modules: a generator and a discriminator. These two modules work collaboratively and are configured with differentiated loss constraint systems to achieve bidirectional and precise optimization of the pseudo-sample generation process. Specifically, the first loss function corresponding to the generator integrates both causal structure constraints and mean squared error constraints, while the second loss function corresponding to the discriminator is configured with a single mean squared error constraint mechanism. This differentiated constraint configuration achieves a balance between global logical regularity and local detail fitting.
[0029] The causal structure constraint is constructed based on the intrinsic mechanism of action of physicochemical indicators obtained from the mining of massive soil samples. It can accurately quantify and characterize the stable causal logic law that objectively exists among various soil physicochemical indicators. It can realize global logical constraints in the entire process of pseudo-sample generation, effectively avoiding the defects of traditional generation models that rely solely on data statistical distribution to generate samples, which are prone to producing invalid pseudo-samples that violate the soil physicochemical action mechanism and do not conform to natural laws.
[0030] The mean square error constraint is constructed based on the ordered pairs of highly correlated soil indicators obtained from real measured samples. It can accurately characterize the inherent statistical characteristics and local variation patterns of numerical differences between highly correlated soil indicators. It can accurately constrain and correct the feature details of pseudo samples from the micro numerical dimension, effectively making up for the problems of traditional generative models ignoring local numerical differences of indicators and large deviations between generated samples and real soil numerical characteristics.
[0031] During the process of generating pseudo-samples in adversarial training, the generator continuously optimizes the sample generation logic and numerical details based on dual constraints, while the discriminator continuously identifies the differences in local features between pseudo-samples and real samples based on mean squared error constraints. This bidirectional feedback forces the model parameters to iteratively update. Through the synergistic cooperation and differentiated empowerment of these two constraint mechanisms, the technical limitations of traditional generative models in fitting a single statistical distribution are broken. This ensures that the final generated pseudo-samples not only possess the causal logic of soil indicators and conform to the inherent laws of real soil, but also highly match real soil measurement data in terms of local numerical features and indicator difference relationships. This significantly improves the fidelity, reliability, and practicality of pseudo-sample data, achieving high-precision data augmentation in small-sample soil scenarios.
[0032] Based on the description of the above embodiments, the method provided by the present invention obtains the measured sample data of the target soil and inputs it into the sample generation model to generate pseudo samples. The sample generation model relies on the generator and discriminator to form an adversarial training mechanism. The generator's first loss function simultaneously introduces causal structure constraints and mean square error constraints, while the discriminator's second loss function introduces mean square error constraints. Causal structure constraints can characterize the inherent causal logic between soil indicators, constraining the generation process to follow the soil's inherent mechanism of action, effectively avoiding the problem of generated samples violating causal relationships. Mean square error constraints can characterize the statistical characteristics of numerical differences of relevant soil indicators, fitting the numerical correlation characteristics between real soil indicators from a local microscopic dimension, and reducing the feature deviation between pseudo samples and the real soil environment. Thus, it not only gets rid of the limitation of existing technologies that rely solely on a single statistical distribution to match generated data, but also takes into account the rationality of the causal logic of indicators and the fitting accuracy of local numerical features, greatly improving the authenticity, rationality, and fit of generated pseudo samples, better adapting to the data distribution patterns of the real soil environment, and thus solving the technical problem that existing technologies generate samples by only matching data through statistical distribution, and the generated results may violate causal logic and have significant differences from the real soil environment.
[0033] Optionally, the pre-construction of the sample generation model specifically includes the following steps: Step S2021: Obtain the training dataset, which includes a first soil dataset corresponding to multiple geographical regions and a second soil dataset corresponding to a geographical region.
[0034] In this embodiment, step S2021 collects and organizes a training dataset for model training. This training dataset is constructed by integrating multi-source measured soil data, specifically including a first soil dataset corresponding to multiple geographical regions and a second soil dataset corresponding to a single target geographical region. The first soil dataset corresponding to multiple geographical regions is a wide-area, large-scale soil sample data set with sufficient data volume and broad coverage, encompassing various physicochemical indicators and correlation patterns of soils from different regions, possessing global statistical characteristics and causal pattern mining value. The second soil dataset corresponding to a single geographical region is a small sample of measured soil data from a selected typical area, accurately matching the soil environmental characteristics of the target area to be modeled, truly reflecting the numerical distribution and local correlation characteristics of soil indicators in the target area, and is the core data for adapting to localized pseudo-sample generation and ensuring the localized fitting effect of the model. The two types of datasets are complementary in function and each performs its own function, providing differentiated data support for subsequent causal constraint construction, local numerical constraint fitting, and targeted model training.
[0035] For example, the LUCAS2015 topsoil dataset, consisting of 21,859 topsoil samples of arable land from the 28 EU member states, was used as the first soil dataset, and the topsoil dataset from Greece was selected as the second soil dataset.
[0036] Step S2022: Based on the first soil dataset, determine the causal structural constraints between soil indicators.
[0037] In this embodiment of the application, step S2022 relies on the first soil dataset, which has a large data volume and wide geographical coverage, to mine the intrinsic correlation between various soil physicochemical indicators and quantitatively determine the corresponding causal structure constraints between soil indicators.
[0038] By performing causal relationship mining and statistical analysis on the first soil dataset, the conditional independence relationships and interaction logic among different soil indicators can be accurately identified. Causal structure information consistent with the natural evolution of soil can be extracted, and based on this information, causal structure constraints that can participate in model iteration and optimization can be constructed. These constraints can quantify the inherent global causal logic among soil indicators, providing global mechanistic constraints for subsequent model-generated pseudo-samples and preventing logical defects in generated samples that violate the laws of soil physicochemical interactions.
[0039] Step S2023: Determine the mean square error constraints between soil indices based on the second soil dataset.
[0040] Based on a second soil dataset that closely matches the real soil environment of the target area, the local numerical correlation characteristics among soil indicators in the target area are analyzed, and the mean square error constraints between soil indicators are determined.
[0041] By performing feature correlation screening, constructing ordered pairs of indicators, and solving for the baseline of the difference in true values on the second soil dataset, unique local numerical statistical features of soil indicators in the target area can be extracted, and mean squared error constraints can be constructed based on these features. The mean squared error constraints focus on the micro-numerical differences and local correlation characteristics of soil indicators, accurately depicting the numerical variation patterns of the real soil in the target area. This helps correct local detail biases in the model-generated samples and compensates for the inability of global statistical fitting to adapt to subtle local features.
[0042] Step S2024: Construct a total loss function based on causal structure constraints, mean squared error constraints, and the native loss of the preset model. The total loss function includes a first loss function and a second loss function. Train a sample generation model based on the second soil dataset and the total loss function.
[0043] In this embodiment of the application, step S2024 integrates the causal structure constraints obtained by mining, the mean squared error constraints obtained by fitting, and the native loss mechanism of the preset base model to construct the complete total loss function required for model training. The constructed total loss function includes the first loss function of the corresponding generator and the second loss function of the corresponding discriminator.
[0044] For example, the default base model is CTAB-GAN+ (Enhanced Conditional Table Generative Adversarial Network Plus). CTAB-GAN+ is a generative adversarial network (GAN) specifically designed for synthesizing tabular data, and is an enhanced version of CTAB-GAN. Through pattern-specific normalization (VGM), improved preprocessing for mixed data types and long-tailed distributions, and an adversarial training framework combining Wasserstein distance, gradient penalty, and an auxiliary classifier, it can generate high-fidelity synthetic tabular data that supports conditional sampling, and is widely used in data augmentation, privacy protection, and downstream machine learning tasks.
[0045] In the loss function fusion process, the two types of constraints are differentiated and applied. Causal structure constraints and mean squared error constraints are both incorporated into the generator's first loss function, enabling the generator to simultaneously possess global causal mechanism constraints and local numerical detail constraints. The mean squared error constraint is incorporated into the discriminator's second loss function, allowing the discriminator to focus on identifying differences in local numerical features of samples. Based on this, a second soil dataset closely resembling the real-world scenario of the target region is used as training data. Relying on the constructed differentiated total loss function, the pre-defined base model undergoes multiple rounds of iterative adversarial training. Through backpropagation of the loss function, the model's internal network parameters are continuously updated, constantly optimizing the model's causal fitting ability and local numerical fitting accuracy until the model parameters converge and the generated samples meet the requirements of causal rationality and numerical fidelity. Finally, a sample generation model capable of generating high-precision soil pseudo-samples for the target region is obtained.
[0046] Optionally, the training dataset includes a training set and a test set. Step S2021, obtaining the training dataset, specifically includes the following steps: Step S2021a: Obtain the initial soil dataset.
[0047] In this embodiment of the application, the initial soil dataset obtained in step S2021a is the original publicly available standardized soil sample dataset, which includes a large amount of soil measurement data from multiple different geographical regions. It comprehensively covers the original observation information of various soil physicochemical indicators under different regional environments, including multiple attribute data such as soil pH, organic carbon, total nitrogen, available nutrients, and electrical conductivity. It completely preserves the original distribution characteristics and multi-indicator information of wide-area soil samples, providing a complete original data base for subsequent data processing and feature mining.
[0048] Step S2021b: Process the initial soil dataset according to the preset data processing strategy to obtain a preprocessed dataset.
[0049] In this embodiment, step S2021b processes the initial soil dataset according to a preset data processing strategy to obtain a preprocessed dataset. The preset data processing strategy is a standardized and regularized processing mechanism adapted to the characteristics of soil data, mainly including a series of processing operations such as data cleaning, missing value imputation, outlier removal, and data distribution correction. By systematically correcting and removing invalid data, missing data, and outlier data that deviate from the normal soil value range in the initial soil dataset, and simultaneously standardizing the index data with distribution offsets and skewed distributions, noise interference and data defects in the original data are effectively eliminated, and the data format and numerical scale of various soil indicators are unified, resulting in a preprocessed dataset with uniform data quality, effective features, and no abnormal interference, ensuring the accuracy of subsequent feature extraction and model training.
[0050] Step S2021c: Extract features from the preprocessed dataset to determine the soil feature vector.
[0051] In this embodiment, step S2021c, for the preprocessed standardized soil dataset, combines the data type and characteristic attributes of soil physicochemical indicators to carry out targeted feature modeling and feature encoding extraction operations. Continuous, discrete, and mixed features in the preprocessed dataset are classified, identified, and adapted for encoding. Through feature distribution fitting and vector transformation, the unstructured, tabular raw soil data is converted into a high-dimensional structured feature vector that the model can recognize and compute. This fully preserves the core feature information of each soil indicator in the preprocessed dataset and the correlation characteristics between indicators, ultimately obtaining a soil feature vector with unified dimensions, effective features, and adapted to the model input requirements.
[0052] Reference Figure 3For example, processing the initial soil dataset according to a preset data processing strategy includes: First, missing values are uniformly filled with specific values such as -9999999 to ensure that subsequent encoding and model training are not interrupted by NaN values. Second, logarithmic transformation is performed on numerical columns with significant skewness to achieve numerical stabilization, reduce the impact of long-tailed distributions on training, and improve the stability of Gaussian mixture fitting. At the same time, type labeling is completed to distinguish between continuous, discrete, and mixed type columns, providing meta-information for distribution modeling and segmented encoding.
[0053] Based on the processed data, distribution modeling and numerical encoding at the feature level are performed. First, metadata is constructed for each column, including record type, value range, encoding method, and required segmentation information. Then, a Bayesian Gaussian mixture model is fitted to continuous and mixed-type columns. Finite Gaussian mixture models approximate the true data distribution and provide component selection and residual encoding functions. The forward transformation maps tabular data to vectors. Simultaneously, the inverse transformation restores the network output vectors to data domain values. Finally, a conditional vector and sampling co-conditional module are constructed based on the preprocessed metadata. Conditional vectors are constructed during the training and sampling phases. During generation, the sampler calls the conditional vectors and metadata to guide component selection and local sampling, making the synthetic data distribution closer to the original data and more controllable.
[0054] In step S2021d, the soil feature vector is divided into a training set and a test set according to the preset partitioning rules.
[0055] In this embodiment, step S2021d divides the soil feature vectors into a training set and a test set according to a preset partitioning rule. The preset partitioning rule is a standardized data splitting ratio adapted to small-sample soil modeling. Under the premise of ensuring consistent data distribution and complete feature coverage in the two datasets after partitioning, all soil feature vectors are randomly and hierarchically partitioned. The training set is used for subsequent model constraint construction, loss function iterative optimization, and model parameter update training. The test set is used for performance verification and generation effect evaluation after model training. By reasonably partitioning the dataset, overfitting and underfitting problems are effectively avoided, ensuring the stability of model training and the objectivity and accuracy of model evaluation results.
[0056] For example, the data on the same sample dataset is divided in an 8:2 ratio, with 80% of the data used as the training set for learning model parameters and 20% of the data used as the test set for evaluating the model's generalization ability and prediction accuracy.
[0057] Optionally, step S2022, based on the first soil dataset, determines the causal structure constraints among soil indicators, specifically including the following steps: Step S2022a: The first soil dataset is processed using a preset causal discovery algorithm to determine a list of conditionally independent constraints. The list of conditionally independent constraints includes multiple conditional constraints, and each conditional constraint includes a first indicator variable, a second indicator variable, a condition set, and a constraint weight.
[0058] In this embodiment, step S2022a utilizes a pre-defined causal discovery algorithm to perform overall feature mining and structural analysis on the first soil dataset, solving for the conditional independence constraints between multiple sets of soil indicators, and summarizing them to construct a complete list of conditional independence constraints. The pre-defined causal discovery algorithm can be the PC algorithm (Peter-Clark Algorithm), which can automatically identify the independence and dependency relationships between different soil indicators based on data distribution characteristics, and screen out statistically significant effective constraint relationships. The obtained list of conditional independence constraints contains multiple effective conditional constraints, each of which corresponds to a set of independence relationship judgment combinations, specifically including a first indicator variable, a second indicator variable, a condition set, and constraint weights. The first and second indicator variables are any two sets of soil physicochemical indicators whose association is to be tested; the condition set is a set of other soil indicators that can interfere with and regulate the association between the two sets of indicators; and the constraint weights are used to characterize the credibility and importance of the corresponding conditional constraints, providing a basis for subsequent constraint quantification and weighted fusion.
[0059] Reference Figure 4 For example, when determining the causal structure constraints between soil indices, the constraints output by the PC algorithm are first loaded and parsed. The PC algorithm starts with a fully connected undirected graph and then progressively removes edges through a series of pre-defined conditional independence checks. For example, to check for 0th-order independence, the algorithm checks whether X and Y are unconditionally independent. If the check passes, the algorithm removes the edge between X and Y. Then, it checks for first-order conditional independence. For the still connected edge XY, the algorithm iterates through all adjacent vertices Z of X and Y, checking... Suppose the test passes when Z1 is used as the condition. The algorithm will then record the separating set {Z1} and delete the edge XY. This process continues until the algorithm eventually finds... If we set |{Z1, Z2, Z3}, then it will delete the XY edge. The final result will be a list of constraints in the format (variable X, variable Y, condition set Z, weight W).
[0060] Step S2022b: Using a preset regression algorithm, determine the first residual and the second residual corresponding to the first indicator variable and the second indicator variable, respectively.
[0061] In this embodiment of the application, step S2022b uses a preset regression algorithm to perform regression fitting on the first index variable and the second index variable in the condition constraints, and solves for the first residual corresponding to the first index variable and the second residual corresponding to the second index variable.
[0062] The pre-defined regression algorithm employs kernel regression fitting, relying on the indicator characteristics within the condition set to accurately estimate the conditional expectations of the first and second indicator variables. By constructing the fitting relationship between the condition set features and the target indicators, the predicted fitted values of the indicators under the control of the condition set are obtained. The difference between the original true values and the fitted predicted values is calculated to extract residual fluctuation information unrelated to the condition set variables, resulting in the first and second residuals. The residuals effectively eliminate the correlation interference introduced by the condition set, accurately preserving the independent fluctuation characteristics of the two sets of target indicators, providing a clean data foundation for subsequent independence testing and constraint violation calculation.
[0063] Reference Figure 4 For example, after loading and parsing the constraints output by the PC algorithm, the effects of the conditions on the variables are then calculated. Nonparametric Nadaraya-Watson kernel regression is used to estimate the conditional expectations E[X|Z] and E[Y|Z]. The specific steps are as follows: Calculate the kernel matrix of Z: As shown in the following formula, use the radial basis function (RBF) kernel to measure any two condition set samples Z. p and Z q Similarity between them: in, It is Euclidean distance, bandwidth Automatic estimation using the median heuristic, i.e., setting it as all sample pairs within a batch. The median distance. This allows the kernel scale to adapt to the density of the data.
[0064] Calculate the Nadaraya-Watson weights: The kernel matrix is shown in the following formula. Row-wise normalization yields the weight matrix. : in Indicating the estimation of the first When considering the conditional expectation of the nth sample, the nth The weight that each sample should have. and The more similar the two, the greater the weight.
[0065] The conditional expectation and residual are calculated, where the formula for the conditional expectation X is as follows: The conditional expectation formula for Y is shown below: The residual formula for X is shown below: The residual formula for Y is shown below.
[0066] It should be noted that, if If it is established, then and In theory, they are independent of each other.
[0067] Step S2022c: Determine the violation score of a single condition constraint based on the first residual, the second residual, and the preset independence algorithm.
[0068] In this embodiment, step S2022c, based on the obtained first and second residuals and combined with a preset independence algorithm, quantitatively calculates the constraint violation score corresponding to a single conditional constraint. The preset independence algorithm determines whether the two sets of indicators satisfy the preset conditional independence assumption by quantifying the correlation between the two sets of residuals. If there is a significant correlation between the two sets of residuals, it proves that the corresponding conditional independence assumption is not valid, and there is a causal structure violation. By quantifying the correlation strength between the residuals, a quantitative score that can characterize the current conditional constraint violation is obtained. The higher the constraint violation score, the greater the difference between the current data distribution and the mined true causal structure, providing a precise quantitative basis for the penalty constraints in subsequent model training.
[0069] Reference Figure 4 For example, after determining the conditional expectation and residual, further judgment is made. and Whether they are independent. Use the Hilbert-Schmidt Independence Criterion (HSIC). HSIC is a nonparametric statistical method for measuring the independence of two random variables. Its basic idea is that two random variables are independent if and only if any bounded function between them is uncorrelated. It maps the data to a high-dimensional feature space using a kernel function and calculates the distance between the distributions of the two variables in that space. If the two variables are independent, this distance should be zero; if they are not independent, the distance is greater than zero. The specific steps are as follows: The kernel matrix for calculating the residuals is shown in the following formula: and Calculate the RBF kernel matrix and : bandwidth and It is also estimated using the median heuristic.
[0070] The kernel matrix is double-centered. The formula for the centered matrix is shown below: in It is an n×n identity matrix. It is an n-dimensional column vector consisting entirely of 1s. The formula for the centered kernel matrix is as follows: Calculating HSIC: The V-statistic of HSIC is calculated as follows: in The trace represents the matrix. The value calculated by the formula is the result of applying the individual constraints. A measure of the degree of violation.
[0071] In step S2022d, the violation scores are weighted according to the constraint weights to obtain the causal structure constraints.
[0072] In this embodiment, step S2022d performs weighted integration of the violation scores of all individual constraints based on their respective constraint weights, ultimately constructing a causal structure constraint that can be used for model loss optimization. Different constraints correspond to different causal confidence and physical importance. By introducing constraint weights to perform a weighted average of the violation scores of each constraint, core causal constraints with high confidence and strong correlation can be retained first, while interference constraints with low confidence can be weakened, thereby improving the rationality and accuracy of the overall causal constraints.
[0073] Understandably, the integrated causal structure constraint can uniformly quantify the degree of causal structure violation of the overall soil index system. It can be incorporated into the model's total loss function as a regularization term, continuously constraining the pseudo-sample generation process during model training, so that the generated data always conforms to the inherent causal action law of soil indicators, and avoids invalid generation results that violate the soil physicochemical mechanism.
[0074] Optionally, step S2023, based on the second soil dataset, determines the mean square error constraints among soil indices, specifically including the following steps: Step S2023a: Based on the second soil dataset, construct candidate ordered pairs, wherein the candidate ordered pairs are soil index pairs that point to low-relevance features. High-relevance features refer to the features in the candidate index features whose correlation with the preset target index features is greater than a preset threshold, and low-relevance features refer to the features in the candidate index features whose correlation with the preset target index features is less than or equal to a preset threshold. The candidate index features are included in the second soil dataset.
[0075] Optionally, in this embodiment, step S2023a constructs candidate ordered pairs that conform to the local correlation rules of soil based on the various candidate indicator features included in the second soil dataset. First, a target indicator feature is preset as the correlation evaluation benchmark. The correlation coefficient between all candidate indicator features in the second soil dataset and the preset target indicator feature is calculated one by one. All candidate indicator features are then hierarchically divided according to a preset correlation threshold. Indicator features with a correlation greater than the preset threshold are defined as highly correlated features, and indicator features with a correlation less than or equal to the preset threshold are defined as low-correlation features. Based on this, following the fixed pairing rule of high-correlation features pointing to low-correlation features, the selected high-correlation features and low-correlation features are combined and paired to construct multiple sets of candidate ordered pairs. Each set of candidate ordered pairs can accurately correspond to the combination of indicators with significant correlation differences in the soil system of the target area, fully carrying the unique local numerical correlation relationship between the target soil indicators, and providing basic pairing units for subsequent feature difference calculation and baseline construction.
[0076] Reference Figure 5 For example, when determining the mean squared error, candidate ordered pairs are first constructed to ensure high correlation between each indicator. The specific steps are as follows: Variable centering is performed as shown in the following equation for candidate features. Centering is performed on the target column t: Here, mean represents the calculation of the mean.
[0077] calculate absolute value of the correlation coefficient with t As shown below: Where N is the sample size. denoted as σstandard, where the points in parentheses refer to the parameters within the parentheses.
[0078] Selecting those with a correlation higher than the threshold The feature set C is shown in the following formula: Based on the directed acyclic graph generated by the PC algorithm, generate ordered pairs that point from highly correlated points to lowly correlated points. The specific formula is as follows: If the number of ordered pairs of highly correlated features pointing to low correlated features generated by the PC algorithm is less than the preset number, then the Pearson correlation coefficient is used to supplement the ordered pairs of the first N highly correlated features pointing to the target column.
[0079] Step S2023b: Determine the true difference baseline based on the candidate ordered pairs, wherein the true difference baseline is used to characterize the feature difference of the candidate ordered pairs.
[0080] In this embodiment, step S2023b, based on the constructed multiple candidate ordered pairs, statistically calculates the feature differences corresponding to each ordered pair, and determines a stable true difference baseline through a smoothing iterative processing method. For each constructed candidate ordered pair in the second soil dataset, the feature difference between highly correlated features and low-correlation features is calculated sample by sample to obtain the original feature difference sequence corresponding to all real samples. To eliminate the numerical instability caused by fluctuations in the difference of a single sample, the original feature difference sequence is iteratively smoothed using an exponential moving average method to filter random noise and accidental biases, ultimately obtaining a true difference baseline that can stably represent the inherent numerical difference patterns of each candidate ordered pair.
[0081] Understandably, this true difference baseline is generated based on the statistical analysis of real soil measurement data in the target area. It accurately depicts the inherent static difference distribution characteristics and micro-numerical variation patterns between high-correlation and low-correlation characteristics in the real soil environment, and serves as the core reference standard for subsequent evaluation of the rationality of pseudo-sample values.
[0082] Reference Figure 5 For example, after constructing candidate ordered pairs, the true difference baseline is calculated on the discriminator side to make the generated data closely resemble the original data distribution. The specific steps are as follows: To calculate the difference between the actual data in the training set and the test set within a batch, and the difference between the generated data in the test set and the training set, the following formula is used: Where b is the batch index and k is the ordered pair index.
[0083] The mean of the true difference for each ordered pair is obtained by averaging the batch dimension, as shown in the following formula: Calculate the operating baseline as shown in the following formula, and smooth inter-batch fluctuations using an exponential moving average: in =0.9 is the smoothing coefficient, t is the current iteration step, and μ is the baseline mean.
[0084] Step S2023c: Determine the mean square error constraint based on the true difference baseline.
[0085] In this embodiment, step S2023c uses the true difference baseline as a reference to construct a mean squared error constraint for model training constraint optimization. During the generation of pseudo samples, the feature differences of each candidate ordered pair in the pseudo samples are extracted simultaneously. The pseudo sample feature differences are compared with the true difference baseline dimension by dimension. The degree of deviation between the pseudo sample difference and the true baseline difference is quantified by the mean squared error calculation method to obtain the overall numerical deviation loss.
[0086] Understandably, the mean squared error constraint can measure the numerical difference between the generated pseudo-samples and real soil data from a local micro-level perspective, accurately capturing the distortion problem of pseudo-samples in the details of indicator pairing differences. Using this constraint as a local regularization term in the iterative optimization of model loss can continuously constrain the model generation process, prompting the pseudo-samples output by the model to closely match the numerical statistical laws of real soil in the target area in terms of local indicator difference characteristics. This effectively reduces the micro-feature deviation between the generated samples and the real soil environment, improving the detail fidelity and scene adaptability of the generated samples.
[0087] Optionally, step S2024 involves constructing a total loss function based on the causal structure constraint, the mean squared error constraint, and the native loss of the preset model. The total loss function includes a first loss function and a second loss function, specifically comprising the following steps: Step S2024a: The original loss is split into generator base loss and discriminator base loss.
[0088] In this embodiment, step S2024a decomposes the native loss of the preset model, obtaining the generator's basic loss and the discriminator's basic loss. The native loss of the preset model is the basic loss system inherent in the model's adversarial training mechanism, encompassing the basic bias losses of the two core training dimensions: model generation and sample discrimination. To achieve accurate adaptation and differentiated fusion of subsequent constraint terms, the integrated native loss needs to be functionally decomposed. Based on the network function positioning and training objectives of the generator and discriminator, the generator's basic loss, used only to constrain the generator's basic generation capabilities, and the discriminator's basic loss, used only to constrain the discriminator's ability to distinguish between real and fake samples, are extracted. The two types of basic losses are independent of each other and each performs its own function, serving as the basic basis for the generator and discriminator loss functions, respectively. This provides a stable basic loss framework for the weighted fusion of multiple constraint terms, ensuring that the model's original adversarial training performance is not lost.
[0089] Step S2024b involves weighting and merging the generator base loss, causal structure constraint, and mean squared error constraint to obtain the first loss function.
[0090] In this embodiment, step S2024b weights and merges the split generator base loss, pre-constructed causal structure constraints, and mean squared error constraints to construct the first loss function corresponding to the generator. The generator undertakes the core task of generating pseudo-samples and needs to simultaneously meet the dual requirements of global causal mechanism compliance and local numerical feature authenticity. Therefore, dual constraint terms are superimposed for joint optimization. The causal structure constraints are used to standardize the overall generation logic of pseudo-samples, ensuring that the relationships between the generated soil sample indicators conform to the inherent causal interaction laws of the soil and preventing the generation of logically abnormal samples. The mean squared error constraints are used to correct local micro-numerical deviations in pseudo-samples, ensuring that the indicator difference characteristics of the generated samples fit the statistical laws of real soil data in the target area. By pre-setting weighting coefficients, the generator base loss, causal structure constraint loss, and mean squared error constraint loss are weighted and fused to balance the basic adversarial training effect, the causal structure constraint effect, and the local numerical fitting effect of the model, forming a complete first loss function and achieving comprehensive iterative optimization of the generator network parameters.
[0091] Step S2024c: The discriminator's basic loss and mean square error constraint are weighted and merged to obtain the second loss function.
[0092] In this embodiment, step S2024c involves weighted merging of the discriminator's base loss and mean squared error constraint obtained from the splitting process to construct the second loss function corresponding to the discriminator. The core function of the discriminator is to accurately distinguish between real soil samples and model-generated pseudo samples, and to identify local numerical detail differences and feature distribution deviations in the samples. Therefore, only the mean squared error constraint is introduced to assist in the discriminator optimization. Relying on the accurate characterization of local difference features of soil indicators by the mean squared error constraint, this compensates for the shortcomings of traditional discriminators that rely solely on global distribution discrimination and ignore local detail deviations. By pre-setting a weighting ratio, the discriminator's base loss and mean squared error constraint loss are organically integrated to construct the second loss function adapted to the discriminator training. This enables the discriminator not only to identify global distribution differences in samples but also to accurately capture subtle distortions in local indicator values and feature differences of pseudo samples, improving the discriminator's accuracy in distinguishing between real and pseudo samples, and thus driving the generator to continuously optimize its generation effect.
[0093] Reference Figure 6 For example, in the embodiments of this application, the model construction and training process is as follows: First, a causal regularization term is introduced into the generator loss function of CTAB-GAN+: Loss of a single constraint: For a constraint c = (variable X, variable Y, condition set Z, weight W), its loss is the calculated HSIC value, as shown in the following formula: The final CI (Conditional Independence) regularization term is obtained by weighting the losses of all constraints, as shown in the following formula: Where constraints are the set of conditionally independent constraints (X, Y, Z, W) obtained by the PC algorithm. It is the degree of constraint violation, W c To constrain the corresponding weights, kernel regression is first used to obtain the residuals, and then HSIC is used to measure whether the residuals still have dependencies. This means that the degree of violation of each constraint is summed up according to its weight. The greater the weight, the greater the impact of that constraint on the overall degree of violation. Normalization to a weighted average ensures that the result does not expand with the number of constraints or the overall weight size.
[0094] Ultimately, the CI loss term Total loss added to the generator In the equation, the information loss, downstream loss, and generator loss together constitute the total loss, as shown below. The information loss, downstream loss, and generator loss are the built-in loss functions of CTAB-GAN+. The downstream loss is shown in the following formula: Here, l(.) returns the target variable, fe(.) returns the input features of the given data record, and the dots in parentheses refer to the parameters within the parentheses. G(z) represents the generator neural network, and z is the input feature from a pre-defined prior distribution. The random noise vector obtained from sampling is received by the generator network, which receives the noise z and outputs synthesized samples.
[0095] Information loss is shown in the following formula: Where E and SD represent the mean and standard deviation of the feature, respectively. This indicates that sample x follows the data distribution of the real dataset. p data , Representation function Find the mathematical expectation over the true distribution. This indicates that the noise z follows a pre-defined prior distribution. p (z), Representation function Calculate the mathematical expectation over the noise prior distribution.
[0096] The generator loss is shown in the following equation: in and Let H(.) be the given and generated conditional vector bits corresponding to the i-th column, and H(.) be the cross-entropy loss.
[0097] Then, after obtaining the mean squared error between the real data and the pseudo-sample data, calculate the MSE of the pseudo-sample difference and the baseline, as well as the total loss of the discriminator. The specific steps are as follows: Discriminator side: MSE of spurious sample difference versus baseline and total discriminator loss As shown in the following formula: in, is the gradient penalty weight hyperparameter, which controls the proportion of the gradient penalty term in the overall loss; D(.) is the discriminator network, which takes samples as input and outputs scores; x represents the input real sample. For a real sample x, generate a difference sample obtained by linear interpolation of the sample; This indicates that the discriminator outputs the gradient vector of the input dimension using the interpolated samples; Represents the L2 (Euclidean) norm; The difference between the magnitude of the gradient vector L2 and the constant 1 is used to construct the gradient penalty error term; To generate the sample distribution, For the true sample distribution, This represents the distribution of the interpolated samples.
[0098] Local MSE constraints are applied on the generator side, and the specific steps are as follows: The difference in activation features of pseudo-samples is shown in the following formula: The local MSE constraint is calculated by averaging over the batch (B samples) and ordered pairs (K samples), as shown in the following formula: Local constraint loss and its total losses The integration of these elements results in the following formula: After obtaining the total loss of the divine support and the discriminator respectively, the model is trained based on the total loss.
[0099] Optionally, refer to Figure 7 In some embodiments of the present invention, the sample generation method is implemented as follows: Step 1, Data Collection: Nutrient content data for multiple indicators were collected using the LUCAS dataset, providing fundamental soil data support for subsequent model construction. The LUCAS dataset contains a large number of measured samples of European farmland, covering multiple regions and soil types, and is a core data source for constructing causal structures and training models.
[0100] Step 2, small sample data preprocessing: Typical small sample data of the target study area are extracted from the LUCAS dataset (those skilled in the art can determine the typicality according to the actual application needs), and data preprocessing (including cleaning, standardization, missing value imputation, etc.) is performed to obtain soil feature data of the target area that can be directly used for model training, ensuring the localization adaptation effect of the subsequent model.
[0101] Step 3: Construct a causal relationship structure for soil indicators: Using a large number of farmland samples from the LUCAS dataset, and combining the PC algorithm (causal discovery algorithm) and the Hilbert-Schmidt independence criterion (HSIC), we can explore the causal relationship structure among multiple nutrient content data.
[0102] The PC algorithm is responsible for identifying the conditional independence relationships among soil indicators and constructing an initial list of causal constraints. The HSIC criterion is used to quantify the independence between residuals, verify the conditional independence assumption, and ultimately form a causal structure constraint that can participate in model training, ensuring that the generated data conforms to the soil physicochemical mechanism.
[0103] Step 4, Model Training and MSE Constraint Construction: Based on the small sample data of the target area after preprocessing in step two, candidate ordered pairs (soil index pairings with high correlation features pointing to low correlation features) are constructed. Calculate the feature difference of candidate ordered pairs in the real sample, obtain the baseline of the real difference through exponential moving average, and construct the mean squared error (MSE) constraint; By fusing causal structure constraints, MSE constraints, and the native loss of the CTAB-GAN+ model, a differentiated loss function for the generator and discriminator is constructed, and a CTAB-GAN+ data generation model with dual constraints is trained.
[0104] Step 5: Generate pseudo-samples and verify them: The trained model is used to generate pseudo-sample data. Simultaneously, the real and pseudo-sample data are compared, and the mean squared error score is calculated to quantify the local numerical deviation between the pseudo-samples and real soil data, thus verifying the model's generation effect. If the error does not meet the requirements, the model will continue to iterate and optimize (feedback to the model training stage in step five) until the generated samples simultaneously meet the requirements of causal plausibility and numerical fidelity.
[0105] Step Six, Model Application: The validated model can be used for soil data augmentation in the target area, generating a sufficient number of high-quality pseudo-samples to solve the problem of insufficient soil modeling data under small sample conditions, and supporting subsequent applications such as soil property inversion and spatial mapping.
[0106] It is understood that, based on the description of the above embodiments, this invention addresses the problems of scarce nutrient data, high collection costs, and overfitting of traditional models in precision agriculture. By introducing causal constraint distribution modeling and a two-layer data preprocessing architecture, it overcomes the shortcomings of existing technologies that merely fit data distributions, ignore the true causal relationships between elements, and generate samples lacking actual physical meaning. Simultaneously, the proposed generative model utilizes causal priors and distribution constraints for joint constraints, improving data fidelity and model generalization ability, effectively alleviating overfitting problems under small sample sizes, and providing sufficient and reliable data support for soil nutrient prediction. This meets the needs of efficient and low-cost data supply and stable modeling in precision agriculture.
[0107] Based on the same inventive concept, this application also provides a sample generation apparatus for implementing the sample generation method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more sample generation apparatus embodiments provided below can be found in the limitations of the sample generation method described above, and will not be repeated here.
[0108] In one exemplary embodiment, such as Figure 8 As shown, a sample generation device 80 is provided, including: an acquisition module 801 for acquiring measured sample data of target soil; and a generation module 802 for inputting the measured sample data into a pre-constructed sample generation model to generate multiple pseudo samples. The sample generation model includes a generator and a discriminator. The first loss function corresponding to the generator includes causal structure constraints and mean square error constraints. The second loss function corresponding to the discriminator includes mean square error constraints. The causal structure constraints are used to characterize the causal logic between soil indicators, and the mean square error constraints are used to characterize the statistical characteristics of the numerical differences between related soil indicators.
[0109] Optionally, the sample generation device of the sample generation method further includes a construction module connected to the generation module, used for: acquiring a training dataset, wherein the training dataset includes a first soil dataset corresponding to multiple geographical regions and a second soil dataset corresponding to a geographical region; determining causal structure constraints between soil indicators based on the first soil dataset; determining mean squared error constraints between soil indicators based on the second soil dataset; constructing a total loss function based on the causal structure constraints, mean squared error constraints, and the native loss of the preset model, wherein the total loss function includes a first loss function and a second loss function; and training a sample generation model based on the second soil dataset and the total loss function.
[0110] Optionally, the training dataset includes a training set and a test set. The building module is also used to: obtain an initial soil dataset; process the initial soil dataset according to a preset data processing strategy to obtain a preprocessed dataset; extract features from the preprocessed dataset to determine soil feature vectors; and divide the soil feature vectors into a training set and a test set according to a preset partitioning rule.
[0111] Optionally, the construction module is further configured to: process the first soil dataset using a preset causal discovery algorithm to determine a list of conditionally independent constraints, wherein the list of conditionally independent constraints includes multiple conditional constraints, each conditional constraint including a first indicator variable, a second indicator variable, a condition set, and constraint weights; use a preset regression algorithm to determine the first residual and the second residual corresponding to the first indicator variable and the second indicator variable, respectively; determine the violation score of a single conditional constraint based on the first residual, the second residual, and the preset independence algorithm; and weight the violation scores according to the constraint weights to obtain the causal structure constraints.
[0112] Optionally, the construction module is further configured to: construct candidate ordered pairs based on the second soil dataset, wherein the candidate ordered pairs are soil index pairs that point to low-correlation features from highly correlated features, where highly correlated features refer to features among the candidate index features whose correlation with the preset target index features is greater than a preset threshold, and low-correlation features refer to features among the candidate index features whose correlation with the preset target index features is less than or equal to a preset threshold, and the candidate index features are included in the second soil dataset; determine the true difference baseline based on the candidate ordered pairs, wherein the true difference baseline is used to characterize the feature difference of the candidate ordered pairs; and determine the mean square error constraint based on the true difference baseline.
[0113] Optionally, the building module is also used to: split the native loss into generator base loss and discriminator base loss; weight and merge the generator base loss, causal structure constraint and mean squared error constraint to obtain a first loss function; and weight and merge the discriminator base loss and mean squared error constraint to obtain a second loss function.
[0114] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 9 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs in the non-volatile storage media to run. The database stores measured sample data of the target soil. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a grid connection. When the computer program is executed by the processor, it implements a sample generation method.
[0115] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0116] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0117] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0118] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0119] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0120] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0121] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0122] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0123] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method of sample generation, characterized by, The sample generation method includes: Obtain measured sample data of the target soil; The measured sample data is input into a pre-constructed sample generation model to generate multiple pseudo samples. The sample generation model includes a generator and a discriminator. The first loss function corresponding to the generator includes causal structure constraints and mean squared error constraints. The second loss function corresponding to the discriminator includes mean squared error constraints. The causal structure constraints are used to characterize the causal logic between soil indicators, and the mean squared error constraints are used to characterize the statistical characteristics of the numerical differences between related soil indicators.
2. The sample generation method of claim 1, wherein, The pre-construction of the sample generation model specifically includes: Obtain a training dataset, wherein the training dataset includes a first soil dataset corresponding to multiple geographical regions and a second soil dataset corresponding to a geographical region; Based on the first soil dataset, determine the causal structure constraints among soil indicators; Based on the second soil dataset, determine the mean square error constraints among soil indices; Based on the causal structure constraint, the mean squared error constraint, and the native loss of the preset model, a total loss function is constructed, wherein the total loss function includes the first loss function and the second loss function; The sample generation model is trained based on the second soil dataset and the total loss function.
3. The sample generation method of claim 2, wherein, The training dataset includes a training set and a test set. Obtaining the training dataset specifically includes: Obtain the initial soil dataset; The initial soil dataset is processed according to a preset data processing strategy to obtain a preprocessed dataset; Feature extraction is performed on the preprocessed dataset to determine the soil feature vector; According to the preset partitioning rules, the soil feature vectors are divided into the training set and the test set.
4. The sample generation method of claim 2, wherein, The step of determining the causal structure constraints among soil indicators based on the first soil dataset specifically includes: The first soil dataset is processed using a preset causal discovery algorithm to determine a list of conditionally independent constraints. The list of conditionally independent constraints includes multiple conditional constraints, and each conditional constraint includes a first indicator variable, a second indicator variable, a condition set, and a constraint weight. Using a preset regression algorithm, determine the first residual and the second residual corresponding to the first indicator variable and the second indicator variable, respectively; Based on the first residual, the second residual, and the preset independence algorithm, determine the degree of violation score of a single condition constraint; The violation score is weighted according to the constraint weights to obtain the causal structure constraint.
5. The sample generation method of claim 2, wherein, The step of determining the mean square error constraint between soil indicators based on the second soil dataset specifically includes: Based on the second soil dataset, candidate ordered pairs are constructed, wherein the candidate ordered pairs are soil index pairs that point to low-correlation features by high-correlation features. The high-correlation features refer to the features among the candidate index features that have a correlation greater than a preset threshold with the preset target index features, and the low-correlation features refer to the features among the candidate index features that have a correlation less than or equal to the preset target index features. The candidate index features are included in the second soil dataset. Based on the candidate ordered pairs, a true difference baseline is determined, wherein the true difference baseline is used to characterize the feature difference of the candidate ordered pairs; The mean square error constraint is determined based on the true difference baseline.
6. The sample generation method of claim 2, wherein, The step involves constructing a total loss function based on the causal structure constraint, the mean squared error constraint, and the native loss of the preset model. This total loss function includes the first loss function and the second loss function, specifically comprising: The original loss is decomposed into generator basic loss and discriminator basic loss; The generator base loss, causal structure constraint, and mean squared error constraint are weighted and combined to obtain the first loss function; The discriminator's basic loss and the mean square error constraint are weighted and combined to obtain the second loss function.
7. A sample generating apparatus, characterized by comprising: The sample generation device includes: The acquisition module is used to acquire measured sample data of the target soil. The generation module is used to input the measured sample data into a pre-built sample generation model to generate multiple pseudo samples. The sample generation model includes a generator and a discriminator. The first loss function corresponding to the generator includes causal structure constraints and mean squared error constraints. The second loss function corresponding to the discriminator includes mean squared error constraints. The causal structure constraints are used to characterize the causal logic between soil indicators, and the mean squared error constraints are used to characterize the statistical characteristics of the numerical differences between related soil indicators.
8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the steps of the sample generation method according to any one of claims 1-6.
9. A computer readable storage medium having stored thereon a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the sample generation method according to any one of claims 1-6.
10. A computer program product comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the sample generation method according to any one of claims 1-6.