A Class Imbalanced Sample Weighting Method and System for Anti-Fraud Models
By performing feature space structure analysis and weighted calculation on the anti-fraud sample set, a class-balanced weighted coefficient is generated, which solves the problem of class distribution imbalance in the anti-fraud model, improves the ability to identify minority class fraud samples, and enhances the fraud detection rate of the model.
Patent Information
- Application Number
- CN202611603988.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-16
- Publication Date
- 2026-11-17
AI Technical Summary
In anti-fraud applications in fields such as financial transactions and cybersecurity, the proportion of fraudulent behavior is extremely small, resulting in a class distribution imbalance between the majority and minority class samples in the training data. Existing methods cannot effectively identify minority fraud samples, leading to a low detection rate of anti-fraud models in actual deployment.
By acquiring an anti-fraud sample set, performing feature space structure parsing, generating neighborhood topology information of minority class samples and boundary contour information of majority class samples, calling a pre-built sample weighting coefficient generation model for joint weighting calculation, generating class balance weighting coefficients, and using these coefficients to weight the loss contribution, driving the anti-fraud model to shift towards the decision boundary of minority class sample units.
It achieves high-precision identification of minority class samples under extremely imbalanced conditions, improves the fraud detection rate of the anti-fraud model, and enhances the model's identification ability by driving the decision boundary to shift towards the minority class region through refined and structured sample weighted data.
Smart Images

