Class imbalance table data processing method based on contrast constraint diffusion
By comparing constrained diffusion generation methods and combining diffusion modeling and contrastive learning branches, minority class samples are generated and filtered, solving the problem of inconsistent generated samples in class imbalance scenarios and improving the model's recognition and prediction capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SICHUAN UNIV
- Filing Date
- 2026-05-11
- Publication Date
- 2026-06-05
AI Technical Summary
Existing methods lack effective class discrimination constraints when generating minority class samples, resulting in inconsistent distribution of generated samples in the feature space, which affects the model's recognition ability and the reliability of prediction tasks in class imbalance scenarios.
A contrast-constrained diffusion generation method is adopted. The generative model is based on a two-branch asymmetric momentum contrastive learning architecture. It combines diffusion modeling branch and contrastive learning branch, and introduces prediction contrastive branch and target contrastive branch to generate and filter minority class synthetic samples, ensuring the consistency and discriminability of generated samples in terms of class semantics.
It improves the semantic reliability and discriminative effectiveness of minority class samples, reduces the interference of noisy samples on model training, and enhances the recognition ability of downstream tasks and the stability of the system.
Smart Images

Figure CN122153609A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data processing technology in the computer field, and specifically relates to a method for processing class-imbalanced table data based on contrast constraint diffusion. Background Technology
[0002] In recent years, with the development of machine learning and data analysis technologies, tabular data, as an important form of structured data, has been widely used in scenarios such as risk prediction, anomaly detection, medical auxiliary diagnosis, and financial analysis. These applications typically require training large models based on historical tabular data before predicting or identifying target events. The results are highly dependent on the quality and distribution characteristics of the training data. In practical applications, due to factors such as data acquisition costs and differences in event frequency, the number of samples in different categories within tabular data often exhibits a significant imbalance, meaning the number of minority class samples is significantly less than the number of majority class samples. For example, in financial risk prediction scenarios, abnormal or risky samples are usually far fewer than normal samples; in medical risk prediction scenarios, the number of severe disease cases is usually lower than the number of healthy or mild cases. This class imbalance problem causes models trained on the raw data to favor the majority class during prediction, thereby reducing their ability to identify minority class events.
[0003] To alleviate the aforementioned problems, existing technologies typically adjust the data distribution through methods such as sample reweighting, undersampling, or oversampling. Among these, oversampling methods, which generate new minority class samples to supplement the data distribution, are widely used in tasks involving class imbalance in tabular data. Synthetic minority oversampling methods (academically known as SMOTE and its various variants) generate new samples based on sample neighborhood interpolation. While their implementation is relatively simple, they struggle to effectively maintain the overall distribution characteristics of minority class samples in high-dimensional or heterogeneous feature scenarios and are prone to introducing noisy samples.
[0004] In recent years, generative model-based methods for generating minority class samples have been gradually proposed. These methods model the feature distribution of minority class samples and gradually recover synthetic samples that conform to statistical characteristics during the generation process, thereby improving the diversity and distribution consistency of the generated samples to a certain extent. Some methods enhance the consistency between the generated samples and the original data by introducing conditional information or feature constraints during the generation process, making the generated results closer to the real minority class samples in terms of overall statistical distribution.
[0005] However, in practical implementation, existing generative model-based minority class sample augmentation methods still have several key shortcomings. First, most methods primarily focus on the distribution fitting ability of minority class samples, lacking explicit constraints on the discriminative structure between different classes. This leads to generated samples potentially being distributed near class boundaries in the feature space, thus introducing semantic ambiguity or class confusion. Second, while some methods enhance modeling capabilities by introducing feature interaction structures, their constraints are mostly based on statistical correlation learning, making it difficult to guarantee the consistency and stability of generated samples at the class semantic level.
[0006] Furthermore, existing methods typically use synthetic samples directly for model training after sample generation, lacking a further verification mechanism for the structural consistency between the generated samples and the original data. This makes it difficult to identify and remove synthetic samples that do not conform to the class discrimination structure in a timely manner, which may accumulate errors in subsequent prediction tasks and affect the overall system performance.
[0007] Therefore, how to introduce an effective class discrimination constraint mechanism while generating minority class samples, so as to ensure that the generated samples have a clear and stable class semantic structure while maintaining a reasonable distribution, and further improve the reliability and robustness of downstream classification and prediction tasks, has become a technical problem that urgently needs to be solved in the field of class imbalance processing of tabular data. Summary of the Invention
[0008] To address the aforementioned shortcomings in existing technologies, the class imbalance table data processing method based on contrast constraint diffusion provided by this invention solves the problem that existing methods are insufficient in improving minority class recognition capabilities when generating samples in class imbalance scenarios.
[0009] To achieve the above-mentioned objectives, the technical solution adopted by this invention is as follows:
[0010] A method for processing class-imbalanced table data generated based on contrast constraint diffusion is provided, which includes the following steps:
[0011] S1. Obtain a binary classification tabular dataset. Each sample in the tabular dataset includes numerical features, categorical features, and a classification label. The number of samples in the minority class is less than the number of samples in the majority class in the tabular dataset.
[0012] S2. The generative model is trained using a tabular dataset to obtain a generative model that generates a synthetic latent representation of the minority class based on noise. The generative model includes a parallel diffusion modeling branch and a contrastive learning branch. The contrastive learning branch adopts a two-branch asymmetric momentum contrastive learning architecture, including a prediction contrastive branch and a target contrastive branch.
[0013] S3. Randomly generate several noise inputs to generate the model. The diffusion modeling branch performs noise denoising and collects the synthetic latent representation of the minority class of each noise. The decoding module decodes each synthetic latent representation to obtain a synthetic table sample.
[0014] S4. Filter all synthetic table samples, and then merge all the filtered synthetic table samples with the table dataset to obtain enhanced imbalanced table data.
[0015] Furthermore, methods for training generative models using tabular datasets include:
[0016] S21. Input the samples corresponding to the minority class in the tabular dataset into the diffusion modeling branch to generate a latent representation, and inject noise into it to generate a noisy latent representation. Based on the noisy latent representation and the time step, obtain the prediction result for the noise.
[0017] S22. For any sample in the tabular dataset Search the tabular dataset for the sample that is closest to it in Euclidean distance and has the same classification label. To form positive sample pairs, a tabular dataset is used to centralize the samples. All samples with different labels constitute the negative sample set;
[0018] S23, Sample Input the prediction comparison branch to obtain the predicted feature representation, and then input the sample. With sample The corresponding negative sample set is input into the target comparison branch to obtain the target feature representation;
[0019] S24. Calculate the loss function value of the generative model using the prediction results, prediction feature representation, and target feature representation, and then backpropagate to update the model parameters of the generative model.
[0020] S25. Increment the iteration count by one and determine whether the iteration count has reached the preset iteration count. If yes, complete the training of the generative model; otherwise, return to step S21.
[0021] Furthermore, the diffusion modeling branch includes a feature segmenter, a feature encoder, and a multi-layer transfactor diffusion modeling module connected in sequence;
[0022] The prediction contrast branch includes a feature segmenter and a feature encoder shared with the diffusion modeling branch, as well as a projection multilayer perceptron connected to the feature encoder and the prediction multilayer perceptron, respectively.
[0023] The target comparison branch includes a feature segmenter, a feature encoder, and a projection multilayer perceptron connected in sequence.
[0024] The feature segmenter is used to map each feature and classification label of a sample into a vector to form a feature vector; the feature encoder is used to perform cross-feature modeling on the feature vector, capture the correlation between different feature dimensions, and obtain a latent representation; the multi-layer transformer diffusion modeling module is used to obtain the prediction result of noise based on the input noisy latent representation and time step.
[0025] The projection multilayer perceptron and the prediction multilayer perceptron of the prediction contrast branch form a projection head, which is used to generate a prediction feature representation based on the latent representation; the projection multilayer perceptron of the target contrast branch is used to generate a target feature representation based on the latent representation.
[0026] Furthermore, the loss function for calculating the loss function value of the generative model is... The expression is:
[0027] ,
[0028]
[0029] in, Let the diffusion loss function be used. To compare loss functions; These are the weighting coefficients used to balance the contributions of the two types of losses; A latent representation of samples in the minority class; for Noisy latent representation; For time steps; for The corresponding prediction results; Let be the square of the second norm of the vector; It is a standard multivariate Gaussian distributed random noise vector; For a minority class of potential subspaces; Let be the expectation operator, representing the joint expectation operation on the minority class latent representation samples, the diffusion time step, and the random noise variable; The set of index pairs for positive sample pairs; This represents the total number of positive sample pairs. This is a similarity metric function used to measure the similarity of feature representations; Temperature coefficient; It is an exponential function; For the sample The predictive features are represented; For the sample Target feature representation; For the sample The negative sample set; for The kth sample in the formed set The target feature representation.
[0030] Furthermore, the target comparison branch is also equipped with a parameter smoothing update mechanism, the expression of which is:
[0031]
[0032] in, The parameters of the comparison branch are for the target. Update directly without backpropagation; is the feature encoding parameter for predicting the contrastive branch; m is the momentum update coefficient.
[0033] Furthermore, methods for generating noisy latent representations by injecting noise into the latent representation include:
[0034] The numerical features in the sample are noise-added using a Gaussian noise method:
[0035]
[0036]
[0037] in, Latent representation of samples in the minority class The numerical feature part; for Noisy latent representation after adding noise; For the i-th dimension, it is a numerical feature; Let be the noise intensity function of the numerical feature of the i-th dimension at time step t; and These represent the minimum and maximum values of the noise intensity, respectively. Let be the learnable noise scheduling parameter corresponding to the numerical feature of the i-th dimension; This is the element-wise multiplication operator; It is a standard multivariate Gaussian distributed random noise vector; It follows a Gaussian distribution; It is the identity matrix;
[0038] Noise is added to the categorical features in the sample using a random masking method:
[0039]
[0040]
[0041] in, Latent representation of samples in the minority class The categorical feature part; For masking functions; for Noisy latent representation after adding noise; Let be the noise intensity function of the categorical feature of the i-th dimension at time step t; The learnable noise scheduling parameter is the categorical feature corresponding to the j-th dimension. and Train together with the neural network parameters of the multi-layer transomer diffusion modeling module.
[0042] Furthermore, methods for filtering data across all synthetic table samples include:
[0043] S41. Input all samples from the tabular dataset and all synthetic tabular samples into the prediction contrast branch and project them onto the discriminant space. :
[0044]
[0045] Where h is the contrastive embedding feature vector obtained after the input sample is mapped by the prediction contrastive branch; For all samples in the tabular dataset and any sample from all synthetic tabular samples; It is the overall feature mapping function; It is a shared feature mapping function composed of a shared feature segmenter and a feature encoder; Projection functions are constructed for the projection multilayer perceptron and the prediction multilayer perceptron, respectively, to predict the contrast branch. The equals sign is defined to indicate that the variable on the left is derived from the expression on the right;
[0046] S42, in the discriminant space In the process, calculate any two samples cosine distance:
[0047]
[0048] in, For the sample The cosine distance; For transpose; Let L be the L2 norm of the vector;
[0049] S43. For the synthesized table sample, search for its value in the table dataset based on the cosine distance. The nearest neighbor;
[0050] S44, in each synthetic table sample Among the nearest neighbors, if the majority class accounts for a greater than 100%, the majority class accounts for a greater than 100%. If so, the current composite table sample is removed, and the filtered composite table sample is obtained.
[0051] Furthermore, the decoding module is based on samples in a tabular dataset. Its potential representation The correspondence between them is determined by minimizing the reconstruction error. The latent representation obtained from training recovers the mapping function. This is the decoding module.
[0052] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0053] (1) Improve the semantic reliability of minority class sample generation. In the process of minority class sample generation, the present invention introduces contrast constraints (i.e., the contrast learning branch composed of the prediction contrast branch and the target contrast branch). Through the contrast constraints, the semantic consistency of the sample category and the separability between categories can be constrained, so that the generated sample can maintain a clear and stable category semantic structure while satisfying the reasonable distribution of minority class features, thereby avoiding the generated sample from falling into the fuzzy region of category boundary or the region dominated by the majority class, thus improving the semantic reliability of the generated minority class sample.
[0054] (2) Enhance the discriminative effectiveness of minority class samples in high-dimensional tabular data. By jointly modeling the generation process and the contrastive learning process in the shared feature representation space (the feature segmenter and feature encoder shared by the diffusion modeling branch and the prediction contrast branch), this invention can guide the generated samples to exhibit the distribution characteristics of intra-class compactness and inter-class separation in high-dimensional, heterogeneous feature tabular data scenarios, thereby enhancing the discriminative support capability of the generated minority class samples for downstream classification or prediction tasks.
[0055] (3) To reduce the risk of performance degradation caused by noise-enhanced samples, this invention further introduces a posterior structure consistency screening mechanism based on the discriminative feature space after the samples are generated (referring to the process of removing generated samples that do not meet the preset category structure consistency conditions based on the neighborhood relationship of the samples in the discriminative feature space after the samples are generated). This removes generated samples that do not meet the preset category structure, thereby effectively reducing the interference of semantic noise samples on the model training process and reducing the risk of model performance degradation caused by unstable sample enhancement quality.
[0056] (4) Improve the applicability and stability of the method in different downstream models and application scenarios. The minority class samples generated by this invention have high consistency at the category semantic level. They can be used in conjunction with a variety of classification or prediction models without relying on a specific downstream model structure, thereby improving the stability and reliability of the overall system performance in class imbalance scenarios. Attached Figure Description
[0057] Figure 1 This is a flowchart of a method for processing class-imbalanced table data generated based on contrast constraint diffusion.
[0058] Figure 2 This is a diagram of the overall architecture of the generated model. Detailed Implementation
[0059] The specific embodiments of the present invention are described below to enable those skilled in the art to understand the present invention. However, it should be understood that the present invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the present invention as defined and determined by the appended claims. All inventions utilizing the concept of the present invention are protected.
[0060] refer to Figure 1 , Figure 1 A flowchart is shown below illustrating a method for processing class-imbalanced table data generated based on contrast constraint diffusion. Figure 1 As shown, the method S includes steps S1 to S4.
[0061] In step S1, a binary classification tabular dataset is obtained. Each sample in the tabular dataset includes numerical features, categorical features, and a classification label. The number of minority class samples in the tabular dataset is less than the number of majority class samples.
[0062] The tabular dataset in this scheme ,in For samples containing numerical features, categorical features, and classification labels, For classification labels (real-world classification labels are not simply 0 and 1, but for ease of processing, we convert the majority class label to 0 and the minority class label to 1). Define the set of indices of all majority class samples in this tabular dataset. The set of indices of all minority class samples An imbalanced binary classification table dataset refers to a dataset that satisfies the following conditions: .
[0063] The purpose of this scheme is to generate a set of minority class samples. (Its classification label must be 1, that is, it must be a minority class), to supplement the original imbalanced dataset, to obtain more balanced tabular training data, thereby eliminating a series of problems caused by class imbalance during the model training stage.
[0064] In this scheme, when the binary classification tabular dataset is used for financial risk prediction, the dataset uses customers or transaction records as samples. The feature vector contains a hybrid representation of numerical and categorical features. The numerical features include, but are not limited to, continuous variables such as transaction amount, account balance, repayment amount, and number of historical overdue payments. The categorical features include, but are not limited to, discrete variables such as customer occupation category, marital status, credit rating, and transaction type. The labels are binary variables indicating whether a risk event has occurred (e.g., default / normal, fraud / non-fraud), and the number of risk class samples is significantly less than the number of normal class samples. When the binary classification tabular dataset is used for medical risk prediction, the dataset uses individual patients or medical records as samples. The feature vector also contains a hybrid representation of numerical physiological indicators and categorical clinical attributes. The numerical features include, but are not limited to, continuous variables such as blood pressure, blood sugar, heart rate, and laboratory test values. The categorical features include, but are not limited to, discrete variables such as gender, past medical history category, diagnosis type, and treatment plan category. The labels are binary variables indicating disease risk or severity (e.g., severe / non-severe, sick / not sick), and the number of high-risk or severe samples is significantly less than the number of normal or mild samples.
[0065] In step S2, the generative model is trained using a tabular dataset to obtain a generative model that generates a synthetic latent representation of the minority class based on noise. The generative model includes a parallel diffusion modeling branch and a contrastive learning branch. The contrastive learning branch adopts a two-branch asymmetric momentum contrastive learning architecture, including a prediction contrastive branch and a target contrastive branch.
[0066] In scenarios with imbalanced tabular data, if the generation model is trained uniformly on all samples, the generation process is easily dominated by the statistical characteristics of the majority class samples, thus weakening the ability to model the distribution of the minority class. To avoid the above problem, the diffusion modeling branch of this scheme only performs diffusion modeling on the latent representations corresponding to the minority class samples. That is, only the latent representations of the minority class samples are fed into the diffusion modeling branch, so that the generation process focuses on the expression of the feature structure of the minority class.
[0067] The contrastive learning branch guides sample features to exhibit an intra-class clustering and inter-class separation distribution structure in the latent representation space by constructing similarity relationships between samples of the same class and distinguishing relationships between samples of different classes. This is used to learn the discriminative structure of different classifications on the majority and minority classes.
[0068] In one embodiment of the present invention, the method for training a generative model using a tabular dataset includes:
[0069] S21. Input the samples corresponding to the minority class in the tabular dataset into the diffusion modeling branch to generate a latent representation, and inject noise into it to generate a noisy latent representation. Based on the noisy latent representation and the time step, obtain the prediction result for the noise. In implementation, the preferred method of injecting noise into the latent representation to generate a noisy latent representation in this scheme includes:
[0070] The numerical features in the sample are noise-added using a Gaussian noise method:
[0071]
[0072]
[0073] in, Latent representation of samples in the minority class The numerical feature part; for Noisy latent representation after adding noise; Let be the noise intensity function of the numerical feature of the i-th dimension at time step t; and These represent the minimum and maximum values of the noise intensity, respectively. Let be the learnable noise scheduling parameter corresponding to the numerical feature of the i-th dimension; This is the element-wise multiplication operator; It is a standard multivariate Gaussian distributed random noise vector; It follows a Gaussian distribution; It is the identity matrix;
[0074] Noise is added to the categorical features in the sample using a random masking method:
[0075]
[0076]
[0077] in, Latent representation of samples in the minority class The categorical feature part; For masking functions; for Noisy latent representation after adding noise; Let be the noise intensity function of the categorical feature of the i-th dimension at time step t; The learnable noise scheduling parameter is the categorical feature corresponding to the j-th dimension. and Train together with the neural network parameters of the multi-layer transomer diffusion modeling module.
[0078] In this scheme, to adapt to the differences in physical semantics across different feature dimensions, a noise scheduling function is used. and Parameterization by feature dimension and The noise intensity of numerical features and the mask probability of class features are controlled separately to enable the diffusion process to match the different value structures and semantic constraints of the two types of features. and As learnable parameters, they will be trained together with the neural network parameters of the multi-layer transformer diffusion modeling module to achieve adaptive noise scheduling of feature dimensions, thereby enhancing the fitting ability and correlation preservation ability of features with different distributions in high-dimensional tables.
[0079] S22. For any sample in the tabular dataset Search the tabular dataset for the sample that is closest to it in Euclidean distance and has the same classification label. To form positive sample pairs, a tabular dataset is used to centralize the samples. All samples with different labels constitute the negative sample set;
[0080] S23, Sample Input the prediction comparison branch to obtain the predicted feature representation, and then input the sample. With sample The corresponding negative sample set is input into the target comparison branch to obtain the target feature representation;
[0081] S24. Calculate the loss function value of the generative model using the prediction results, prediction feature representation, and target feature representation, and then backpropagate to update the model parameters of the generative model.
[0082] In one embodiment of the present invention, a loss function is used to calculate the loss function value of the generative model. The expression is:
[0083] ,
[0084]
[0085] in, Let the diffusion loss function be used. To compare loss functions; These are the weighting coefficients used to balance the contributions of the two types of losses; A latent representation of samples in the minority class; for Noisy latent representation; For time steps; for The corresponding prediction results; Let be the square of the second norm of the vector; It is a standard multivariate Gaussian distributed random noise vector; For a minority class of potential subspaces; Let be the expectation operator, representing the joint expectation operation on the minority class latent representation samples, the diffusion time step, and the random noise variable; The set of index pairs for positive sample pairs; This represents the total number of positive sample pairs. This is a similarity metric function used to measure the similarity of feature representations; Temperature coefficient; It is an exponential function; For the sample The predictive features are represented; For the sample Target feature representation; For the sample The negative sample set; for The kth sample in the formed set The target feature representation.
[0086] In this plan, The gradient signal will affect the network parameters of the multi-layer transfactor diffusion modeling module, the shared feature segmenter and feature encoder module parameters; The gradient signals will act on the parameters of the projective multilayer perceptron and the predictive multilayer perceptron in the prediction-contrast branch, as well as the parameters of the shared feature segmenter and feature encoder modules. Since the diffusion modeling branch and the prediction-contrast branch share the same feature encoder, the gradient signals of the diffusion modeling loss and the contrastive learning loss will act together on this shared feature encoder during training, so that it is constrained by the discriminative structure while learning the minority class generation distribution.
[0087] S25. Increment the iteration count by one and determine whether the iteration count has reached the preset iteration count. If yes, complete the training of the generative model; otherwise, return to step S21.
[0088] like Figure 2 As shown, in implementation, the preferred method of this scheme includes a feature segmenter, a feature encoder, and a multi-layer transfactor diffusion modeling module connected in sequence.
[0089] The prediction contrast branch includes a feature segmenter and a feature encoder shared with the diffusion modeling branch, as well as a projection multilayer perceptron connected to the feature encoder and the prediction multilayer perceptron, respectively.
[0090] The target comparison branch includes a feature segmenter, a feature encoder, and a projection multilayer perceptron connected in sequence.
[0091] The feature segmenter maps each feature and classification label of a sample to a vector to form a feature vector; the feature encoder performs cross-feature modeling on the feature vector to capture the correlation between different feature dimensions and obtain a latent representation; the multi-layer transformer diffusion modeling module obtains the prediction result of noise based on the input noisy latent representation and time step.
[0092] The projection multilayer perceptron of the predictive contrastive branch and the predictive multilayer perceptron constitute a projection head, which is used to generate a predictive feature representation based on the latent representation; the projection multilayer perceptron of the target contrastive branch is used to generate a target feature representation based on the latent representation.
[0093] In this scheme, the generative model, after adopting the above structure, inputs the latent representation obtained by mapping the samples through the shared feature segmenter and the feature encoder into the projection multilayer perceptron and the prediction multilayer perceptron during the training phase to construct feature representations and calculate the contrastive loss based on positive and negative sample pairs. During backpropagation, the gradient signal of the contrastive loss is propagated back layer by layer through the projection multilayer perceptron, the shared feature encoder, and the shared feature segmenter, thereby updating the parameters of the shared feature segmenter and the feature encoder.
[0094] Finally, in the generation phase, the latent noise from random sampling is gradually denoised through backdiffusion, approximating the latent representation distribution obtained by the shared feature encoder mapping real samples during the training phase. Since this latent representation is jointly constrained by both diffusion loss and contrastive loss during training, its spatial structure possesses clear class semantic characteristics, thus ensuring that the generated minority class latent representation is semantically consistent with the real minority class. In other words, through the constraints of contrastive learning, structural constraints are achieved, enabling the generated samples to possess semantic consistency within the same class and semantic separability between different classes.
[0095] In step S3, several noise input generation models are randomly generated. The diffusion modeling branch performs noise denoising and collects the synthetic latent representation of the minority class for each noise. The decoding module decodes each synthetic latent representation to obtain a synthetic table sample. The detailed implementation process of step S3 is as follows:
[0096] Initial noise is sampled from a standard Gaussian distribution: ,in This represents the initial potential representation of the reverse diffusion process. Let be the identity matrix. After obtaining the initial noise representation, based on the generative model parameters learned during the training phase, a back-diffusion sampling process is sequentially performed in the latent representation space according to a preset time step sequence t=T,T−1,…,1. Specifically, at each time step t, according to the conditional probability distribution: , for the current potential representation Denoising sampling is performed to gradually obtain the potential representation of reduced noise intensity. .
[0097] After obtaining the synthesized minority class latent representation, it is input into the decoding module. The latent representation is mapped back to the original table feature space to obtain the corresponding synthetic table sample. The decoding module in this scheme is based on samples in the tabular dataset. Its potential representation The correspondence between them is determined by minimizing the reconstruction error. The latent representation obtained from training recovers the mapping function. This is the decoding module.
[0098] In step S4, all synthetic table samples are filtered, and then all filtered synthetic table samples are merged with the table dataset to obtain enhanced imbalanced table data.
[0099] In one embodiment of the present invention, a method for filtering data from all synthetic table samples includes:
[0100] S41. Input all samples from the tabular dataset and all synthetic tabular samples into the prediction contrast branch and project them onto the discriminant space. :
[0101]
[0102] Where h is the contrastive embedding feature vector obtained after the input sample is mapped by the prediction contrastive branch; For all samples in the tabular dataset and any sample from all synthetic tabular samples; It is the overall feature mapping function; It is a shared feature mapping function composed of a feature segmenter and a feature encoder; Projection functions are constructed for the projection multilayer perceptron and the prediction multilayer perceptron, respectively, to predict the contrast branch. The equals sign is defined to indicate that the variable on the left is derived from the expression on the right;
[0103] S42, in the discriminant space In the process, calculate any two samples cosine distance:
[0104]
[0105] in, For the sample The cosine distance; For transpose; Let L be the L2 norm of the vector;
[0106] S43. For the synthesized table sample, search for its value in the table dataset based on the cosine distance. The nearest neighbor;
[0107] S44, in each synthetic table sample Among the nearest neighbors, if the majority class accounts for a greater than 100%, the majority class accounts for a greater than 100 If so, the current composite table sample is removed, and the filtered composite table sample is obtained.
[0108] This scheme can remove synthetic table samples that are inconsistent with the semantic structure of real minority class samples through the above filtering method, thereby ensuring that the generated synthetic table samples are more "like" the real minority class and less "like" the real majority class, thus effectively reducing the interference of semantic noise samples on the model training process.
[0109] To improve the stability of the contrastive learning branch structure, this invention introduces a parameter smoothing update mechanism in the target contrastive branch, enabling the target feature representation to evolve smoothly as the parameters of the prediction contrastive branch change. Specifically, the expression for the parameter smoothing update mechanism is:
[0110]
[0111] in, The parameters of the comparison branch are for the target. Update directly without backpropagation; is the feature encoding parameter for predicting the contrastive branch; m is the momentum update coefficient.
[0112] The following examples illustrate the effectiveness of the unbalanced tabular data processing method provided in this solution:
[0113] Taking financial risk prediction as an example, experiments were conducted on the Default of Credit Card Clients dataset. This dataset contains significantly fewer defaulted samples than normal samples, representing typical imbalanced financial risk data. The method of this invention generates and enhances the minority defaulted samples, which are then used to train the risk prediction model. An example of the Default of Credit Card Clients dataset (each row represents a sample, and each column is its feature or label name) can be found in Table 1.
[0114] Table 1. Example of a credit card customer default dataset
[0115]
[0116] The specific experimental setup is as follows: the default ratio of normal to default samples in the original dataset is 3.52 (i.e., majority class samples: minority class samples = 3.52). The experiment first divides the original dataset into training and test sets in a 7:3 ratio. Then, the training set is copied several times, with different sets being processed differently: left unprocessed, processed using other methods to augment the minority class, and processed using the method described in this experiment to augment the minority class. These unprocessed and differently processed training sets are then used to train a classifier (this embodiment uses LR, RF, XGBoost, ADABoost, and SVM). The previously created test set is then used to test the trained classifier, allowing the classifier to determine the label (normal or default) of the samples based on their features. This experiment uses the F1 score to describe the classifier's label judgment and classification results on the test set.
[0117] The F1 score is a comprehensive performance metric used to evaluate the performance of classification models, simultaneously measuring the model's completeness and accuracy in classifying the target class. In binary classification tasks, for the target class (usually the minority class), the F1 score is defined as the harmonic mean of precision and recall, calculated as follows:
[0118]
[0119] Precision represents the proportion of samples that the model classifies as belonging to the target class, but which actually do. Recall represents the proportion of samples that actually belong to the target class, but which are correctly identified by the model. The F1 score ranges from 0 to 1, with higher values indicating better classification performance. Specifically, a high F1 score indicates that the model can comprehensively identify true minority class samples (high recall) while avoiding misclassifying majority class samples as minority class samples (high precision).
[0120] Table 2 shows the results of processing a credit card customer default dataset and testing it on five classifiers. The first column represents the name of the enhancement method used or not enhanced; the first row represents the name of the classifier used.
[0121] Table 2 shows the results of testing the processed credit card customer default dataset on five classifiers.
[0122]
[0123] Experimental results show that, under the same classifier conditions, the dataset augmented by the method of this invention outperforms methods such as SMOTE, ADASYN, CTAB-GAN+, and TabDiff in the F1 score, indicating that this invention can effectively improve the identification ability of minority class risk events, thereby enhancing the accuracy and stability of the financial risk prediction system. The results also demonstrate that the proposed method effectively augments imbalanced datasets, enabling classifiers trained with the augmented dataset to better perform classification and prediction functions. Furthermore, the dataset augmented by this method exhibits the highest performance across all classifiers, demonstrating that the dataset obtained by this method possesses good model independence and generalization effectiveness.
Claims
1. A method for processing class-imbalanced table data generated based on contrastive constraint diffusion, characterized in that, Including the following steps: S1. Obtain a binary classification tabular dataset. Each sample in the tabular dataset includes numerical features, categorical features, and a classification label. The number of samples in the minority class is less than the number of samples in the majority class in the tabular dataset. S2. The generative model is trained using a tabular dataset to obtain a generative model that generates a synthetic latent representation of the minority class based on noise. The generative model includes a parallel diffusion modeling branch and a contrastive learning branch. The contrastive learning branch adopts a two-branch asymmetric momentum contrastive learning architecture, including a prediction contrastive branch and a target contrastive branch. S3. Randomly generate several noise inputs to generate the model. The diffusion modeling branch performs noise denoising and collects the synthetic latent representation of the minority class of each noise. The decoding module decodes each synthetic latent representation to obtain a synthetic table sample. S4. Filter all synthetic table samples, and then merge all the filtered synthetic table samples with the table dataset to obtain enhanced imbalanced table data.
2. The method for processing unbalanced tabular data according to claim 1, characterized in that, Methods for training generative models using tabular datasets include: S21. Input the samples corresponding to the minority class in the tabular dataset into the diffusion modeling branch to generate a latent representation, and inject noise into it to generate a noisy latent representation. Based on the noisy latent representation and the time step, obtain the prediction result for the noise. S22. For any sample in the tabular dataset Search the tabular dataset for the sample that is closest to it in Euclidean distance and has the same classification label. To form positive sample pairs, a tabular dataset is used to centralize the samples. All samples with different labels constitute the negative sample set; S23, Sample Input the prediction comparison branch to obtain the predicted feature representation, and then input the sample. With sample The corresponding negative sample set is input into the target comparison branch to obtain the target feature representation; S24. Calculate the loss function value of the generative model using the prediction results, prediction feature representation, and target feature representation, and then backpropagate to update the model parameters of the generative model. S25. Increment the iteration count by one and determine whether the iteration count has reached the preset iteration count. If yes, complete the training of the generative model; otherwise, return to step S21.
3. The method for processing unbalanced tabular data according to claim 2, characterized in that, The diffusion modeling branch includes a feature segmenter, a feature encoder, and a multi-layer transfactor diffusion modeling module connected in sequence. The prediction contrast branch includes a feature segmenter and a feature encoder shared with the diffusion modeling branch, as well as a projection multilayer perceptron connected to the feature encoder and the prediction multilayer perceptron, respectively. The target comparison branch includes a feature segmenter, a feature encoder, and a projection multilayer perceptron connected in sequence. The feature segmenter is used to map each feature and classification label of a sample into a vector to form a feature vector; the feature encoder is used to perform cross-feature modeling on the feature vector, capture the correlation between different feature dimensions, and obtain a latent representation; the multi-layer transformer diffusion modeling module is used to obtain the prediction result of noise based on the input noisy latent representation and time step. The projection multilayer perceptron and the prediction multilayer perceptron of the prediction contrast branch form a projection head, which is used to generate a prediction feature representation based on the latent representation. The projected multilayer perceptron of the target contrast branch is used to generate target feature representations based on latent representations.
4. The method for processing unbalanced tabular data according to claim 2, characterized in that, Loss function for calculating the loss function value of the generative model The expression is: , ; ; in, Let the diffusion loss function be used. To compare loss functions; These are the weighting coefficients used to balance the contributions of the two types of losses; A latent representation of samples in the minority class; for Noisy latent representation; For time steps; for The corresponding prediction results; Let be the square of the second norm of the vector; It is a standard multivariate Gaussian distributed random noise vector; For a minority class of potential subspaces; Let be the expectation operator, representing the joint expectation operation on the minority class latent representation samples, the diffusion time step, and the random noise variable; The set of index pairs for positive sample pairs; This represents the total number of positive sample pairs. This is a similarity metric function used to measure the similarity of feature representations; Temperature coefficient; It is an exponential function; For the sample The predictive features are represented; For the sample Target feature representation; For the sample The negative sample set; for The kth sample in the formed set The target feature representation.
5. The method for processing unbalanced tabular data according to claim 2, characterized in that, The target comparison branch also includes a parameter smoothing update mechanism, the expression of which is: ; in, The parameters of the comparison branch are for the target. Update directly without backpropagation; is the feature encoding parameter for predicting the contrastive branch; m is the momentum update coefficient.
6. The method for processing unbalanced tabular data according to claim 2, characterized in that, Methods for generating noisy latent representations by injecting noise into latent representations include: The numerical features in the sample are noise-added using a Gaussian noise method: ; ; in, Latent representation of samples in the minority class The numerical feature part; for Noisy latent representation after adding noise; Let be the noise intensity function of the numerical feature of the i-th dimension at time step t; and These represent the minimum and maximum values of the noise intensity, respectively. Let be the learnable noise scheduling parameter corresponding to the numerical feature of the i-th dimension; This is the element-wise multiplication operator; It is a standard multivariate Gaussian distributed random noise vector; It follows a Gaussian distribution; It is the identity matrix; Noise is added to the categorical features in the sample using a random masking method: ; ; in, Latent representation of samples in the minority class The categorical feature part; For masking functions; for Noisy latent representation after adding noise; Let be the noise intensity function of the categorical feature of the j-th dimension at time step t; The learnable noise scheduling parameter is the categorical feature corresponding to the j-th dimension. and Train together with the neural network parameters of the multi-layer transomer diffusion modeling module.
7. The method for processing unbalanced tabular data according to claim 3, characterized in that, Methods for filtering data across all synthetic table samples include: S41. Input all samples from the tabular dataset and all synthetic tabular samples into the prediction contrast branch and project them onto the discriminant space. : ; Where h is the contrastive embedding feature vector obtained after the input sample is mapped by the prediction contrastive branch; For all samples in the tabular dataset and any sample from all synthetic tabular samples; It is the overall feature mapping function; It is a shared feature mapping function composed of a shared feature segmenter and a feature encoder; Projection functions are constructed for the projection multilayer perceptron and the prediction multilayer perceptron, respectively, to predict the contrast branch. The equals sign is defined to indicate that the variable on the left is derived from the expression on the right; S42, in the discriminant space In the process, calculate any two samples cosine distance: ; in, For the sample The cosine distance; For transpose; Let L be the L2 norm of the vector; S43. For the synthesized table sample, search for its value in the table dataset based on the cosine distance. The nearest neighbor; S44, in each synthetic table sample Among the nearest neighbors, if the majority class accounts for a greater than 100%, the majority class accounts for a greater than 100%. If so, the current composite table sample is removed, and the filtered composite table sample is obtained.
8. The method for processing unbalanced tabular data according to claim 1, characterized in that, The decoding module is based on samples from a tabular dataset. Its potential representation The correspondence between them is determined by minimizing the reconstruction error. The latent representation obtained from training recovers the mapping function. This is the decoding module.