Figure CN123118104A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of machine learning and anti-fraud detection technology, and more specifically, to a method and system for class-imbalanced sample weighting for anti-fraud models. Background Technology
[0002] In anti-fraud applications in fields such as financial transactions and cybersecurity, fraudulent behavior typically accounts for only a tiny proportion compared to legitimate behavior, leading to a severe class imbalance between majority and minority class samples in the training data. This imbalance causes anti-fraud models to allocate significant decision-making resources during training to fitting majority class samples, while significantly weakening their ability to identify minority fraudulent samples. Ultimately, this results in a low detection rate of fraudulent behavior when the anti-fraud model is deployed in practice.
[0003] Existing methods typically employ random oversampling or random undersampling strategies to simply adjust the number of samples, or directly set fixed class weight coefficients to uniformly correct the loss function. These methods treat samples as isolated data points in the feature space, ignoring the local geometric distribution characteristics of different classes of samples in the feature space and the differences in boundary morphology at the class boundaries. They cannot perform differentiated weighting based on the actual neighborhood distribution density and directional characteristics of minority class samples, as well as the boundary geometry between majority and minority class samples. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a class-imbalanced sample weighting method and system for anti-fraud models.
[0005] According to a first aspect of this application, a class-imbalanced sample weighting method for anti-fraud models is provided, the method comprising: Obtain an anti-fraud sample set, which includes majority class sample units and minority class sample units carrying fraud labels, and each sample unit corresponds to a set of original feature fields; The anti-fraud sample set is subjected to feature space structure parsing processing to generate neighborhood topology information of minority class sample units and boundary contour structure information of majority class sample units. The neighborhood topology information includes the neighborhood density distribution characteristics and neighborhood direction distribution characteristics of minority class sample units in the feature space. The boundary contour structure information includes the boundary geometric morphology characteristics at the intersection of majority class sample units and minority class sample units. The pre-built sample weighting coefficient generation model is invoked to perform joint weighting calculation on the neighborhood density distribution features, the neighborhood direction distribution features, and the boundary geometric features to generate the category balance weighting coefficients corresponding to each sample unit. The loss contribution of each sample unit in the anti-fraud sample set is weighted using the class balance weighting coefficient to obtain a weighted loss calculation dataset. The weighted loss calculation dataset is used to drive the anti-fraud model to shift towards the decision boundary of minority class sample units.
[0006] According to a second aspect of this application, a class-imbalanced sample weighting system for anti-fraud models is provided. The class-imbalanced sample weighting system for anti-fraud models includes a machine-readable storage medium and a processor. The machine-readable storage medium stores machine-executable instructions. When the processor executes the machine-executable instructions, the class-imbalanced sample weighting system for anti-fraud models implements the aforementioned class-imbalanced sample weighting method for anti-fraud models.
[0007] Based on any of the above aspects, the technical effect of this application is as follows: This application does not simply increase or decrease the number of majority and minority class samples or assign fixed weights. Instead, it first obtains a set of anti-fraud samples with fraud labels. Based on this, it performs structural analysis on the feature space, extracting the neighborhood topology information formed by the neighborhood density distribution and neighborhood direction distribution features of minority class sample units in the feature space, as well as the boundary contour structure information formed by the boundary geometry features at the intersection of majority and minority class sample units. This characterizes the spatial structural characteristics of the samples from two dimensions: local neighborhood distribution and class boundary geometry. Subsequently, a pre-built sample weighting coefficient generation model is used to jointly calculate the weights of the above three types of features, generating a class balance weighting coefficient corresponding to each sample unit. This ensures that the weight allocation can simultaneously reflect the sparsity and directionality of minority class samples as well as the complexity of the class boundary. Furthermore, the loss contribution weighting of each sample unit is weighted using the class-balanced weighting coefficients to form a weighted loss calculation dataset. This drives the anti-fraud model to actively shift the decision boundary towards the minority class sample region during training, thereby providing refined and structured sample weighted data for high-precision fraud detection under extreme imbalance conditions. Attached Figure Description
[0008] Figure 1 The diagram illustrates a flowchart of the class-imbalanced sample weighting method for anti-fraud models provided in this application embodiment.
[0009] Figure 2 This is a schematic diagram of the scenario of anti-fraud sample feature spatial distribution and neighborhood topological boundary contour analysis provided in the embodiments of this application.
[0010] Figure 3 This is a schematic diagram of the three-branch encoding and feature interaction fusion scenario of the sample weighting coefficient generation model provided in the embodiments of this application.
[0011] Figure 4 This is a schematic diagram of a multi-level training and validation closed-loop scenario for a weighted loss-driven anti-fraud model provided in this application embodiment. Detailed Implementation
[0012] Figure 1 This document illustrates a flowchart of a class-imbalanced sample weighting method for anti-fraud models provided in an embodiment of this application. Figure 2-4 As shown, this embodiment uses multi-source data anti-fraud model training as the application scenario. The anti-fraud sample set is collected from multiple data sources, including majority class sample units and minority class sample units carrying fraud labels. Each sample unit corresponds to a set of original feature data, which includes structured transaction feature fields, text description feature fields, image feature data, audio feature data, and time-series behavioral feature data. Structured transaction feature fields include continuous numerical fields such as transaction amount, transaction frequency, and account balance, as well as discrete category fields such as merchant category code, payment channel code, and device type identifier. Text description feature fields include unstructured text data such as transaction notes and user feedback text. Image feature data includes pixel matrix data such as transaction voucher images and user authentication images. Audio feature data includes waveform sampling sequences of user call recordings. Time-series behavioral feature data includes time-dimensional data such as user login timestamp sequences and page browsing duration sequences. Fraud labels are either positive or negative sample labels, with positive labels corresponding to fraudulent transactions and negative labels corresponding to normal transactions. The total number of sample units is N, with N1 representing fraudulent transactions and N2 representing legitimate transactions. N1 is much smaller than N2. All data sources for the anti-fraud sample set have undergone data anonymization processing, and facial and voiceprint information in image and audio data has been de-identified, complying with data security compliance requirements.
[0013] Step S110: Obtain an anti-fraud sample set, which includes majority class sample units and minority class sample units carrying fraud labels, and each sample unit corresponds to a set of original feature fields.
[0014] The anti-fraud sample set is extracted from multi-source databases. A unified query interface is used to retrieve labeled transaction records and associated multimodal data within a preset time range. For each sample unit, structured transaction feature fields are stored directly as numerical vectors, text description feature fields are stored as word embedding vector sequences, image feature data is stored as a three-dimensional pixel matrix, audio feature data is stored as a Mel-frequency cepstral coefficient matrix, and time-series behavioral feature data is stored as a multivariate time series matrix. The raw feature data of all sample units are grouped and stored in a sample data dictionary according to data type. The key of the sample data dictionary is the sample unit identifier, and the value is a nested dictionary structure containing raw feature data of each type.
[0015] Step S120: Perform feature space structure parsing processing on the anti-fraud sample set to generate neighborhood topology information of minority class sample units and boundary contour structure information of majority class sample units. The neighborhood topology information includes neighborhood density distribution features and neighborhood direction distribution features of minority class sample units in the feature space. The boundary contour structure information includes boundary geometric features at the intersection of majority class sample units and minority class sample units.
[0016] For each sample unit in the anti-fraud sample set obtained in step S110, the various original feature data are mapped to a uniform-dimensional numerical feature vector using corresponding feature extractors. Structured transaction feature fields are mapped to d-dimensional numerical feature vectors through a fully connected feature mapping network. Text description feature fields are mapped to d-dimensional numerical feature vectors through a pre-trained text encoder, which employs an attention-based Transformer encoder architecture and uses the average pooling output of the last encoder layer as the text feature vector. Image feature data are mapped to d-dimensional numerical feature vectors through a pre-trained convolutional neural network, which employs a residual network architecture and uses the output of the global average pooling layer as the image feature vector. Audio feature data are mapped to d-dimensional numerical feature vectors through a pre-trained audio encoder, which employs a multi-layer one-dimensional convolutional network architecture and uses the global average pooling result of the last convolutional layer as the audio feature vector. Temporal behavior feature data are mapped to d-dimensional numerical feature vectors through a gated recurrent unit network, using the hidden state of the last time step as the temporal feature vector. The d-dimensional feature vectors output by various types of feature extractors are concatenated along the channel dimension to obtain a unified feature vector with a dimension of 5d. The unified feature vectors of all sample units constitute a feature space point set. Based on this feature space point set, feature space structure parsing processing is performed to generate neighborhood topology information and boundary contour structure information through steps S121 to S128.
[0017] For example, such as Figure 2As shown, each sample unit in the anti-fraud sample set is mapped to a two-dimensional feature space consisting of feature dimension 1 and feature dimension 2. In this two-dimensional feature space, majority class sample units are represented by densely distributed solid dots, while minority class sample units are represented by sparsely distributed hollow circles. By traversing this two-dimensional feature space, the connection relationship between minority class sample units and their nearest neighbors is identified, thereby extracting neighborhood density distribution features and neighborhood direction distribution features that reflect the local neighborhood structure. The extraction of neighborhood direction distribution features is reflected as connection vectors radiating outwards from the target sample in all directions. Simultaneously, Figure 2 The boundary line between the majority class sample units and the minority class sample units is also shown. This boundary line is composed of multiple black dashed line segments. Based on the difference in sample distribution on both sides of the boundary line, the boundary contour structure information reflecting the geometric shape of the two classes of samples at the interface is extracted.
[0018] Step S121: Extract the neighbor sample distribution information of each minority class sample unit in the anti-fraud sample set in the feature space. The neighbor sample distribution information includes a set of neighbor sample identifiers centered on the minority class sample unit within a preset nearest neighbor range.
[0019] For each minority class sample unit x, calculate the cosine distance between the uniform feature vector of that minority class sample unit and the uniform feature vectors of all other sample units in the feature space. The cosine distance dcos(a, b) = 1 - (a·b) ÷ (||a|| × ||b||), where a·b is the vector dot product and ||a|| is the L2 norm of the vector. The K sample units with the smallest cosine distance are selected as the nearest neighbors of that minority class sample unit. The neighbor sample identifier set contains the sample unit identifiers and fraud labels of these K nearest neighbors. K takes a preset nearest neighbor parameter value.
[0020] Step S122: Calculate the original neighborhood density value corresponding to the minority class sample unit based on the number of neighbor samples belonging to the minority class sample unit in the neighbor sample identifier set, and normalize the original neighborhood density value to generate a dimensionless neighborhood density distribution feature.
[0021] Suppose that the neighboring sample identifier set of a minority class sample unit x contains K1 minority class sample units. The original neighborhood density value d0 = K1 ÷ K. Calculate the original neighborhood density values of all minority class sample units in the anti-fraud sample set, and calculate the mean m1 and standard deviation s1. The dimensionless neighborhood density distribution characteristic is d1 = (d0 - m1) ÷ s1.
[0022] Step S123: Construct the connection direction vector between the minority class sample unit and each neighbor sample in its neighbor sample identifier set. The connection direction vector is obtained by subtracting the feature fields of the minority class sample unit from the feature fields of its neighbor samples dimension by dimension.
[0023] Let f be the uniform feature vector of minority class sample unit x, and g be the uniform feature vector of neighbor sample y. The connection direction vector is v = fg. For all K neighbor samples in the neighbor sample identifier set, the connection direction vector is calculated, resulting in a set of connection direction vectors V = {v1, v2, ..., vK}.
[0024] Step S124: Perform principal direction decomposition on the set of connection direction vectors, extract the direction component with the largest variance in the set of connection direction vectors, and normalize the direction component to generate neighborhood direction distribution features.
[0025] Calculate the covariance matrix C = (1 / K) × Σ(j=1 to K)vj × (vj)^T for all vectors in the set of connection direction vectors V, where (vj)^T represents the transpose of vector vj. Perform eigenvalue decomposition on C: C = Q × Λ × Q^T, where Q is the eigenvector matrix and Λ is the eigenvalue diagonal matrix. Extract the eigenvector corresponding to the largest eigenvalue in Λ as the principal direction component p. Perform L2 norm normalization on p, resulting in the normalized vector u = p ÷ ||p||, where ||p|| = (Σ(m=1 to 5d)pm²)^0.5, and pm is the m-th component of p. u represents the neighborhood direction distribution feature of this minority class sample unit, with a dimension of 5d.
[0026] Step S125: Traverse each majority class sample unit in the anti-fraud sample set, identify whether the neighbor sample identifier set of the majority class sample unit contains minority class sample units. If the neighbor sample identifier set of the majority class sample unit contains minority class sample units, mark the majority class sample unit as a boundary majority class sample unit, and extract the feature difference vector between the boundary majority class sample unit and the included minority class sample units.
[0027] For each majority class sample unit, its K nearest neighbor samples are calculated in the same way as in step S121. If at least one minority class sample unit is among the K nearest neighbor samples, then the majority class sample unit is marked as a boundary majority class sample unit. For this boundary majority class sample unit, the feature difference vector is calculated for the minority class sample unit with the smallest cosine distance among its nearest neighbors. Let the uniform feature vector of the boundary majority class sample unit be h, the uniform feature vector of the corresponding minority class sample unit be f, and the feature difference vector w = hf.
[0028] Step S126: Perform clustering processing on the feature difference vectors corresponding to all boundary majority class sample units in the anti-fraud sample set to obtain a set of difference vector cluster centers. Each cluster center vector in the set of difference vector cluster centers is used to describe a boundary geometric feature at the intersection of majority class sample units and minority class sample units.
[0029] Collect the feature difference vectors of all boundary majority class sample units, forming a set of difference vectors W = {w1, w2, ..., wB}, where B is the number of boundary majority class sample units. Perform K-means clustering on W, setting the number of clusters to a preset value C. Randomly initialize C cluster center vectors and iteratively execute sample allocation and center update steps: the sample allocation step assigns each feature difference vector to the cluster center with the smallest Euclidean distance; the center update step updates each cluster center to the arithmetic mean of all assigned feature difference vectors. Iterate until the change in cluster centers is less than a convergence threshold. After clustering, obtain C cluster center vectors {r1, r2, ..., rC}, where each r has a dimension of 5d.
[0030] Step S127: Extract the normalized direction vector and the dimensionless magnitude ratio of each cluster center vector in the set of difference vector cluster centers, and use the normalized direction vector and magnitude ratio as the structured components of the boundary geometric features to generate boundary contour structure information.
[0031] For each cluster center vector r, calculate its L2 norm t = ||r|| = (Σ(m=1 to 5d)rm²)^0.5, where rm is the m-th component of r. The normalized direction vector e = r ÷ t. Calculate the mean of all C moduli: m² = (1 / C) × Σ(k=1 to C)tk. The dimensionless moduli ratio z = t ÷ m². Use e and z as structured components of the boundary geometry corresponding to the cluster center. All C pairs (e, z) constitute the boundary contour structure information.
[0032] Step S128: Combine the normalized neighborhood density distribution features and the unitized neighborhood orientation distribution features of all minority class sample units into neighborhood topology information.
[0033] For each minority class sample unit in the anti-fraud sample set, the d1 generated in step S122 and the u generated in step S124 are combined to form the neighborhood topology information element of that sample unit. The neighborhood topology information elements of all minority class sample units constitute the neighborhood topology structure information.
[0034] Step S130: Call the pre-built sample weighting coefficient generation model to perform joint weighting calculation on the neighborhood density distribution features, the neighborhood direction distribution features and the boundary geometric features to generate the category balance weighting coefficients corresponding to each sample unit.
[0035] The pre-built sample weighting coefficient generation model is a multi-branch neural network, which includes a first branch network, a second branch network, a third branch network, a feature interaction layer, a fully connected fusion layer, and a coefficient output layer. The class-balanced weighting coefficients corresponding to each sample unit are generated through steps S131 to S137.
[0036] For example, such as Figure 2 As shown, the sample weighted coefficient generation model employs a three-branch encoding structure and a cross-attention mechanism. Neighborhood density distribution features are input into the first branch network, processed by density-aware encoding to generate a density-aware encoded vector; neighborhood orientation distribution features are input into the second branch network, processed by orientation-aware encoding to generate an orientation-aware encoded vector; and boundary geometric features are input into the third branch network, processed by morphology-aware encoding to generate a morphology-aware encoded vector. These three encoded vectors are then input into a feature interaction layer, where they are fused pairwise through a cross-attention mechanism. During this interaction, attention weight allocation results for density-direction interaction, density-morphology interaction, and orientation-morphology interaction are generated, thus achieving joint weighted calculation of the three types of features. The fused multi-source features are concatenated into a multi-source fused feature vector by a fully connected fusion layer, then compressed into a compressed fused feature vector by a feature compression layer. Finally, the activation function of the coefficient output layer maps and generates class-balanced weighted coefficients for each sample unit, and relative weighting adjustments are made based on the distribution comparison of the class-balanced weighted coefficients.
[0037] Step S131: Input the normalized neighborhood density distribution features into the first branch network of the sample weighted coefficient generation model, and perform density-aware encoding processing on the neighborhood density distribution features through the nonlinear mapping layer of the first branch network to generate a density-aware encoding vector.
[0038] The first branch network consists of three fully connected layers, each followed by batch normalization and a linear rectified activation function. The input is a scalar d1. The first layer maps the scalar to a d2-dimensional vector, the second layer to a d3-dimensional vector, and the third layer to a d4-dimensional vector. The output of the third layer is the density-aware encoding vector a1, with a dimension of d4.
[0039] Step S132: Input the neighborhood orientation distribution features after normalization into the second branch network of the sample weighted coefficient generation model, and perform orientation-aware encoding processing on the neighborhood orientation distribution features through the orientation encoding layer of the second branch network to generate orientation-aware encoding vectors.
[0040] The second branch network consists of three fully connected layers, with the same structure as the first branch network. The input is a 5d-dimensional vector u, which is mapped by the three fully connected layers to a d4-dimensional direction-aware encoding vector a2.
[0041] Step S133: Input the dimensionless boundary geometric features into the third branch network of the sample weighted coefficient generation model, and perform morphological-aware encoding on the structured components of the boundary geometric features through the morphological encoding layer of the third branch network to generate a morphological-aware encoding vector.
[0042] The third branch network receives the structured components of the boundary geometric features. For C pairs (e, z) in the boundary contour structure information, the normalized direction vector e and the magnitude ratio z of each pair are concatenated into a vector of dimension (5d+1), which is then input into the third branch network. The third branch network consists of three fully connected layers. The input dimension is (5d+1), and the three fully connected layers map it to a vector of dimension d4. The C vectors are then averaged to obtain the morphologically aware encoding vector a3 of dimension d4.
[0043] Step S134: After scaling the density-aware encoding vector, the orientation-aware encoding vector, and the morphology-aware encoding vector, input them into the feature interaction layer of the sample weighting coefficient generation model. Through the cross-attention mechanism of the feature interaction layer, the three are fused in pairs to generate density-orientation interaction vector, density-morphology interaction vector, and orientation-morphology interaction vector.
[0044] Scale alignment processing involves normalizing a1, a2, and a3 through layer normalization to obtain feature vectors with consistent scale. The feature interaction layer contains three parallel cross-attention units. The first cross-attention unit uses a1 as the query vector, a2 as the key vector and value vector, calculates attention weights, and sums them to output a density-direction interaction vector b1. The second cross-attention unit uses a1 as the query vector, a3 as the key vector and value vector, and outputs a density-morphology interaction vector b2. The third cross-attention unit uses a2 as the query vector, a3 as the key vector and value vector, and outputs a direction-morphology interaction vector b3. In the cross-attention calculation, the attention weight α = softmax(Q × K^T ÷ dk^0.5), where Q is the query vector, K is the key vector, dk is the dimension of the key vector, and the output is a weighted sum of the attention weights and the value vector.
[0045] Step S135: Input the density-aware encoding vector, the direction-aware encoding vector, the morphology-aware encoding vector, the density-direction interaction vector, the density-morphology interaction vector, and the direction-morphology interaction vector into the fully connected fusion layer of the sample weighting coefficient generation model for element-wise concatenation to obtain a multi-source fusion feature vector. Perform feature compression processing on the multi-source fusion feature vector through the layer-by-layer nonlinear transformation of the fully connected fusion layer to generate a compressed fusion feature vector. The dimension of the compressed fusion feature vector is lower than the dimension of the multi-source fusion feature vector.
[0046] The six vectors a1, a2, a3, b1, b2, and b3 are concatenated along their dimensional directions to obtain a multi-source fusion feature vector of dimension 6×d4. The fully connected fusion layer consists of two fully connected layers. The first layer maps dimension 6×d4 to dimension d5, and the second layer maps dimension d5 to dimension d6, where d6 < 6×d4. Each layer is followed by a linear rectified activation function. The output of the second layer is the compressed fusion feature vector of dimension d6.
[0047] Step S136: Input the compressed fusion feature vector into the coefficient output layer of the sample weighting coefficient generation model, and map the compressed fusion feature vector to a preset numerical range through the activation function mapping process of the coefficient output layer to generate the initial weighting coefficient corresponding to the sample unit.
[0048] The coefficient output layer consists of a fully connected layer and a sigmoid growth curve activation function. The fully connected layer maps the compressed fusion feature vector of dimension d6 to a scalar value, and the sigmoid growth curve activation function maps this scalar value to the interval (0, 1) to obtain the initial weighting coefficients q1.
[0049] Step S137: Obtain the statistical center value of the initial weighting coefficients of all majority class sample units in the anti-fraud sample set, and calculate the relative weighting adjustment factor corresponding to the sample unit based on the dimensionless ratio of the statistical center value to the initial weighting coefficient corresponding to the sample unit. Multiply the initial weighting coefficient corresponding to the sample unit by the relative weighting adjustment factor to obtain the class balance weighting coefficient corresponding to the sample unit.
[0050] Calculate the median q2 of the initial weighting coefficients for all majority class sample units as the statistical center value. For that sample unit, the relative weighting adjustment factor q3 = q2 ÷ q1. If the sample unit is a minority class sample unit, then q3 is greater than 1, increasing its weighting coefficient. The class-balanced weighting coefficient q4 = q1 × q3.
[0051] Step S140: Use the class balance weighting coefficient to perform loss contribution weighting on each sample unit in the anti-fraud sample set to obtain a weighted loss calculation dataset. The weighted loss calculation dataset is used to drive the anti-fraud model to shift towards the decision boundary of minority class sample units.
[0052] Based on the class balance weighting coefficients of each sample unit generated in step S130, the loss calculation in the anti-fraud model training process is weighted, which is achieved through steps S141 to S144.
[0053] Step S141: Obtain the fraud prediction probability value output by each sample unit in the anti-fraud sample set during the forward propagation of the anti-fraud model, and calculate the original loss contribution value corresponding to each sample unit based on the fraud category label of each sample unit and the fraud prediction probability value.
[0054] The anti-fraud model is a multi-layer neural network classifier. For each sample unit, the anti-fraud model outputs a fraud prediction probability value s1. The original loss contribution value L1=-[y×log(s1)+(1-y)×log(1-s1)], where y is the fraud category label, y=1 for fraud samples and y=0 for normal samples.
[0055] Step S142: Multiply the category balance weighting coefficient corresponding to each sample unit by the original loss contribution value corresponding to that sample unit to obtain the weighted loss contribution value corresponding to that sample unit. Summarize the weighted loss contribution values of all sample units in the anti-fraud sample set into a weighted loss contribution value set.
[0056] The weighted loss contribution value L2 = q4 × L1. L2 is calculated for all sample units in the anti-fraud sample set to obtain the weighted loss contribution value set {L21, L22, ..., L2N}.
[0057] Step S143: Sum all weighted loss contribution values in the set of weighted loss contribution values to obtain the batch weighted total loss value. Use the batch weighted total loss value as the basis for gradient calculation of backpropagation of the anti-fraud model. Calculate the partial derivatives of the batch weighted total loss value with respect to the parameters of each layer of the anti-fraud model through the backpropagation algorithm.
[0058] The batch-weighted total loss value L3 = (1 / N) × Σ(i=1 to N)L2i. Calculate the partial derivatives of L3 with respect to the weight parameters θ1 of each layer of the anti-fraud model. The chain rule is used to perform backpropagation calculations layer by layer.
[0059] Step S144: Update the parameters of each layer of the anti-fraud model according to the partial derivatives to complete one training iteration. Combine the updated fraud prediction probability value of each sample unit output by the anti-fraud model after this training iteration with the original feature field to form a weighted loss calculation data unit in the weighted loss calculation dataset. The weighted loss calculation data unit is used for weighted loss contribution calculation in the next training iteration.
[0060] The adaptive moment estimation optimizer is used to update the network weight parameters of each layer of the anti-fraud model: η is the preset learning rate, and Adam is the adaptive moment estimation update function. After the update, the anti-fraud model re-propagates forward for each sample unit, outputting the updated fraud prediction probability value s2. The original feature fields, s2, and q4 are combined into a weighted loss calculation data unit and stored in the weighted loss calculation dataset.
[0061] Step S210: Perform sample grouping and partitioning processing on the anti-fraud sample set, dividing the anti-fraud sample set into multiple sample groups, each sample group containing some majority class sample units and some minority class sample units.
[0062] All N sample units in the anti-fraud sample set are randomly shuffled and uniformly divided according to a preset number of groups G. Each sample group contains N ÷ G sample units, where the ratio of majority class sample units to minority class sample units remains consistent with the ratio in the original anti-fraud sample set. During grouping, priority is given to ensuring that each sample group contains at least a preset minimum number of minority class sample units. If a sample group has insufficient minority class sample units, they are randomly transferred from adjacent sample groups to supplement it.
[0063] Step S220: Perform the feature space structure parsing process on each sample group to obtain the group neighborhood topology information and group boundary contour information corresponding to each sample group. Input the group neighborhood topology information and group boundary contour information of each sample group into the sample weighting coefficient generation model to generate the group category balanced weighting coefficients corresponding to the sample units within each sample group.
[0064] For the g-th sample group, all sample units within the sample group are treated as independent sample sets. The group neighborhood topology and group boundary contour information corresponding to this sample group are generated according to steps S121 to S128. This group neighborhood topology and group boundary contour information are then input into the pre-built sample weighting coefficient generation model in step S130. The group category balanced weighting coefficients corresponding to each sample unit within the sample group are generated according to steps S131 to S137.
[0065] Step S230: Use the group category balance weighting coefficient corresponding to each sample group to perform loss contribution weighting processing on the sample units within the sample group to obtain the group weighted loss calculation subset. Merge all the group weighted loss calculation subsets into a global weighted loss calculation dataset. The global weighted loss calculation dataset is used to drive the decision boundary shift of the anti-fraud model under the group training strategy.
[0066] For each sample unit within the g-th sample group, its group category balancing weighting coefficient is used to perform loss contribution weighting processing according to steps S141 to S144, generating a group-weighted loss calculation subset corresponding to that sample group. All G group-weighted loss calculation subsets are merged into a complete global weighted loss calculation dataset for use by the anti-fraud model in this training batch.
[0067] Step S240: After the preset group training rounds, the anti-fraud sample set is re-divided into sample groups. The re-divided sample groups have different sample composition structures than the sample groups in the previous group training rounds.
[0068] After a pre-defined training round E1, the anti-fraud sample set is randomly shuffled and regrouped. Because the seeds for each shuffle are different, the composition of sample units in the regrouped samples differs from the corresponding sample groups in the previous training round. This dynamic grouping strategy allows each sample unit to interact with different neighboring samples at different training stages, enhancing the diversity of neighborhood topological and boundary contour information.
[0069] Step S250: Iteratively execute the feature space structure parsing process, group category weighting coefficient generation, and group weighted loss calculation sub-dataset construction operations using the re-divided sample groups until the anti-fraud model reaches the preset training termination condition.
[0070] After regrouping the samples, steps S220 to S230 are executed again to generate a new global weighted loss calculation dataset and drive the anti-fraud model to continue training. The samples are regrouped every E1 training epochs, and this process is repeated until the recall rate of the minority class samples on the validation set exceeds a preset threshold, or the number of training epochs reaches the preset maximum number of training epochs E2. Training is terminated when either condition is met.
[0071] Step S310: Obtain the original feature field of each minority class sample unit in the anti-fraud sample set, and perform feature perturbation processing on the original feature field of each minority class sample unit. The feature perturbation processing is achieved by applying random perturbation values that follow a preset probability distribution to each dimension of the original feature field.
[0072] For each minority class sample unit in the anti-fraud sample set, extract its uniform feature vector f. Generate a random perturbation vector δ with the same dimension as f. Each component of δ is independently sampled from a normal distribution N(0, σ1²) with a mean of 0 and a standard deviation of σ1, where σ1 is a preset perturbation strength parameter. The perturbed feature vector is f1 = f + δ.
[0073] Step S320: The minority class sample units after the feature perturbation processing are taken as new minority class sample units, and the new minority class sample units are added to the anti-fraud sample set to obtain an expanded anti-fraud sample set. The feature space structure parsing processing is performed on the expanded anti-fraud sample set to generate expanded sample neighborhood topology information and expanded sample boundary contour structure information.
[0074] The perturbation-generated f1 is used as the unified feature vector of the newly generated minority class sample unit, and its fraud label is the same as that of the original minority class sample unit. All newly generated minority class sample units are added to the anti-fraud sample set, resulting in an expanded anti-fraud sample set with a total number of samples of N + N1 × R, where R is the number of newly generated samples for each minority class sample unit. The expanded anti-fraud sample set is then processed according to steps S121 to S128 to generate expanded sample neighborhood topology information and expanded sample boundary contour structure information.
[0075] Step S330: Input the expanded sample neighborhood topology information and the expanded sample boundary contour information into the sample weighting coefficient generation model to generate the expanded weighting coefficients corresponding to each sample unit in the expanded anti-fraud sample set. Based on the expanded weighting coefficients, perform loss contribution weighting processing on each sample unit in the expanded anti-fraud sample set to obtain the expanded weighted loss calculation dataset.
[0076] The expanded sample neighborhood topology information and expanded sample boundary contour information are input into the sample weighting coefficient generation model, and the expanded weighting coefficients are generated according to steps S131 to S137. The expanded weighting loss calculation dataset is calculated according to steps S141 to S144.
[0077] Step S340: Use the augmented weighted loss calculation dataset to perform a complete training cycle on the anti-fraud model to obtain an intermediate anti-fraud model. Extract difficult-to-classify sample units with classification confidence below a preset threshold from the prediction results of the intermediate anti-fraud model on the augmented anti-fraud sample set. The difficult-to-classify sample units include misclassified minority class sample units and misclassified majority class sample units.
[0078] The anti-fraud model E is trained for 3 epochs using an augmented weighted loss dataset to obtain an intermediate-state anti-fraud model. The augmented anti-fraud sample set is then input into the intermediate-state model to obtain the fraud prediction probability value s for each sample unit. The classification confidence is set to |s-0.5|, which is the absolute difference between the predicted probability value and 0.5. Sample units with a classification confidence value below a preset threshold τ1 are labeled as difficult-to-classify sample units. Among the difficult-to-classify sample units, those with a fraud prediction probability value s greater than 0.5 but a true label of normal sample are misclassified majority class sample units, while those with s less than 0.5 but a true label of fraud sample are misclassified minority class sample units.
[0079] Step S350: Perform the feature perturbation process again on the minority class sample units in the difficult sample units, and supplement the newly generated minority class sample units into the sample set used in the current training batch to form an iterative expanded sample set. Re-input the iterative expanded sample set into the intermediate anti-fraud model for the next round of training to obtain the updated anti-fraud model parameters until the proportion of difficult sample units in the expanded anti-fraud sample set is lower than the preset termination ratio.
[0080] For minority class sample units among the hard-to-distinguish sample units, the feature perturbation processing of step S310 is performed again. The perturbation intensity parameter σ1 is multiplied by the attenuation coefficient ρ to obtain the new perturbation intensity, where ρ takes a value between 0 and 1. The newly generated minority class sample units are added to the current sample set to form an iteratively expanded sample set. The intermediate anti-fraud model is trained again for E4 epochs using the iteratively expanded sample set. After training, the proportion of hard-to-distinguish sample units is recalculated. If the proportion is higher than the preset termination proportion τ2, the iteration continues to execute steps S340 to S350; if the proportion is lower than τ2, the iteration is terminated, and the current anti-fraud model parameters are saved.
[0081] Step S410: Construct a multi-level feature extraction structure for the anti-fraud model. The multi-level feature extraction structure includes a shallow feature extraction layer, a middle feature extraction layer, and a deep feature extraction layer. The shallow feature extraction layer is used to extract basic feature representations from the original feature fields of the sample units. The middle feature extraction layer is used to extract combined feature representations from the basic feature representations. The deep feature extraction layer is used to extract abstract semantic feature representations from the combined feature representations.
[0082] The anti-fraud model employs a three-layer feature extraction structure. The shallow feature extraction layer consists of two fully connected layers, taking the uniform feature vector of the sample unit as input (dimension 5d) and outputting the basic feature representation h1 (dimension d7). The middle feature extraction layer consists of two fully connected layers, taking h1 as input and outputting the combined feature representation h2 (dimension d8). The deep feature extraction layer consists of two fully connected layers, taking h2 as input and outputting the abstract semantic feature representation h3 (dimension d9).
[0083] Step S420: Insert a first category-balanced weighting module between the shallow feature extraction layer and the middle feature extraction layer. The first category-balanced weighting module is used to receive the basic feature representation output by the shallow feature extraction layer, and perform element-wise weighting processing on the basic feature representation based on the category-balanced weighting coefficients of the sample units corresponding to the basic feature representation to obtain the shallow weighted feature representation.
[0084] The first category-balanced weighting module receives h1 and the category-balanced weighting coefficient q4 for the sample unit. The shallow-weighted feature representation is h1w = h1 × q4, and the multiplication is element-wise multiplication, multiplying each element of h1 by q4.
[0085] Step S430: Insert a second category-balanced weighting module between the intermediate feature extraction layer and the deep feature extraction layer. The second category-balanced weighting module is used to receive the combined feature representation output by the intermediate feature extraction layer, and perform element-wise weighting processing on the combined feature representation based on the category-balanced weighting coefficients of the sample units corresponding to the combined feature representation to obtain the intermediate-weighted feature representation.
[0086] The second-class balanced weighting module receives h2 and q4. The intermediate-level weighted feature representation is h2w = h2 × q4.
[0087] Step S440: Insert a third category balance weighting module after the deep feature extraction layer. The third category balance weighting module is used to receive the abstract semantic feature representation output by the deep feature extraction layer, and perform element-wise weighting processing on the abstract semantic feature representation based on the category balance weighting coefficient of the sample unit corresponding to the abstract semantic feature representation to obtain the deep weighted feature representation.
[0088] The third category of balanced weighted modules receives h3 and q4. The deep weighted feature representation is h3w = h3 × q4.
[0089] Step S450: Input the shallow weighted feature representation into the middle-layer feature extraction layer for further feature transformation processing to obtain a shallow weighted combined feature representation. Then, perform element-wise addition and fusion processing on the shallow weighted combined feature representation and the middle-layer weighted feature representation to obtain a middle-layer fused feature representation. Input the middle-layer fused feature representation into the deep feature extraction layer for further feature transformation processing to obtain a middle-layer weighted abstract semantic feature representation. Then, perform element-wise addition and fusion processing on the middle-layer weighted abstract semantic feature representation and the deep weighted feature representation to obtain a deep fused feature representation.
[0090] Inputting h1w into the middle-layer feature extraction layer yields a shallowly weighted combined feature representation h2p. The middle-layer fusion feature representation h2f = h2p + h2w, with element-wise addition. Inputting h2f into the deep feature extraction layer yields a middle-layer weighted abstract semantic feature representation h3p. The deep fusion feature representation h3f = h3p + h3w.
[0091] Step S460: Input the deep fusion feature representation into the classification output layer of the anti-fraud model. Through the fully connected mapping and probability normalization processing of the classification output layer, output the hierarchical weighted fraud prediction probability value corresponding to each sample unit. Calculate the hierarchical weighted loss contribution value based on the hierarchical weighted fraud prediction probability value and the fraud category label of the corresponding sample unit. Based on the hierarchical weighted loss contribution value, perform joint parameter updates on the multi-level feature extraction structure, the first category balanced weighting module, the second category balanced weighting module, the third category balanced weighting module, and the classification output layer.
[0092] The classification output layer consists of a fully connected layer and a normalized exponential function. The fully connected layer maps h3f to a 2D vector, and the normalized exponential function converts the 2D vector into a fraud prediction probability value s3. The layer-weighted loss contribution value L4 = -[y×log(s3) + (1-y)×log(1-s3)]. The partial derivatives of L4 with respect to the weight parameters of each layer are calculated, and the parameters of all layers are updated through backpropagation.
[0093] For example, during the weighted loss calculation and multi-level training process in steps S140 to S460, such as Figure 4As shown, the anti-fraud model comprises shallow feature extraction layers, mid-level feature extraction layers, and deep feature extraction layers. For different feature extraction layers, first-class balanced weighting modules, second-class balanced weighting modules, and third-class balanced weighting modules are inserted respectively. These weighting modules receive corresponding class balanced weighting coefficients to achieve weighted fusion of feature representations from each layer. During the training phase, the anti-fraud model outputs fraud prediction probability values during forward propagation, which are combined with the true annotations of the samples and fed into the loss contribution weighting calculation module. The weighted loss values are aggregated into a batch-weighted total loss value, which then drives backpropagation gradient updates, completing the optimization of network parameters.
[0094] During training, such as Figure 4 As shown, the validation sample set is continuously input into the model for prediction results and classification accuracy evaluation. For the misclassified minority class sample set, its misclassification boundary features are extracted, and the sample weighting coefficient generation model is fine-tuned to generate updated validation weighting coefficients. Subsequently, incremental training is performed to update the classification decision layer parameters. During training, classification accuracy is continuously compared. When performance improves, parameters are retained; when performance does not improve, parameters are rolled back, forming a closed loop of validation and incremental tuning. Simultaneously, during training, hard-to-classify sample units are extracted, and feature perturbation processing is applied to them to generate new minority class sample units, which are added to the iteratively expanded sample set and used as input for the next round of training to continue participating in model training. Thus, by utilizing the periodic weighting coefficient dynamic adjustment mechanism, the anti-fraud model's ability to identify minority class fraud samples is continuously optimized.
[0095] Step S510: Obtain the original feature fields of each sample unit in the anti-fraud sample set, and perform feature reorganization processing on the original feature fields of each sample unit. The feature reorganization processing includes dividing the original feature fields of each sample unit into multiple feature field groups according to the feature semantic category. Each feature field group contains several feature dimensions with the same semantic category.
[0096] For each sample unit's unified feature vector, it is divided into 5 feature field groups according to the feature source type: the structured transaction feature field group corresponds to vector dimensions 1 to d, the text description feature field group corresponds to vector dimensions d+1 to 2d, the image feature field group corresponds to vector dimensions 2d+1 to 3d, the audio feature field group corresponds to vector dimensions 3d+1 to 4d, and the time-series behavior feature field group corresponds to vector dimensions 4d+1 to 5d. Each feature field group contains d feature dimensions.
[0097] Step S520: Perform the feature space structure parsing process on each feature field group to generate the field group neighborhood topology information and field group boundary contour structure information corresponding to each feature field group.
[0098] For the t-th feature field group, extract the d-dimensional sub-vectors corresponding to the feature field group for all sample units in the anti-fraud sample set, forming a sub-feature space for the feature field group. In this sub-feature space, generate the neighborhood topology information and the boundary contour structure information of the field group according to the methods in steps S121 to S128.
[0099] Step S530: Based on the neighborhood topology information and boundary contour information of each feature field group, generate the field group weighting coefficients corresponding to each feature field group using the sample weighting coefficient generation model. Concatenate all the field group weighting coefficients of the same sample unit to obtain the multi-field group weighting coefficient vector corresponding to the sample unit. The dimension of the multi-field group weighting coefficient vector is equal to the number of feature field groups into which the sample unit is divided.
[0100] The neighborhood topology and boundary contour information of the t-th feature field group are input into the sample weighted coefficient generation model to generate the weighted coefficient qt for that feature field group. The weighted coefficients of the five field groups in the same sample unit are concatenated into a multi-field weighted coefficient vector qvec=[q1, q2, q3, q4, q5] with a dimension of 5.
[0101] Step S540: Using the multi-field group weighted coefficient vector, the feature dimensions belonging to different feature field groups in the original feature fields of the sample unit are grouped and weighted to generate the field group weighted feature vector corresponding to the sample unit. The feature dimensions within the same feature field group in the field group weighted feature vector share the field group weighted coefficients corresponding to that feature field group.
[0102] The d-dimensional sub-vector corresponding to the t-th feature field group in the weighted feature vector f2 is the original d-dimensional sub-vector multiplied by qt. The dimension of f2 is the same as the original unified feature vector, which is 5d. The d feature dimensions within the same feature field group share the same weighting coefficient qt.
[0103] Step S550: Construct a field-weighted sample set by the field-group weighted feature vectors of all sample units in the anti-fraud sample set, and use the field-group weighted sample set to train the anti-fraud model. During the training process, the anti-fraud model performs forward propagation calculation and backward gradient update based on the field-group weighted feature vectors.
[0104] The weighted feature vector f2 of all sample units is used as input to replace the original unified feature vector. This vector is then input into the anti-fraud model for forward propagation to calculate the loss value. Finally, the network weight parameters of the anti-fraud model are updated through backpropagation.
[0105] Step S560: After each training batch is completed, based on the classification error feedback of the anti-fraud model on the samples of the current batch, the weighting coefficients of the field groups corresponding to each feature field group are adaptively adjusted. The adaptive adjustment is achieved by increasing the weighting coefficients of the field groups corresponding to the feature field groups with larger classification errors and decreasing the weighting coefficients of the field groups corresponding to the feature field groups with smaller classification errors.
[0106] Calculate the absolute value of the classification error e = |ys| for each sample unit in the current batch. For the t-th feature field group, calculate the Pearson correlation coefficient between the weighted coefficient qt corresponding to this feature field group and the classification error e. If the correlation coefficient is positive and exceeds a preset positive threshold, multiply the weighted coefficient of this feature field group by an amplification factor γ1, where γ1 is greater than 1; if the correlation coefficient is negative and its absolute value exceeds a preset negative threshold, multiply the weighted coefficient of this feature field group by a reduction factor γ2, where γ2 is between 0 and 1. The updated weighted coefficients are used for training the next batch.
[0107] Step S610: During the training of the anti-fraud model, the internal representation information of the model in the current training state is periodically extracted. The internal representation information of the model includes a set of feature embedding vectors output by the hidden layer of the anti-fraud model. Each feature embedding vector in the set of feature embedding vectors corresponds to a sample unit in the anti-fraud sample set.
[0108] Every E5 training epochs, all sample units in the anti-fraud sample set are input into the anti-fraud model in the current state, and the feature embedding vector output by the last hidden layer of the anti-fraud model is extracted. For each sample unit, the dimension of this feature embedding vector is d9, taken from h3 output by the deep feature extraction layer in step S410. The feature embedding vectors of all sample units constitute the feature embedding vector set H={h31, h32, ..., h3N}.
[0109] Step S620: Perform the feature space structure parsing process on the feature embedding vector set to generate hidden layer space neighborhood topology information and hidden layer space boundary contour structure information. The hidden layer space neighborhood topology information describes the density distribution and orientation distribution characteristics of minority class sample units in the current hidden layer feature space. The hidden layer space boundary contour structure information describes the boundary morphology characteristics at the intersection of majority class sample units and minority class sample units in the current hidden layer feature space.
[0110] The feature embedding vector set H is used as the new feature space point set, replacing the original feature space point set composed of unified feature vectors in step S120. Feature space structure parsing processing is then performed on this new feature space point set according to the methods in steps S121 to S128. The cosine distance calculation in step S121 is performed in the hidden layer feature space of dimension d9, and the K-nearest neighbor parameter retains its preset value. After processing, hidden layer space neighborhood topology information and hidden layer space boundary contour structure information are generated.
[0111] Step S630: Input the hidden layer space neighborhood topology information and the hidden layer space boundary contour information into the sample weighting coefficient generation model to generate a dynamically adjusted weighting coefficient for each sample unit. The dynamically adjusted weighting coefficient reflects the degree of class imbalance of the sample unit in the current hidden layer feature space.
[0112] The hidden layer spatial neighborhood topology information and hidden layer spatial boundary contour information generated in step S620 are input into the pre-constructed sample weighting coefficient generation model in step S130, and the weighting coefficients corresponding to each sample unit are generated according to the methods in steps S131 to S137. These weighting coefficients are generated based on the structural information of the current hidden layer feature space and are denoted as dynamically adjusted weighting coefficients q5.
[0113] Step S640: The dynamically adjusted weighting coefficient is fused with the existing class balance weighting coefficient of the corresponding sample unit. The fusion process is achieved by calculating the weighted average of the dynamically adjusted weighting coefficient and the class balance weighting coefficient to obtain the fused weighting coefficient. The original class balance weighting coefficient of the corresponding sample unit is replaced with the fused weighting coefficient, and the step of weighting the loss contribution of each sample unit in the anti-fraud sample set is re-executed based on the fused weighting coefficient to obtain the dynamically weighted loss calculation dataset.
[0114] The fusion weighting coefficient q6 = λ1 × q4 + (1 - λ1) × q5, where λ1 is a preset fusion weight, with a value between 0 and 1. Replace the class balance weighting coefficient q4 used in step S140 with q6, and recalculate the loss contribution weighting according to the methods in steps S141 to S144 to obtain the dynamic weighted loss calculation dataset.
[0115] Step S650: Use the dynamically weighted loss calculation dataset to drive the anti-fraud model for subsequent training iterations, so that the decision boundary of the anti-fraud model is continuously adjusted with the change of the hidden layer feature space structure. In the next cycle, extract the hidden layer feature embedding vector set of the anti-fraud model again, and repeatedly perform the operation of feature space structure parsing processing on the feature embedding vector set, generating dynamically adjusted weighting coefficients, fusing weighting coefficients and the dynamically weighted loss calculation dataset, forming a closed loop of periodic dynamic adjustment of weighting coefficients during training.
[0116] The anti-fraud model is trained for E5 epochs using the dynamically weighted loss calculation dataset generated in step S640. After training, step S610 is executed again to extract a new set of feature embedding vectors, and then steps S620 to S640 are executed to generate a new dynamically weighted loss calculation dataset. This process is repeated, updating the dynamic weighting coefficients every E5 epochs, forming a closed loop of periodic dynamic adjustment of the weighting coefficients during training, until the preset training termination condition is reached.
[0117] For example, step S710: Obtain the prediction results on the verification sample set after the anti-fraud model has been trained. The verification sample set includes majority class verification sample units and minority class verification sample units carrying fraud labels. The prediction results include the fraud prediction probability value and prediction category label corresponding to each verification sample unit.
[0118] After the anti-fraud model is trained, it is evaluated using an independent set of validation samples. The validation sample set is extracted from historical transaction data with the same distribution as the training data but a different time window. It contains majority and minority class validation sample units, and the fraud labels are known. The validation sample set is input into the trained anti-fraud model to obtain a fraud prediction probability value s4 for each validation sample unit. The predicted class label is determined based on whether s4 is greater than 0.5; s4 greater than 0.5 predicts fraud, and s4 less than or equal to 0.5 predicts normal transactions.
[0119] Step S720: Extract the misclassified minority class verification sample units from the prediction results, construct the misclassified minority class sample set, and extract the original feature fields of each sample unit in the misclassified minority class sample set.
[0120] The minority class validation sample units whose predicted category label is fraud but whose predicted category label is normal are selected from the screening results, forming a misclassified minority class sample set. A unified feature vector is extracted from each sample unit in this misclassified minority class sample set for subsequent feature space structure analysis.
[0121] Step S730: Perform the feature space structure parsing process on the original feature fields of the misclassified minority class sample set to generate the neighborhood topology information and the boundary contour structure information of the misclassified samples.
[0122] The unified feature vectors of all sample units in the misclassified minority class sample set are used as the feature space point set. Feature space structure parsing is performed according to steps S121 to S128. The K-nearest neighbor parameter is adjusted to a preset small value K2, where K2 is less than K, to focus on the local neighborhood structure of the misclassified samples. This generates the neighborhood topology information and boundary contour structure information of the misclassified samples.
[0123] Step S740: Based on the neighborhood topology information and the boundary contour information of the misclassified samples, perform targeted fine-tuning on the sample weighted coefficient generation model. The targeted fine-tuning only updates the network parameters in the sample weighted coefficient generation model that are related to the feature distribution of the misclassified samples.
[0124] The neighborhood topology and boundary contour information of the misclassified samples generated in step S730 are used as inputs. The ideal weighting coefficient of the misclassified samples is set as the target value qmax, where qmax is the preset maximum weighting coefficient value. The mean squared error is used as the loss function L5 = (qout - qmax), where qout is the weighting coefficient output by the sample weighting coefficient generation model. The partial derivatives of L5 with respect to the parameters of each layer of the sample weighting coefficient generation model are calculated, but only the fully connected layer parameters of the morphological encoding layer in the third branch network and the weight parameters related to morphological encoding in the fully connected fusion layer are updated. The parameters of the first and second branch networks remain unchanged during directional fine-tuning. A preset fine-tuning learning rate η2 is used, which is less than the base learning rate η, and E6 iterations are performed.
[0125] Step S750: Use the sample weighting coefficient generation model after the directional fine-tuning to regenerate updated verification weighting coefficients for the verification sample set, and perform loss contribution weighting processing on each verification sample unit in the verification sample set based on the updated verification weighting coefficients to obtain the verification weighted loss calculation dataset.
[0126] The validation sample set is input into the directional fine-tuned sample weighting coefficient generation model to generate updated validation weighting coefficients q7. Following the methods in steps S141 to S144, q7 is used to replace q4, and the validation sample set is weighted according to the loss contribution to obtain the validation weighted loss calculation dataset.
[0127] Step S760: The anti-fraud model is incrementally trained using the verification weighted loss calculation dataset. The incremental training only updates the parameters of the classification decision layer of the anti-fraud model in a limited number of steps.
[0128] The network weight parameters of the shallow and mid-level feature extraction layers of the anti-fraud model are frozen, allowing only the network weight parameters of the deep feature extraction layer and the classification output layer to be updated during incremental training. Incremental training is performed for E7 epochs using a validation-weighted loss dataset, where E7 is a preset minimum value.
[0129] Step S770: After incremental training is completed, the updated prediction results of the anti-fraud model on the verification sample set are obtained again, and the classification accuracy of the minority class verification sample units is calculated. If the classification accuracy is improved compared with the classification accuracy before incremental training, the sample weighting coefficients after the targeted fine-tuning process are retained to generate model parameters and anti-fraud model parameters after incremental training.
[0130] After incremental training, the validation sample set is input into the anti-fraud model again, and the classification accuracy of the minority class validation sample units is calculated. The classification accuracy equals the number of minority class validation sample units correctly predicted as fraud divided by the total number of minority class validation sample units. Let A1 be the classification accuracy of the minority class validation sample units before incremental training, and A2 be the classification accuracy after incremental training. If A2 is greater than A1, the sample weighting coefficients after targeted fine-tuning are saved to generate model parameters and the anti-fraud model parameters after incremental training.
[0131] Step S780: If the classification accuracy does not improve compared to the classification accuracy before incremental training, then revert to the sample weighting coefficient generation model parameters before the targeted fine-tuning process and the anti-fraud model parameters before incremental training, and re-execute the step of performing the feature space structure parsing process on the original feature fields of the misclassified minority class sample set, adjusting the nearest neighbor range parameters in the feature space structure parsing process.
[0132] If A2 is less than or equal to A1, then discard the results of this targeted fine-tuning and incremental training, revert the parameters of the sample weighted coefficient generation model to the state before targeted fine-tuning in step S740, and revert the parameters of the anti-fraud model to the state after training in step S710. Adjust the K-nearest neighbor parameter from K2 to K3, where K3 takes a value between K2 and K. Using the adjusted K3 as the new nearest neighbor parameter, repeat steps S730 to S770 until A2 is greater than A1 or the number of adjustments reaches the preset upper limit E8.
[0133] Step S810: During the process of density-aware encoding of the normalized neighborhood density distribution features by the sample weighted coefficient generation model, the intermediate density representation vectors output by each hidden layer of the density encoding branch network in the sample weighted coefficient generation model are obtained. The intermediate density representation vectors constitute a density representation vector sequence. The intermediate density representation vectors corresponding to different hidden layers in the density representation vector sequence have a hierarchical relationship of feature expression that is abstracted layer by layer.
[0134] The density-encoded branch network, which is the first branch network in step S131, contains three fully connected layers. Let the output of the first layer be g1 with dimension d2; the output of the second layer be g2 with dimension d3; and the output of the third layer be g3 with dimension d4. The density representation vector sequence is G = {g1, g2, g3}.
[0135] Step S820: Perform difference calculation processing on the intermediate density representation vectors output by adjacent hidden layers in the density representation vector sequence. The difference calculation processing is performed by subtracting the intermediate density representation vector of the next layer from the intermediate density representation vector of the previous layer element by element under a uniform dimensionless scale to obtain the interlayer density information gain vector.
[0136] For g1 and g2: First, transform g1 to the same dimension d3 as g2 using a linear mapping. The mapped vector is denoted as g1p. The interlayer density information gain vector Δg21 = g2 - g1p, with the subtraction performed element-wise. For g2 and g3: Transform g2 to the same dimension d4 as g3 using a linear mapping. The mapped vector is denoted as g2p, and Δg32 = g3 - g2p.
[0137] Step S830: Perform symbolic parsing processing on the interlayer density information gain vector to extract the symbolic polarity distribution pattern of each element in the interlayer density information gain vector. The symbolic polarity distribution pattern is used to reflect the information transmission direction of the neighborhood density distribution characteristics between different abstraction levels.
[0138] For each element of Δg21, if the element value is greater than 0, it is marked as positive; if it is less than 0, it is marked as negative; and if it is equal to 0, it is marked as zero. The number of positive marks P1, the number of negative marks N1, and the number of zero marks Z1 are counted to form the sign polarity distribution pattern of Δg21. The same process is applied to Δg32 to obtain its sign polarity distribution pattern.
[0139] Step S840: During the process of the sample weighted coefficient generation model performing direction-aware encoding on the normalized neighborhood direction distribution features, the intermediate direction representation vectors output by each hidden layer of the direction encoding branch network in the sample weighted coefficient generation model are obtained. The intermediate direction representation vectors constitute a direction representation vector sequence. The difference calculation is performed on the intermediate direction representation vectors output by adjacent hidden layers in the direction representation vector sequence to obtain the inter-layer direction information gain vector. The symbol resolution is then performed on the inter-layer direction information gain vector to extract the symbol polarity distribution pattern of each element in the inter-layer direction information gain vector.
[0140] The directional coding branch network, which is the second branch network in step S132, contains three fully connected layers. Let the output of the first layer be j1 with dimension d2; the output of the second layer be j2 with dimension d3; and the output of the third layer be j3 with dimension d4. The directional representation vector sequence is J = {j1, j2, j3}. Using the same method as in steps S820 and S830, the inter-layer directional information gain vectors Δj21 and Δj32 are calculated, and their respective symbol polarity distribution patterns are extracted.
[0141] Step S850: Under a unified dimensionless scale, perform layer-by-layer alignment and matching processing on the symbol polarity distribution patterns corresponding to the density representation vector sequence and the direction representation vector sequence to identify whether there is a polarity conflict in the symbol polarity distribution patterns at the same hidden layer level of the density coding branch network and the direction coding branch network. The polarity conflict refers to the fact that the symbol polarity of the density information gain vector and the symbol polarity of the direction information gain vector are opposite under the dimensionless scale at the same level.
[0142] For the same hidden layer, compare the sign polarity distribution patterns of Δg21 and Δj21. If the number of positive labels P1 in Δg21 and the number of negative labels N1 in Δj21 both exceed half of their respective vector dimensions, or the number of negative labels N1 in Δg21 and the number of positive labels P1 in Δj21 both exceed half of their respective vector dimensions, then a polarity conflict is determined to exist at this layer. The same determination is made for Δg32 and Δj32.
[0143] Step S860: If the polarity conflict exists, in the feature interaction layer of the sample weighted coefficient generation model, the density-aware encoding vector segments and direction-aware encoding vector segments corresponding to the hidden layer with polarity conflict are subjected to mutual inhibition weighting processing. The density-aware encoding vector and direction-aware encoding vector after the mutual inhibition weighting processing are then subjected to joint weighting calculation processing with the morphology-aware encoding vector to generate class-balanced weighting coefficients after eliminating feature encoding conflicts. The mutual inhibition weighting processing is achieved by reducing the attention weight of the density-aware encoding vector segments and the direction-aware encoding vector segments in the cross-attention mechanism.
[0144] If a polarity conflict is detected, before performing the cross-attention calculation in step S134, the vector segments corresponding to the polarity conflict level in the density-aware encoding vector a1 and the direction-aware encoding vector a2 are subjected to mutual inhibition weighting. Let the segment corresponding to the conflict level in a1 be a1c, and the segment corresponding to the conflict level in a2 be a2c. In the cross-attention calculation, the attention weight between a1c and a2c is multiplied by an inhibition factor ρ2, where ρ2 takes a preset value between 0 and 1. The cross-attention weight is reduced after the mutual inhibition weighting, which weakens the contribution of information from the conflict level in feature interaction. Then, steps S135 to S137 are performed to generate the category balance weighting coefficients after eliminating feature encoding conflicts.
[0145] Step S910: Analyze the neighborhood density distribution features of each minority class sample unit in the anti-fraud sample set, extract sparse minority class sample units whose neighborhood density distribution features are lower than a preset density threshold, construct a sparse minority class sample unit set, and perform main direction consistency analysis on the neighborhood direction distribution features of each sparse minority class sample unit in the sparse minority class sample unit set. The main direction consistency analysis is achieved by calculating the directional angle between the neighborhood direction distribution features of the sparse minority class sample unit and the neighborhood direction distribution features of other minority class sample units within its nearest range.
[0146] The preset density threshold is τ3. Traverse all minority class sample units in the anti-fraud sample set, and extract the minority class sample units whose neighborhood density distribution feature d1 generated in step S122 is lower than τ3 to form a sparse minority class sample unit set. For each sample unit x in the sparse minority class sample unit set, select neighbor samples belonging to the minority class from its K nearest neighbors. Let the neighborhood direction distribution feature of x be u, and the neighborhood direction distribution feature of a certain minority class neighbor sample be u1, with the direction angle φ = arccos(|u·u1|÷(||u||×||u1||)). Calculate the mean φavg of the direction angles between x and all minority class neighbors.
[0147] Step S920: Based on the magnitude of the directional angle, classify the sparse minority class sample units according to their degree of directional isolation, and mark the sparse minority class sample units whose directional angle is greater than a preset angle threshold as directionally isolated sample units.
[0148] The preset included angle threshold is φ1. If the φavg of a sparse minority class sample unit is greater than φ1, then the sparse minority class sample unit is marked as an oriented isolated sample unit.
[0149] Step S930: When the sample weighting coefficient generation model performs direction-aware encoding processing on the neighborhood direction distribution features of the direction-isolated sample unit, a direction perturbation compensation processing is applied to the direction-aware encoding vector of the direction-isolated sample unit. The direction perturbation compensation processing is achieved by superimposing a direction perturbation vector that follows a preset distribution on the direction-aware encoding vector. The direction of the direction perturbation vector is in a preset angular relationship with the main direction of the neighborhood direction distribution features of the direction-isolated sample unit.
[0150] When the second branch network performs direction-aware encoding on the neighborhood direction distribution features u of the directionally isolated sample unit in step S132, direction perturbation compensation is applied after the first layer output of the second branch network. A direction perturbation vector r is generated, with its direction perpendicular to u (r·u=0). The magnitude of r is sampled from a normal distribution with a mean of 0 and a standard deviation of σ², where σ² is a preset perturbation intensity. The perturbated first layer output j1p=j1+r. Subsequent calculations for the second and third layers continue based on j1p.
[0151] Step S940: Obtain the orientation-aware encoding vector after applying the orientation perturbation compensation processing, and input the orientation-aware encoding vector after applying the orientation perturbation compensation processing, along with the density-aware encoding vector and morphology-aware encoding vector of the orientation isolated sample unit, into the feature interaction layer of the sample weighting coefficient generation model. When performing cross-attention calculation on the orientation-aware encoding vector after applying the orientation perturbation compensation processing in the feature interaction layer, an orientation perturbation intensity attenuation factor is introduced. The orientation perturbation intensity attenuation factor gradually decreases with the increase of the number of training iterations, so that the influence of the orientation perturbation compensation processing gradually weakens in the later stage of training.
[0152] The directional perturbation intensity attenuation factor β(t) = β0 × exp(-t ÷ T1), where β0 is the initial attenuation factor, t is the current training iteration number, and T1 is the attenuation time constant. In the feature interaction layer of step S134, when performing cross-attention calculation on the directional awareness encoding vector a2p after directional perturbation compensation processing with other vectors, the attention weight is multiplied by (1 + β(t)). As the number of training iterations t increases, β(t) gradually approaches 0, and the influence of directional perturbation compensation gradually weakens.
[0153] Step S950: Through feature interaction layer processing including directional perturbation intensity attenuation factor, generate perturbation attenuation weighting coefficients corresponding to the directional isolated sample units, and use the perturbation attenuation weighting coefficients to perform loss contribution weighting processing on the directional isolated sample units. In the early stage of training, provide larger loss contribution weights to the directional isolated sample units to strengthen their influence on the decision boundary, and gradually restore them to loss contribution weights based on the real neighborhood directional distribution features in the later stage of training.
[0154] After the feature interaction layer in step S940 and subsequent steps S135 to S137, the class balance weighting coefficients corresponding to the directionally isolated sample units are generated, denoted as the perturbation attenuation weighting coefficient q8. In the early stages of training, β(t) is relatively large, and q8 is larger than the weighting coefficients generated based on the true neighborhood directional distribution features, providing a greater loss contribution weight for the directionally isolated sample units. In the later stages of training, β(t) approaches 0, and q8 gradually recovers to a level close to the weighting coefficients generated based on the true neighborhood directional distribution features.
[0155] Step S1010: After each training iteration of the anti-fraud model driven by the weighted loss calculation dataset, extract the hidden layer feature vector of the anti-fraud model for each sample unit in the anti-fraud sample set after the current training iteration. The hidden layer feature vector constitutes the hidden layer feature vector set of the current iteration.
[0156] After each training iteration, the abstract semantic feature representation h3 of the deep feature extraction layer of the anti-fraud model is extracted as the hidden layer feature vector. The h3 of all sample units constitutes the set Hcur of hidden layer feature vectors for the current iteration.
[0157] Step S1020: Perform the feature space structure parsing process on the current iteration hidden layer feature vector set to generate the current iteration neighborhood topology structure information and the current iteration boundary contour structure information.
[0158] Using Hcur as the feature space point set, generate the current iteration neighborhood topology information and the current iteration boundary contour structure information according to the methods in steps S121 to S128.
[0159] Step S1030: Perform structural difference comparison processing on the current iteration neighborhood topology information and the current iteration boundary contour structure information with the previous iteration neighborhood topology information and the previous iteration boundary contour structure information generated during the previous training iteration. The structural difference comparison processing is achieved by calculating the density distribution offset between the current iteration neighborhood density distribution features and the previous iteration neighborhood density distribution features, as well as the boundary morphology change between the current iteration boundary geometric morphology features and the previous iteration boundary geometric morphology features.
[0160] Let d1_prev be the neighborhood density distribution feature of each minority class sample unit in the neighborhood topology information generated in the previous training iteration, and d1_cur be the feature in the current iteration. The density distribution offset Δd = (1 / N1) × Σ(i=1 to N1)|d1_cur_i - d1_prev_i|. Let z_prev be the modulus ratio of each cluster center in the boundary contour structure information of the previous iteration, and z_cur be the feature in the current iteration. The boundary morphology change Δz = (1 / C) × Σ(k=1 to C)|z_cur_k - z_prev_k|.
[0161] Step S1040: Construct a feature space structure evolution trend vector based on the density distribution offset and the boundary morphology change. The feature space structure evolution trend vector is used to describe the evolution direction and rate of the neighborhood topology of minority class sample units and the boundary contour structure of majority class sample units during the training process.
[0162] The feature space structure evolution trend vector m=[Δd, Δz] has a dimension of 2.
[0163] Step S1050: Input the feature space structure evolution trend vector into a bypass prediction branch network of the sample weighted coefficient generation model, and perform time-series modeling processing on the feature space structure evolution trend vector through the bypass prediction branch network to predict the expected neighborhood topology information and expected boundary contour structure information after the next training iteration.
[0164] The bypass prediction branch network is a gated recurrent unit network (GRU), whose input is the sequence of feature space structure evolution trend vectors {m_t-E9+1, ..., m_t} from the most recent E9 training iterations. The hidden state of the last time step of the GRU is mapped to a 2D prediction vector m_pred=[Δd_pred, Δz_pred] through a fully connected output layer. The expected neighborhood density distribution features are d1_pred=d1_cur+Δd_pred, and the expected boundary morphology change is z_pred=z_cur+Δz_pred. d1_pred and z_pred are then used to update the current iteration's neighborhood topology and the current iteration's boundary contour structure information, respectively, to obtain the expected neighborhood topology and the expected boundary contour structure information.
[0165] Step S1060: Input the expected neighborhood topology information and the expected boundary contour structure information into the backbone network of the sample weighted coefficient generation model, pre-generate the look-ahead weighted coefficients corresponding to the next training iteration, and use the look-ahead weighted coefficients to perform loss contribution weighting processing on each sample unit in the anti-fraud sample set in the current training iteration to obtain the look-ahead weighted loss calculation dataset, so that the parameter update direction of the anti-fraud model in the current training iteration adapts in advance to the expected feature space structure of the next training iteration.
[0166] The expected neighborhood topology and expected boundary contour information generated in step S1050 are input into the sample weighted coefficient generation model, and the look-ahead weighted coefficient q9 is generated according to the methods in steps S131 to S137. In the current training iteration, q9 is used to replace q4, and the look-ahead weighted loss calculation dataset is calculated according to the methods in steps S141 to S144 for parameter updates of the anti-fraud model.
[0167] Step S1110: Obtain the cross-attention weight matrix output by the feature interaction layer of the sample weighting coefficient generation model during the generation of the class balance weighting coefficients for each sample unit. The cross-attention weight matrix includes the first attention weight vector of the density-aware encoding vector to the orientation-aware encoding vector, the second attention weight vector of the density-aware encoding vector to the morphology-aware encoding vector, and the third attention weight vector of the orientation-aware encoding vector to the morphology-aware encoding vector.
[0168] In the feature interaction layer of step S134, the three cross-attention units output their corresponding attention weights. In the first cross-attention unit, the attention weight vector of density-aware encoding vector a1 to direction-aware encoding vector a2 is denoted as w1, with a dimension equal to the dimension d4 of a2. In the second cross-attention unit, the attention weight vector of a1 to shape-aware encoding vector a3 is denoted as w2, with a dimension of d4. In the third cross-attention unit, the attention weight vector of a2 to a3 is denoted as w3, with a dimension of d4.
[0169] Step S1120: Perform weight distribution parsing processing on the first attention weight vector, the second attention weight vector, and the third attention weight vector, and extract the prominent attention dimension positions with weight values higher than the preset weight and the suppressed attention dimension positions with weight values lower than the preset weight in each attention weight vector.
[0170] The preset high-weight threshold is τ4, and the preset low-weight threshold is τ5. For w1, iterate through its d4 elements, marking the dimensions with element values greater than τ4 as prominent attention dimensions, and marking the dimensions with element values less than τ5 as suppressive attention dimensions. The same process is applied to w2 and w3. The prominent attention dimensions of the three attention weight vectors are merged and deduplicated to obtain the set P1 of prominent attention dimensions. The suppressive attention dimensions of the three attention weight vectors are merged and deduplicated to obtain the set P2 of suppressive attention dimensions.
[0171] Step S1130: Map the highlighted attention dimension position and the suppressed attention dimension position back to the original feature fields of the sample units in the anti-fraud sample set, establish the correspondence between the original feature fields and the internal attention distribution of the class balanced weighted coefficient, identify the key original feature fields that contribute more than a preset contribution to the generation of the class balanced weighted coefficient according to the correspondence, construct a set of key feature fields, and identify the secondary original feature fields that contribute less than a preset contribution to the generation of the class balanced weighted coefficient, construct a set of secondary feature fields.
[0172] The dimension d4 of each attention weight vector corresponds to the dimension of the encoding vector in the feature interaction layer. By inversely tracing the mapping relationship between the fully connected fusion layer and the branch network, the dimensional positions in P1 and P2 are mapped layer by layer to the 5d dimensional positions of the original unified feature vector. The frequency of each original feature dimension being mapped to P1 is counted. Original feature fields corresponding to original feature dimensions with frequencies higher than a preset frequency threshold τ6 are marked as key original feature fields, forming a set of key feature fields. The frequency of each original feature dimension being mapped to P2 is counted. Those with frequencies higher than τ6 are marked as secondary original feature fields, forming a set of secondary feature fields.
[0173] Step S1140: During the subsequent training of the anti-fraud model, a feature preservation constraint is applied to the model input node corresponding to the original feature field in the set of key feature fields. The feature preservation constraint limits the update magnitude of the network weights corresponding to the model input node during the training process.
[0174] The input layer weight matrix of the anti-fraud model is denoted as θin, with dimensions 5d × d7. For each feature dimension index j in the key feature field set, during each training iteration when updating θin, the update amount of the weight vector in the j-th row is multiplied by a constraint factor φ1, where φ1 takes a preset value between 0 and 1. φ1 close to 0 indicates that the weights in that row are hardly updated, and φ1 close to 1 indicates a normal update. After applying the feature preservation constraint, the update amount of the weights in that row is Δθin_j_new = φ1 × Δθin_j.
[0175] Step S1150: Apply feature suppression attenuation processing to the model input nodes corresponding to the original feature fields in the set of secondary feature fields. The feature suppression attenuation processing gradually reduces the absolute value of the network weights corresponding to the model input nodes in each training iteration.
[0176] For each feature dimension index k in the secondary feature field set, after updating θin in each training iteration, the weight vector of the k-th row is multiplied by a decay factor φ2, where φ2 = 1 - η3, and η3 is a preset decay step size. After applying feature suppression decay processing, the weights of this row are updated to θin_k_new = φ2 × θin_k_old.
[0177] Step S1160: After the continuous effect of the feature preservation constraint and the feature suppression decay process, the classification decision boundary of the anti-fraud model gradually shifts towards the direction that depends on the key original feature fields, and the directional shift is consistent with the attention distribution inside the class balance weighting coefficient.
[0178] In each subsequent training batch, the feature preservation constraint of step S1140 and the feature suppression decay process of step S1150 are repeated. As the number of training iterations increases, the network weights corresponding to the key feature fields are effectively preserved and strengthened, while the network weights corresponding to the secondary feature fields gradually decay to near zero. The classification decision boundary of the anti-fraud model gradually shifts towards the direction that depends on the key original feature fields.
[0179] Step S1210: During the anti-fraud model training process, the majority class sample units correctly classified by the anti-fraud model and the majority class sample units incorrectly classified by the anti-fraud model are extracted from the weighted loss calculation dataset at a preset period. A majority class sample classification result group set is constructed. The feature space structure parsing process is performed on the correctly classified majority class sample units and the incorrectly classified majority class sample units in the majority class sample classification result group set respectively to generate the boundary contour structure information of the correctly classified majority class and the boundary contour structure information of the incorrectly classified majority class.
[0180] The preset training period is E10 rounds. At the end of each round, the current anti-fraud model is used to predict all majority class sample units in the anti-fraud sample set. Correctly predicted majority class sample units are assigned to the correct classification set M1, and incorrectly predicted majority class sample units are assigned to the incorrect classification set M2. For all sample units in M1 and M2, the boundary contour structure information of the correctly classified majority class and the incorrectly classified majority class is generated according to steps S125 to S127. The cluster center set corresponding to M1 is R1, and the cluster center set corresponding to M2 is R2.
[0181] Step S1220: Perform boundary morphology difference analysis on the boundary contour structure information of the correctly classified majority class and the incorrectly classified majority class, extract the morphological deviation direction vector between the incorrectly classified majority class sample unit and the correctly classified majority class sample unit in terms of boundary geometric morphology features, and perform morphological correction adjustment on the boundary geometric morphology features of the incorrectly classified majority class sample unit according to the morphological deviation direction vector. The morphological correction adjustment is achieved by translating the boundary geometric morphology features of the incorrectly classified majority class sample unit in the opposite direction of the morphological deviation direction vector by a preset step size.
[0182] For each misclassified majority class sample unit in M2, calculate the Euclidean distance between its feature difference vector w and the nearest cluster center in R1, and find the correct classification cluster center r1 with the smallest distance. The morphological deviation direction vector vdev = w - r1. The morphologically corrected feature difference vector wcorr = w - η4 × vdev, where η4 is the preset translation step size. wcorr replaces w as the adjusted feature difference vector for this misclassified majority class sample unit.
[0183] Step S1230: Replace the original boundary geometric features with the boundary geometric features of the misclassified majority class sample unit after the morphological correction adjustment process, and re-input the replaced boundary geometric features into the sample weighting coefficient generation model to generate the correction weighting coefficients corresponding to the misclassified majority class sample unit.
[0184] Update the corresponding boundary geometric features in step S127 using the wcorr of each misclassified majority class sample unit in M2. Input the updated boundary geometric features into the sample weighted coefficient generation model, and generate the corrected weighted coefficient q10 according to the methods in steps S133 to S137.
[0185] Step S1240: Update the weighting coefficients used in the loss contribution weighting of the misclassified majority class sample unit in the current period using the corrected weighting coefficients to obtain the updated loss contribution weighting value, so that the degree of loss penalty suffered by the misclassified majority class sample unit in subsequent training matches its boundary position after morphological correction.
[0186] Replace the class balance weighting coefficient q4 used in the current period with q10 for the misclassified majority class sample unit, and recalculate the weighted loss contribution value L2new=q10×L1 according to the method in step S142. The updated weighted loss contribution value L2new is used for the batch weighted total loss value calculation in step S143.
[0187] Step S1250: In the next cycle, repeat the operations of extracting the majority class sample classification result group set from the weighted loss calculation dataset, generating the boundary contour structure information of the correctly classified majority class and the incorrectly classified majority class, morphological correction adjustment processing and weighted coefficient update, forming a continuous correction loop for the boundary morphology of misclassified majority class samples.
[0188] Every E10 training epochs, steps S1210 to S1240 are repeated. In each cycle, the composition of the correct classification set M1 and the misclassification set M2 changes dynamically as the anti-fraud model is updated. The morphology correction adjustment continuously guides the misclassified majority class sample units to move closer to the boundary morphology of the correct classification, forming a continuous boundary morphology correction cycle until the training ends.
[0189] Furthermore, an embodiment of this application provides a class-imbalanced sample weighting system for anti-fraud models, comprising a processor and a memory. The processor and memory are connected, for example, via a bus. Optionally, the class-imbalanced sample weighting system for anti-fraud models may further include a transceiver, which can be used for data interaction between this class-imbalanced sample weighting system and other class-imbalanced sample weighting systems for anti-fraud models, such as sending and / or receiving data. It should be noted that in actual scheduling, the transceiver is not limited to one, and the structure of this class-imbalanced sample weighting system for anti-fraud models does not constitute a limitation on the embodiments of this application.
[0190] The memory stores program code for executing the embodiments of this application, and its execution is controlled by a processor. The processor executes the program code stored in the memory to implement the steps shown in the foregoing method embodiments.
[0191] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application, without departing from the technical concept of this application, also fall within the protection scope of the embodiments of this application.
Claims
1. A weighted method for class-imbalanced samples in anti-fraud models, characterized in that, The method includes: Obtain an anti-fraud sample set, which includes majority class sample units and minority class sample units carrying fraud labels, and each sample unit corresponds to a set of original feature fields; The anti-fraud sample set is subjected to feature space structure parsing processing to generate neighborhood topology information of minority class sample units and boundary contour structure information of majority class sample units. The neighborhood topology information includes the neighborhood density distribution characteristics and neighborhood direction distribution characteristics of minority class sample units in the feature space. The boundary contour structure information includes the boundary geometric morphology characteristics at the intersection of majority class sample units and minority class sample units. The pre-built sample weighting coefficient generation model is invoked to perform joint weighting calculation on the neighborhood density distribution features, the neighborhood direction distribution features, and the boundary geometric features to generate the category balance weighting coefficients corresponding to each sample unit. The loss contribution of each sample unit in the anti-fraud sample set is weighted using the class balance weighting coefficient to obtain a weighted loss calculation dataset. The weighted loss calculation dataset is used to drive the anti-fraud model to shift towards the decision boundary of minority class sample units.
2. The class-imbalanced sample weighting method for anti-fraud models according to claim 1, characterized in that, The anti-fraud sample set is subjected to feature space structure parsing processing to generate neighborhood topology information of minority class sample units and boundary contour structure information of majority class sample units. The neighborhood topology information includes the neighborhood density distribution characteristics and neighborhood orientation distribution characteristics of minority class sample units in the feature space. The boundary contour structure information includes the boundary geometric morphology characteristics at the intersection of majority class sample units and minority class sample units, including: Extract the neighbor sample distribution information of each minority class sample unit in the anti-fraud sample set in the feature space. The neighbor sample distribution information includes a set of neighbor sample identifiers within a preset nearest neighbor range centered on the minority class sample unit. The original neighborhood density value corresponding to the minority class sample unit is calculated based on the number of neighbor samples belonging to the minority class sample unit in the neighbor sample identifier set, and the original neighborhood density value is normalized to generate a dimensionless neighborhood density distribution feature. Construct a connection direction vector between the minority class sample unit and each neighbor sample in its neighbor sample identifier set. The connection direction vector is obtained by subtracting the feature fields of the minority class sample unit from the feature fields of its neighbor samples dimension by dimension. The set of connection direction vectors is subjected to principal direction decomposition processing, the direction component with the largest variance in the set of connection direction vectors is extracted, and the direction component is normalized to generate neighborhood direction distribution features. Traverse each majority class sample unit in the anti-fraud sample set, identify whether the neighbor sample identifier set of the majority class sample unit contains minority class sample units. If the neighbor sample identifier set of the majority class sample unit contains minority class sample units, mark the majority class sample unit as a boundary majority class sample unit, and extract the feature difference vector between the boundary majority class sample unit and the included minority class sample unit. Clustering is performed on the feature difference vectors corresponding to all boundary majority class sample units in the anti-fraud sample set to obtain a set of difference vector cluster centers. Each cluster center vector in the set of difference vector cluster centers is used to describe a boundary geometric feature at the intersection of majority class sample units and minority class sample units. For each cluster center vector in the set of difference vector cluster centers, extract its normalized direction vector and dimensionless modulus ratio value, and use the normalized direction vector and modulus ratio value as the structured components of the boundary geometric morphology features to generate boundary contour structure information; The normalized neighborhood density distribution features and the unitized neighborhood orientation distribution features of all minority class sample units are combined to form neighborhood topology information.
3. The class-imbalanced sample weighting method for anti-fraud models according to claim 1, characterized in that, The process of calling a pre-built sample weighting coefficient generation model to jointly weight the neighborhood density distribution features, the neighborhood direction distribution features, and the boundary geometric features to generate class-balanced weighting coefficients for each sample unit includes: The normalized neighborhood density distribution features are input into the first branch network of the sample weighted coefficient generation model. The neighborhood density distribution features are then subjected to density-aware encoding through the nonlinear mapping layer of the first branch network to generate a density-aware encoding vector. The neighborhood orientation distribution features after normalization are input into the second branch network of the sample weighted coefficient generation model. The orientation encoding layer of the second branch network performs orientation-aware encoding on the neighborhood orientation distribution features to generate orientation-aware encoding vectors. The dimensionless boundary geometric features are input into the third branch network of the sample weighted coefficient generation model. The morphological encoding layer of the third branch network performs morphological-aware encoding on the structured components of the boundary geometric features to generate a morphological-aware encoding vector. After scaling the density-aware encoding vector, the orientation-aware encoding vector, and the morphology-aware encoding vector, they are input into the feature interaction layer of the sample weighting coefficient generation model. The three vectors are then fused in pairs through the cross-attention mechanism of the feature interaction layer to generate density-orientation interaction vector, density-morphology interaction vector, and orientation-morphology interaction vector. The density-aware encoding vector, the direction-aware encoding vector, the morphology-aware encoding vector, the density-direction interaction vector, the density-morphology interaction vector, and the direction-morphology interaction vector are input into the fully connected fusion layer of the sample weighting coefficient generation model for element-wise concatenation to obtain a multi-source fusion feature vector. The multi-source fusion feature vector is then compressed through layer-by-layer nonlinear transformation of the fully connected fusion layer to generate a compressed fusion feature vector. The dimension of the compressed fusion feature vector is lower than that of the multi-source fusion feature vector. The compressed fusion feature vector is input into the coefficient output layer of the sample weighted coefficient generation model. The compressed fusion feature vector is mapped to a preset numerical range through the activation function mapping process of the coefficient output layer to generate the initial weighted coefficients corresponding to the sample unit. Obtain the statistical center value of the initial weighting coefficients of all majority class sample units in the anti-fraud sample set, and calculate the relative weighting adjustment factor corresponding to the sample unit based on the dimensionless ratio of the statistical center value to the initial weighting coefficient corresponding to the sample unit. Multiply the initial weighting coefficient corresponding to the sample unit by the relative weighting adjustment factor to obtain the class balance weighting coefficient corresponding to the sample unit.
4. The class-imbalanced sample weighting method for anti-fraud models according to claim 1, characterized in that, The loss contribution weighting process for each sample unit in the anti-fraud sample set is performed using the category balance weighting coefficients to obtain a weighted loss calculation dataset, including: Obtain the fraud prediction probability value output by each sample unit in the anti-fraud sample set during the forward propagation of the anti-fraud model, and calculate the original loss contribution value corresponding to each sample unit based on the fraud category label of each sample unit and the fraud prediction probability value. Multiply the category balance weighting coefficient corresponding to each sample unit by the original loss contribution value corresponding to that sample unit to obtain the weighted loss contribution value corresponding to that sample unit. Summarize the weighted loss contribution values of all sample units in the anti-fraud sample set into a weighted loss contribution value set. The weighted loss contribution values in the set of weighted loss contribution values are summed to obtain the batch weighted total loss value. The batch weighted total loss value is used as the basis for gradient calculation of backpropagation of the anti-fraud model. The partial derivatives of the batch weighted total loss value with respect to the parameters of each layer of the anti-fraud model are calculated by the backpropagation algorithm. The parameters of each layer of the anti-fraud model are updated according to the partial derivatives to complete one training iteration. The updated fraud prediction probability value of each sample unit output by the anti-fraud model after this training iteration is combined with the original feature field to form a weighted loss calculation data unit in the weighted loss calculation dataset. The weighted loss calculation data unit is used for weighted loss contribution calculation in the next training iteration.
5. The class-imbalanced sample weighting method for anti-fraud models according to claim 1, characterized in that, The method further includes: The anti-fraud sample set is divided into multiple sample groups, and each sample group contains a majority class sample unit and a minority class sample unit. The feature space structure parsing process is performed on each sample group to obtain the group neighborhood topology information and group boundary contour information corresponding to each sample group. The group neighborhood topology information and group boundary contour information of each sample group are input into the sample weighting coefficient generation model to generate the group category balance weighting coefficient corresponding to the sample unit in each sample group. The loss contribution weighting processing of sample units within each sample group is weighted using the group category balance weighting coefficient corresponding to each sample group to obtain a group weighted loss calculation subset. All group weighted loss calculation subsets are merged into a global weighted loss calculation dataset. The global weighted loss calculation dataset is used to drive the decision boundary shift of the anti-fraud model under the group training strategy. After a preset number of training rounds, the anti-fraud sample set is re-grouped, and the re-grouped sample groups have different sample composition structures than the sample groups in the previous training round. The feature space structure parsing, group category weighting coefficient generation, and group weighted loss calculation subset construction operations are performed iteratively using the re-divided sample groups until the anti-fraud model reaches the preset training termination condition.
6. The class-imbalanced sample weighting method for anti-fraud models according to claim 1, characterized in that, The method further includes: The original feature fields of each minority class sample unit in the anti-fraud sample set are obtained, and feature perturbation processing is performed on the original feature fields of each minority class sample unit. The feature perturbation processing is achieved by applying random perturbation values that follow a preset probability distribution to each dimension of the original feature fields. The minority class sample units after the feature perturbation processing are used as new minority class sample units, and the new minority class sample units are added to the anti-fraud sample set to obtain an expanded anti-fraud sample set. The feature space structure parsing processing is performed on the expanded anti-fraud sample set to generate expanded sample neighborhood topology information and expanded sample boundary contour structure information. The expanded sample neighborhood topology information and the expanded sample boundary contour information are input into the sample weighting coefficient generation model to generate expanded weighting coefficients for each sample unit in the expanded anti-fraud sample set. Based on the expanded weighting coefficients, the loss contribution weighting processing is performed on each sample unit in the expanded anti-fraud sample set to obtain the expanded weighted loss calculation dataset. The anti-fraud model is trained for one complete cycle using the augmented weighted loss calculation dataset to obtain an intermediate anti-fraud model. Difficult sample units with classification confidence below a preset threshold are extracted from the prediction results of the intermediate anti-fraud model on the augmented anti-fraud sample set. The difficult sample units include misclassified minority class sample units and misclassified majority class sample units. The feature perturbation process is performed again on the minority class sample units in the difficult-to-distinguish sample units, and the newly generated minority class sample units are added to the sample set used in the current training batch to form an iteratively expanded sample set. The iteratively expanded sample set is then re-inputted into the intermediate anti-fraud model for the next round of training to obtain updated anti-fraud model parameters, until the proportion of difficult-to-distinguish sample units in the expanded anti-fraud sample set is lower than the preset termination ratio.
7. The class-imbalanced sample weighting method for anti-fraud models according to claim 1, characterized in that, The method further includes: A multi-level feature extraction structure for constructing an anti-fraud model is provided, comprising a shallow feature extraction layer, a medium feature extraction layer, and a deep feature extraction layer. The shallow feature extraction layer is used to extract basic feature representations from the original feature fields of sample units. The medium feature extraction layer is used to extract combined feature representations from the basic feature representations. The deep feature extraction layer is used to extract abstract semantic feature representations from the combined feature representations. A first category-balanced weighting module is inserted between the shallow feature extraction layer and the middle feature extraction layer. The first category-balanced weighting module is used to receive the basic feature representation output by the shallow feature extraction layer, and perform element-wise weighting processing on the basic feature representation based on the category-balanced weighting coefficients of the sample units corresponding to the basic feature representation to obtain the shallow weighted feature representation. A second category-balanced weighting module is inserted between the intermediate feature extraction layer and the deep feature extraction layer. The second category-balanced weighting module is used to receive the combined feature representation output by the intermediate feature extraction layer, and perform element-wise weighting processing on the combined feature representation based on the category-balanced weighting coefficients of the sample units corresponding to the combined feature representation to obtain the intermediate-weighted feature representation. A third category-balanced weighting module is inserted after the deep feature extraction layer. The third category-balanced weighting module is used to receive the abstract semantic feature representation output by the deep feature extraction layer, and perform element-wise weighting processing on the abstract semantic feature representation based on the category-balanced weighting coefficient of the sample unit corresponding to the abstract semantic feature representation to obtain the deep weighted feature representation. The shallow weighted feature representation is input into the middle-layer feature extraction layer for further feature transformation processing to obtain a shallow weighted combined feature representation. The shallow weighted combined feature representation and the middle-layer weighted feature representation are then fused element-wise to obtain a middle-layer fused feature representation. The middle-layer fused feature representation is input into the deep feature extraction layer for further feature transformation processing to obtain a middle-layer weighted abstract semantic feature representation. The middle-layer weighted abstract semantic feature representation and the deep weighted feature representation are then fused element-wise to obtain a deep fused feature representation. The deep fusion feature representation is input into the classification output layer of the anti-fraud model. Through the fully connected mapping and probability normalization processing of the classification output layer, the hierarchical weighted fraud prediction probability value corresponding to each sample unit is output. The hierarchical weighted loss contribution value is calculated based on the hierarchical weighted fraud prediction probability value and the fraud category label of the corresponding sample unit. Based on the hierarchical weighted loss contribution value, the parameters of the multi-level feature extraction structure, the first category balanced weighting module, the second category balanced weighting module, the third category balanced weighting module, and the classification output layer are jointly updated.
8. The class-imbalanced sample weighting method for anti-fraud models according to claim 1, characterized in that, The method further includes: Obtain the original feature fields of each sample unit in the anti-fraud sample set, and perform feature reorganization processing on the original feature fields of each sample unit. The feature reorganization processing includes dividing the original feature fields of each sample unit into multiple feature field groups according to the feature semantic category. Each feature field group contains several feature dimensions with the same semantic category. Perform the feature space structure parsing process on each feature field group to generate the field group neighborhood topology information and field group boundary contour structure information corresponding to each feature field group. Based on the neighborhood topology information and boundary contour information of each feature field group, the sample weighted coefficient generation model generates the field group weighted coefficients corresponding to each feature field group. The weighted coefficients of all field groups in the same sample unit are concatenated to obtain the multi-field group weighted coefficient vector corresponding to the sample unit. The dimension of the multi-field group weighted coefficient vector is equal to the number of feature field groups into which the sample unit is divided. The multi-field group weighted coefficient vector is used to group and weight the feature dimensions belonging to different feature field groups in the original feature field of the sample unit to generate the field group weighted feature vector corresponding to the sample unit. The feature dimensions within the same feature field group in the field group weighted feature vector share the field group weighted coefficient corresponding to the feature field group. The field-weighted feature vectors of all sample units in the anti-fraud sample set are used to construct a field-weighted sample set. The anti-fraud model is trained using the field-weighted sample set. During the training process, the anti-fraud model performs forward propagation calculation and backward gradient update based on the field-weighted feature vectors. After each training batch is completed, the weighting coefficients of the field groups corresponding to each feature field group are adaptively adjusted based on the classification error feedback of the anti-fraud model on the samples of the current batch.
9. The class-imbalanced sample weighting method for anti-fraud models according to claim 1, characterized in that, The method further includes: During the training of the anti-fraud model, the internal representation information of the model in the current training state is periodically extracted. The internal representation information of the model includes a set of feature embedding vectors output by the hidden layer of the anti-fraud model. Each feature embedding vector in the set of feature embedding vectors corresponds to a sample unit in the anti-fraud sample set. The feature space structure parsing process is performed on the feature embedding vector set to generate hidden layer space neighborhood topology information and hidden layer space boundary contour information. The hidden layer space neighborhood topology information describes the density distribution and orientation distribution characteristics of minority class sample units in the current hidden layer feature space, and the hidden layer space boundary contour information describes the boundary morphology characteristics at the intersection of majority class sample units and minority class sample units in the current hidden layer feature space. The hidden layer space neighborhood topology information and the hidden layer space boundary contour information are input into the sample weighting coefficient generation model to generate a dynamically adjusted weighting coefficient for each sample unit. The dynamically adjusted weighting coefficient reflects the degree of class imbalance of the sample unit in the current hidden layer feature space. The dynamically adjusted weighting coefficient is fused with the existing class balance weighting coefficient of the corresponding sample unit. The fusion process is achieved by calculating the weighted average of the dynamically adjusted weighting coefficient and the class balance weighting coefficient to obtain the fused weighting coefficient. The original class balance weighting coefficient of the corresponding sample unit is replaced with the fused weighting coefficient, and the step of weighting the loss contribution of each sample unit in the anti-fraud sample set is re-executed based on the fused weighting coefficient to obtain the dynamically weighted loss calculation dataset. The dynamic weighted loss calculation dataset is used to drive the anti-fraud model for subsequent training iterations, so that the decision boundary of the anti-fraud model is continuously adjusted with the change of the hidden layer feature space structure. In the next cycle, the hidden layer feature embedding vector set of the anti-fraud model is extracted again, and the operation of performing feature space structure parsing processing on the feature embedding vector set, generating dynamically adjusted weighting coefficients, and fusing weighting coefficients and dynamic weighted loss calculation dataset is repeated to form a closed loop of periodic dynamic adjustment of weighting coefficients during training.
10. A class-imbalanced sample weighting system for anti-fraud models, characterized in that, The device includes a processor and a computer-readable storage medium storing machine-executable instructions that, when executed by the processor, implement the class-imbalanced sample weighting method for anti-fraud models as described in any one of claims 1-9.
