A dynamic data classification method based on a hybrid model of rules and learning
By introducing knowledge graph reasoning and reinforcement learning rule generation into the data classification method, and combining improved dual contrastive learning and attention mechanisms, the adaptability and accuracy issues of hybrid models when data distribution changes are solved, achieving efficient and reliable dynamic data classification.
Patent Information
- Application Number
- CN202510079051.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2045-01-17
AI Technical Summary
Existing data classification methods suffer from several drawbacks when faced with changes in data distribution. Rule-based models are inflexible and rely on manual adjustments, learning models are prone to failure and difficult to interpret, and hybrid models lack deep fusion and adaptive capabilities, making it difficult to maintain high classification performance over long periods.
We adopt a hybrid model of rules and learning, which introduces knowledge graph reasoning and reinforcement learning to automatically generate rules. We combine improved dual contrastive learning to optimize feature representation and dynamically adjust weights through an improved dual attention mechanism to achieve adaptive updating of the rule model and generalization ability of the learning model.
It improves the adaptability of rule-based models and the generalization ability of learning models, reduces human intervention, ensures that the classification system maintains high accuracy and reliability when data distribution changes, and avoids model degradation problems.
Smart Images

Figure CN119989051B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing, and in particular to a dynamic data classification method based on a hybrid model of rules and learning. Background Technology
[0002] Data classification is a core task in machine learning and data mining, widely applied in industries such as financial risk control, medical diagnosis, intelligent recommendation, autonomous driving, and cybersecurity. Existing data classification methods can be broadly categorized into rule-based methods and machine learning-based methods. Rule-based methods typically rely on domain experts manually defining classification rules, such as decision trees, expert systems, and knowledge graph-based reasoning models. While these methods offer advantages like clear classification logic and strong interpretability, their fixed rules are difficult to adapt to changes in data distribution. When data patterns change, the rule system often requires manual adjustments, resulting in poor system flexibility and difficulty in adapting to real-time data flow changes.
[0003] On the other hand, machine learning-based methods (such as support vector machines, random forests, and deep neural networks) rely on large-scale training data to automatically learn data patterns and build classifiers. These methods can achieve high classification accuracy when the data volume is sufficient and the distribution is stable, but the models are prone to failure when the data distribution drifts, requiring retraining or complex parameter tuning. In addition, deep learning models often have the "black box" problem, that is, classification decisions are difficult to interpret, making them difficult to apply directly in scenarios with high interpretability requirements (such as finance and healthcare).
[0004] In recent years, hybrid classification models have gradually become a research hotspot, namely classification methods that combine rule-based models and learning models. Hybrid models attempt to integrate the interpretability of rule-based models with the adaptive capabilities of learning models, enabling the system to perform logical reasoning based on rules while automatically optimizing classification strategies using the learning model. However, existing hybrid classification methods still have many limitations. First, most hybrid classification models lack deep integration of the rule and learning components, performing only simple weighted fusion at the classification decision stage, without co-optimizing at the levels of feature representation and classification strategies. Second, the maintenance and updating of rule-based models still require significant manual intervention, failing to achieve automatic rule generation and adaptive adjustment. Furthermore, most existing fusion methods rely on fixed weighting mechanisms, failing to adaptively adjust to dynamic changes in data distribution, which may lead to a decline in classification performance over long-term operation.
[0005] Therefore, how to provide a dynamic data classification method based on a hybrid model of rules and learning is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0006] One objective of this invention is to propose a dynamic data classification method based on a hybrid rule-learning model. This invention designs a hybrid rule-learning model and introduces knowledge graph reasoning and reinforcement learning into the rule model to automatically generate and optimize classification rules, reducing reliance on manually set rules. In the learning model, an improved dual contrastive learning is adopted, which optimizes feature representation through contrastive loss in feature space, category space and global space, thereby improving the generalization ability of the learning model in data changing environments.
[0007] A dynamic data classification method based on a rule-based and learning hybrid model according to an embodiment of the present invention includes the following steps:
[0008] S1. Real-time acquisition of multi-source input data, and preprocessing to generate preprocessed data;
[0009] S2. Construct a hybrid model of rules and learning, input the preprocessed data into the hybrid model of rules and learning for classification, output the classification confidence, and generate preliminary classification results;
[0010] S3. Based on the classification confidence, the weights of the rule model and the learning model of the rule and learning hybrid model under different data distributions are adaptively adjusted according to the improved dual attention mechanism to optimize the preliminary classification results and generate the final classification results.
[0011] S4. When a change in data distribution is detected, the rule-learning hybrid model adjusts the rule set to optimize the classification results.
[0012] S5. Apply the rule-learning hybrid model to the actual classification task and update the rule model and learning model during the process.
[0013] Optionally, the multi-source input data includes structured and unstructured data, supporting parallel processing of streaming and batch data. The structured data includes database records, tabular data, and log files, while the unstructured data includes text, images, audio, and video data. The preprocessing includes format standardization, missing value imputation, outlier detection, feature extraction, and normalization.
[0014] Optionally, S2 specifically includes:
[0015] S21. Construct a rule-learning hybrid model, input preprocessed data into the rule-learning hybrid model, the rule-learning hybrid model includes a rule model and a learning model, the rule model includes a knowledge graph and a reinforcement learning model based on policy gradient optimization, and the learning model uses improved dual contrastive learning for feature learning;
[0016] S22. In the rule model, rules are generated based on knowledge graphs, and a reinforcement learning model based on policy gradient optimization is used to dynamically update the rules and adjust the weights of the rules. The classification results of the rule model are generated based on the weights.
[0017] S23. In the learning model, an improved dual contrastive learning method is used for feature learning, and the joint loss is calculated. The gradient descent method is used to optimize the parameters, minimize the joint loss, and generate the classification result of the learning model.
[0018] S24. Calculate the classification confidence scores of the rule model and the learning model based on their classification outputs:
[0019]
[0020] Among them, C r C represents the classification confidence of the rule-based model. l y represents the classification confidence of the learning model. ri Let y represent the classification output of the i-th sample in the rule model. li P(·) represents the classification output of the i-th sample of the learning model, P(·) represents the class probability distribution, and k represents the total number of samples;
[0021] S25. Calculate the preliminary classification results:
[0022]
[0023] Among them, Y f This indicates the preliminary classification results.
[0024] Optionally, S22 specifically includes:
[0025] S221. Construct a knowledge graph G and establish rule mapping relationships:
[0026] G = (V, E), V = {v1, v2, ..., v} n}, E={e1,e2,...,e m};
[0027] Where G represents the knowledge graph, V represents the entity set, and each entity v n Corresponding to the key concepts in the input data, these key concepts include category labels and attribute values, where E represents the set of relationships between entities, and each relationship e m Connect two entities to indicate their relationship;
[0028] Each relation e in the knowledge graph G m With weight w i This indicates the importance of the relationship and is set during initialization.
[0029]
[0030] Among them, w i Representing relation e m The weights, |E| represent the total number of relations;
[0031] S222. Perform rule generation and define dataset D:
[0032] D = {d1, d2, ..., d} k};
[0033] Where D represents the dataset, d k This represents the k-th data point, where k represents the total number of data points, and each data point is d. k From the eigenvector X k express:
[0034] X k =(x k1 ,x k2 ,...,x kn );
[0035] Among them, X i Let x represent the eigenvector. kn Represents data instance d k The nth feature value, where n represents the total number of features;
[0036] Define a set of rules:
[0037] R = {r1, r2, ..., r} p};
[0038] Where R represents the rule set, r p This represents the p-th rule, where p represents the total number of rules. Each rule is defined by the logical condition C(r). p ) and decision D(r p )composition:
[0039]
[0040] Where, r p Let C(r) represent the p-th rule. p ) represents the preconditions of the rule, D(r) p () represents the decision result of the rule, where the decision result is the data category and the prediction output;
[0041] S223. Employ policy gradient optimization-based reinforcement learning model optimization rules to construct a policy gradient optimization-based reinforcement learning model:
[0042] M = (S, A, P, R);
[0043] Where M represents the reinforcement learning model, S represents the state space, which is the matching state between the current data and the rule set, A represents the set of rule adjustment operations, and P represents the change from state s to s after performing operation a. ′ The probability of , where R represents the reward function, is used to measure the accuracy of rule classification:
[0044]
[0045] Where R represents the reward function, y k f represents the true category. r (X k The ) represents the classification result of the rule model, δ represents the indicator function, which takes the value 1 if the classification is correct and 0 otherwise, R represents the reward function, used to measure the accuracy of the rule classification, and k represents the total number of data points.
[0046] The rule adjustment operation set A includes:
[0047] Rule merging, merging similar rules r i and r j ;
[0048] Rule refinement, the prerequisite for rule refinement C(r) i );
[0049] Rule deletion: Delete rules with low contribution.
[0050] S224. Dynamically adjust the importance of rules and update rule weights based on changes in data distribution:
[0051]
[0052] Among them, w′ i The updated rule weight is represented by γ, which represents the rule update rate and controls the adjustment rate of rule importance. i δ(y) represents the rule weights from the previous training round, k represents the total number of data points, and δ(y) represents the total number of data points. j ,f r (X j )) represents the indicator function, y j Representing data X j The true category;
[0053] S225. Based on the updated rule weights, calculate the classification result of the rule model:
[0054]
[0055] Among them, y r r represents the classification result of the rule-based model. j Representation rule, δ(r) j ,x i ) represents sample xi Does it conform to rule r? j , w′ j c represents the updated rule weight. k This represents the set of candidate categories, and argmax represents the variable value that takes the maximum value.
[0056] Optionally, S23 specifically includes:
[0057] S231. Construct the input feature matrix:
[0058] X∈R k×n ;
[0059] Where X represents the input feature matrix, k represents the total number of samples, n represents the total number of features, R represents the set of real numbers, and ∈ means "belongs to";
[0060] Each sample x i From n-dimensional eigenvectors X i =(x i1 ,x i2 ,...,x in )composition;
[0061] S232. Feature learning is performed using an improved dual contrastive learning approach. Contrastive learning is conducted in the feature space for each sample x. i Generate samples from two different perspectives to form a positive sample pair P. f :
[0062]
[0063] Among them, P f Indicates positive sample pairs. and This represents positive samples from two different perspectives;
[0064] Select sample x j As negative samples, two samples from different perspectives are generated, forming negative sample pairs N. f :
[0065]
[0066] Where, N f Indicates negative sample pairs, and This represents negative samples from two different perspectives;
[0067] Calculate the feature similarity between positive and negative sample pairs:
[0068]
[0069] Among them, S f (xi ,x j ) represents the feature similarity between positive and negative sample pairs, h f (x i ) represents the feature embedding function, ∥∥ represents the norm, W2, W1, b1, and b2 represent the training parameters, σ represents the ReLU activation function, and W p Represents the projection matrix;
[0070] S233. Perform contrastive learning in the category space, construct a set of category labels, and generate positive and negative sample pairs:
[0071] P c ={(x i ,x j )|y i =y j};
[0072] N c ={(x i ,x j )|y i ≠y j};
[0073] Among them, P f N represents positive sample pairs. c Represents negative sample pairs, y i and y j Represents a collection of category labels;
[0074] Calculate the feature similarity between positive and negative sample pairs:
[0075]
[0076] Among them, S c (y i ,y j ) represents the feature similarity between positive and negative sample pairs, h c This represents a category embedding function, which is mapped using a nonlinear transformation layer;
[0077] S234. Perform contrastive learning in the global space and calculate the global feature centers:
[0078]
[0079] Where g represents the global feature center, h g This represents the graph neural network embedding function;
[0080] Calculate sample x i Similarity to the global feature center g:
[0081]
[0082] Among them, S g (x i (g) represents sample x i Similarity with the global feature center g, h g (x i ) represents the graph neural network embedding function;
[0083] S235. Calculate the feature space contrast loss:
[0084]
[0085] Among them, L f Represents the feature space contrast loss, τ f The temperature parameter represents the feature contrastive learning parameter, which controls the distribution range of the contrastive loss; exp represents the natural exponential function.
[0086] Calculate the class space contrast loss:
[0087]
[0088] Among them, L c Represents the class space contrast loss, τ c Temperature parameters representing category comparison learning;
[0089] Calculate the global spatial contrast loss:
[0090]
[0091] Among them, L g τ represents the global spatial contrast loss. g P represents the temperature parameter used in global comparative learning. g N represents a positive sample pair with the global center. g This represents a negative sample pair between a sample and the global center;
[0092] Calculate the joint loss:
[0093] L=αL f +βL c +γL g ;
[0094] Where L represents the joint loss, and α, β and γ represent the weighting coefficients;
[0095] S236. Optimize the parameters using gradient descent to minimize the joint loss, and finally generate the classification results of the learned model:
[0096]
[0097] Among them, y lf represents the classification result of the learned model. θ (·) indicates improved dual-contrast learning, c k Let x represent the set of candidate categories, θ represent the parameters for improving dual-contrast learning, and x represent the set of candidate categories. i Indicates a sample.
[0098] Optionally, S3 specifically includes:
[0099] S31. Define the uncertainty of the rule model and use information entropy to measure classification stability:
[0100] P r ={P(y r1 ),P(y r2 ),...,P(y rk )};
[0101]
[0102] Among them, P r σ represents the predicted class distribution of the rule model. r P(y) represents the uncertainty of the rule model. rk ) and P(y ri ) represents the category probability distribution of the rule model;
[0103] S32. Define the uncertainty of the learning model and use information entropy to measure classification stability:
[0104] P l ={P(y l1 ),P(y l2 ),...,P(y lk )};
[0105]
[0106] Among them, P l σ represents the distribution of predicted classes in the learning model. l P(y) represents the uncertainty of the learning model. lk ) and P(y li ) represents the category probability distribution of the rule model;
[0107] S33. Define adaptive weights:
[0108]
[0109] Where, λ a Indicates adaptive weights;
[0110] S34. An improved dual attention mechanism is adopted to calculate the feature attention matrix and perform weighted adjustments on the feature attention matrix to obtain the feature classification result. The improved dual attention mechanism includes feature attention and category attention.
[0111]
[0112] Y′ f =A f ·Y f ;
[0113] Among them, A f Let Y represent the feature attention matrix, softmax represent normalization, Q and K represent the query vector and the output vector of the rule and learning model, respectively, d represent the feature dimension, T represents the transpose operation, and Y represents the feature attention matrix. f This represents the preliminary classification result, Y′ f Indicates the feature classification result;
[0114] S35. Calculate the category attention matrix and adjust it based on classification confidence and adaptive weights:
[0115]
[0116] Y′ c =A c ·Y′ f ;
[0117] Among them, A c Let Q represent the category attention matrix, softmax represent normalization, and Q represent the class attention matrix. c and K c Let d represent the query vector for category labels and the category output vector of the rule and learning model, respectively. c This represents the category label dimension, T represents the transpose operation, and C represents the category label dimension. r C represents the classification confidence of the rule-based model. l λ represents the classification confidence of the learning model. a Y′ represents the adaptive weights. f Y′ represents the feature classification result. c This indicates the final classification result.
[0118] The beneficial effects of this invention are:
[0119] First, this method introduces knowledge graph reasoning and reinforcement learning into the rule model, enabling dynamic generation and optimization of rules based on the characteristics of new data. This allows the rule model to move away from fixed expert knowledge and automatically learn data patterns through inductive logical reasoning. Furthermore, reinforcement learning based on policy gradient optimization dynamically updates the rules and adjusts weights. This approach not only enhances the adaptability of the rule model, ensuring its effectiveness even with changing data distributions, but also reduces reliance on manually set rules, improving the automation level of the classification system. In addition, the knowledge graph-based rule reasoning mechanism can mine high-order feature relationships in complex data environments, making the rule model's reasoning ability more robust, thereby improving its scalability and learning capacity.
[0120] Secondly, an improved dual-contrast learning method was employed in the learning model, performing contrastive learning in the feature space, class space, and global space respectively. This enabled the learning model to extract data patterns more fully, improving classification accuracy. Contrastive learning in the feature space enhanced the discriminative power of sample features, contrastive learning in the class space optimized intra-class aggregation and inter-class separability, while contrastive learning in the global space ensured the stability of the overall feature distribution. Through this multi-level optimization strategy, the learning model maintained high generalization ability even when facing data distribution drift, thus stably adapting to new data during long-term operation and improving the accuracy and reliability of data classification.
[0121] Finally, this method improves the dual attention mechanism by establishing a dynamic weight adjustment strategy between the rule model and the learning model. Unlike traditional fixed-weight fusion methods, the adaptive fusion strategy of this invention can calculate the weights of the rule model and the learning model based on classification confidence and adjust their contribution ratios under different data distributions, thereby ensuring the optimality of classification decisions. Combined with the uncertainty measurement method of information entropy, this invention can adjust the classification strategy according to real-time changes in data distribution, enabling the classification system to operate stably for a long time and avoiding model degradation caused by data distribution drift. Attached Figure Description
[0122] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0123] Figure 1 This is a flowchart of a dynamic data classification method based on a rule-based and learning hybrid model proposed in this invention;
[0124] Figure 2 This is a flowchart illustrating the construction process of the rule-learning hybrid model for a dynamic data classification method based on a rule-learning hybrid model proposed in this invention. Detailed Implementation
[0125] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0126] refer to Figure 1 and Figure 2 A dynamic data classification method based on a rule-based and learning hybrid model includes the following steps:
[0127] S1. Real-time acquisition of multi-source input data, and preprocessing to generate preprocessed data;
[0128] S2. Construct a hybrid model of rules and learning, input the preprocessed data into the hybrid model of rules and learning for classification, output the classification confidence, and generate preliminary classification results;
[0129] S3. Based on the classification confidence, the weights of the rule model and the learning model of the rule and learning hybrid model under different data distributions are adaptively adjusted according to the improved dual attention mechanism to optimize the preliminary classification results and generate the final classification results.
[0130] S4. When a change in data distribution is detected, the rule-learning hybrid model adjusts the rule set to optimize the classification results.
[0131] S5. Apply the rule-learning hybrid model to the actual classification task and update the rule model and learning model during the process.
[0132] In this embodiment, the multi-source input data includes structured data and unstructured data, supporting parallel processing of streaming data and batch data. The structured data includes database records, tabular data, and log files, while the unstructured data includes text, images, audio, and video data. The preprocessing includes format standardization, missing value imputation, outlier detection, feature extraction, and normalization.
[0133] In this embodiment, S2 specifically includes:
[0134] S21. Construct a rule-learning hybrid model, input preprocessed data into the rule-learning hybrid model, the rule-learning hybrid model includes a rule model and a learning model, the rule model includes a knowledge graph and a reinforcement learning model based on policy gradient optimization, and the learning model uses improved dual contrastive learning for feature learning;
[0135] S22. In the rule model, rules are generated based on knowledge graphs, and a reinforcement learning model based on policy gradient optimization is used to dynamically update the rules and adjust the weights of the rules. The classification results of the rule model are generated based on the weights.
[0136] S23. In the learning model, an improved dual contrastive learning method is used for feature learning, and the joint loss is calculated. The gradient descent method is used to optimize the parameters, minimize the joint loss, and generate the classification result of the learning model.
[0137] S24. Calculate the classification confidence scores of the rule model and the learning model based on their classification outputs:
[0138]
[0139] Among them, C r C represents the classification confidence of the rule-based model. l y represents the classification confidence of the learning model. ri Let y represent the classification output of the i-th sample in the rule model. li P(·) represents the classification output of the i-th sample of the learning model, P(·) represents the class probability distribution, and k represents the total number of samples;
[0140] S25. Calculate the preliminary classification results:
[0141]
[0142] Among them, Y f This indicates the preliminary classification results.
[0143] In this embodiment, S22 specifically includes:
[0144] S221. Construct a knowledge graph G and establish rule mapping relationships:
[0145] G = (V, E), V = {v1, v2, ..., v} n}, E={e1,e2,...,e m};
[0146] Where G represents the knowledge graph, V represents the entity set, and each entity v n Corresponding to the key concepts in the input data, these key concepts include category labels and attribute values, where E represents the set of relationships between entities, and each relationship e m Connect two entities to indicate their relationship;
[0147] Each relation e in the knowledge graph G m With weight w i This indicates the importance of the relationship and is set during initialization.
[0148]
[0149] Among them, w i Representing relation e mThe weights, |E| represent the total number of relations;
[0150] S222. Perform rule generation and define dataset D:
[0151] D = {d1, d2, ..., d} k};
[0152] Where D represents the dataset, d k This represents the k-th data point, where k represents the total number of data points, and each data point is d. k From the eigenvector X k express:
[0153] X k =(x k1 ,x k2 ,...,x kn );
[0154] Among them, X i Let x represent the eigenvector. kn Represents data instance d k The nth feature value, where n represents the total number of features;
[0155] Define a set of rules:
[0156] R = {r1, r2, ..., r} p};
[0157] Where R represents the rule set, r p This represents the p-th rule, where p represents the total number of rules. Each rule is defined by the logical condition C(r). p ) and decision D(r p )composition:
[0158]
[0159] Where, r p Let C(r) represent the p-th rule. p ) represents the preconditions of the rule, D(r) p () represents the decision result of the rule, where the decision result is the data category and the prediction output;
[0160] S223. Employ policy gradient optimization-based reinforcement learning model optimization rules to construct a policy gradient optimization-based reinforcement learning model:
[0161] M = (S, A, P, R);
[0162] Where M represents the reinforcement learning model, S represents the state space, which is the matching state between the current data and the rule set, A represents the set of rule adjustment operations, and P represents the change from state s to s after performing operation a. ′The probability of , where R represents the reward function, is used to measure the accuracy of rule classification:
[0163]
[0164] Where R represents the reward function, y k f represents the true category. r (X k The ) represents the classification result of the rule model, δ represents the indicator function, which takes the value 1 if the classification is correct and 0 otherwise, R represents the reward function, used to measure the accuracy of the rule classification, and k represents the total number of data points.
[0165] The rule adjustment operation set A includes:
[0166] Rule merging, merging similar rules r i and r j ;
[0167] Rule refinement, the prerequisite for rule refinement C(r) i );
[0168] Rule deletion: Delete rules with low contribution.
[0169] S224. Dynamically adjust the importance of rules and update rule weights based on changes in data distribution:
[0170]
[0171] Among them, w′ i The updated rule weight is represented by γ, which represents the rule update rate and controls the adjustment rate of rule importance. i δ(y) represents the rule weights from the previous training round, k represents the total number of data points, and δ(y) represents the total number of data points. j ,f r (X j )) represents the indicator function, y j Representing data X j The true category;
[0172] S225. Based on the updated rule weights, calculate the classification result of the rule model:
[0173]
[0174] Among them, y r r represents the classification result of the rule-based model. j Representation rule, δ(r) j ,x i ) represents sample x i Does it conform to rule r? j , w′ j c represents the updated rule weight. kThis represents the set of candidate categories, and argmax represents the variable value that takes the maximum value.
[0175] In this embodiment, S23 specifically includes:
[0176] S231. Construct the input feature matrix:
[0177] X∈R k×n ;
[0178] Where X represents the input feature matrix, k represents the total number of samples, n represents the total number of features, R represents the set of real numbers, and ∈ means "belongs to";
[0179] Each sample x i From n-dimensional eigenvectors X i =(x i1 ,x i2 ,...,x in )composition;
[0180] S232. Feature learning is performed using an improved dual contrastive learning approach. Contrastive learning is conducted in the feature space for each sample x. i Generate samples from two different perspectives to form a positive sample pair P. f :
[0181]
[0182] Among them, P f Indicates positive sample pairs. and This represents positive samples from two different perspectives;
[0183] Select sample x j As negative samples, two samples from different perspectives are generated, forming negative sample pairs N. f :
[0184]
[0185] Where, N f Indicates negative sample pairs, and This represents negative samples from two different perspectives;
[0186] Calculate the feature similarity between positive and negative sample pairs:
[0187]
[0188] Among them, S f (x i ,x j ) represents the feature similarity between positive and negative sample pairs, h f (x i) represents the feature embedding function, ∥∥ represents the norm, W2, W1, b1, and b2 represent the training parameters, σ represents the ReLU activation function, and W p Represents the projection matrix;
[0189] S233. Perform contrastive learning in the category space, construct a set of category labels, and generate positive and negative sample pairs:
[0190] P c ={(x i ,x j )|y i =y j};
[0191] N c ={(x i ,x j )|y i ≠y j};
[0192] Among them, P f N represents positive sample pairs. c Represents negative sample pairs, y i and y j Represents a collection of category labels;
[0193] Calculate the feature similarity between positive and negative sample pairs:
[0194]
[0195] Among them, S c (y i ,y j ) represents the feature similarity between positive and negative sample pairs, h c This represents a category embedding function, which is mapped using a nonlinear transformation layer;
[0196] S234. Perform contrastive learning in the global space and calculate the global feature centers:
[0197]
[0198] Where g represents the global feature center, h g This represents the graph neural network embedding function;
[0199] Calculate sample x i Similarity to the global feature center g:
[0200]
[0201] Among them, S g (x i (g) represents sample x iSimilarity with the global feature center g, h g (x i ) represents the graph neural network embedding function;
[0202] S235. Calculate the feature space contrast loss:
[0203]
[0204] Among them, L f Represents the feature space contrast loss, τ f The temperature parameter represents the feature contrastive learning parameter, which controls the distribution range of the contrastive loss; exp represents the natural exponential function.
[0205] Calculate the class space contrast loss:
[0206]
[0207] Among them, L c Represents the class space contrast loss, τ c Temperature parameters representing category comparison learning;
[0208] Calculate the global spatial contrast loss:
[0209]
[0210] Among them, L g τ represents the global spatial contrast loss. g P represents the temperature parameter used in global comparative learning. g N represents a positive sample pair with the global center. g This represents a negative sample pair between a sample and the global center;
[0211] Calculate the joint loss:
[0212] L=αL f +βL c +γL g ;
[0213] Where L represents the joint loss, and α, β and γ represent the weighting coefficients;
[0214] S236. Optimize the parameters using gradient descent to minimize the joint loss, and finally generate the classification results of the learned model:
[0215]
[0216] Among them, y l f represents the classification result of the learned model. θ (·) indicates improved dual-contrast learning, c k Let x represent the set of candidate categories, θ represent the parameters for improving dual-contrast learning, and x represent the set of candidate categories.i Indicates a sample.
[0217] In this embodiment, S3 specifically includes:
[0218] S31. Define the uncertainty of the rule model and use information entropy to measure classification stability:
[0219] P r ={P(y r1 ),P(y r2 ),...,P(y rk )};
[0220]
[0221] Among them, P r σ represents the predicted class distribution of the rule model. r P(y) represents the uncertainty of the rule model. rk ) and P(y ri ) represents the category probability distribution of the rule model;
[0222] S32. Define the uncertainty of the learning model and use information entropy to measure classification stability:
[0223] P l ={P(y l1 ),P(y l2 ),...,P(y lk )};
[0224]
[0225] Among them, P l σ represents the distribution of predicted classes in the learning model. l P(y) represents the uncertainty of the learning model. lk ) and P(y li ) represents the category probability distribution of the rule model;
[0226] S33. Define adaptive weights:
[0227]
[0228] Where, λ a Indicates adaptive weights;
[0229] S34. An improved dual attention mechanism is adopted to calculate the feature attention matrix and perform weighted adjustments on the feature attention matrix to obtain the feature classification result. The improved dual attention mechanism includes feature attention and category attention.
[0230]
[0231] Y′ f =A f ·Y f ;
[0232] Among them, A f Let Y represent the feature attention matrix, softmax represent normalization, Q and K represent the query vector and the output vector of the rule and learning model, respectively, d represent the feature dimension, T represents the transpose operation, and Y represents the feature attention matrix. f This represents the preliminary classification result, Y′ f Indicates the feature classification result;
[0233] S35. Calculate the category attention matrix and adjust it based on classification confidence and adaptive weights:
[0234]
[0235] Y′ c =A c ·Y′ f ;
[0236] Among them, A c Let Q represent the category attention matrix, softmax represent normalization, and Q represent the class attention matrix. c and K c Let d represent the query vector for category labels and the category output vector of the rule and learning model, respectively. c This represents the category label dimension, T represents the transpose operation, and C represents the category label dimension. r C represents the classification confidence of the rule-based model. l λ represents the classification confidence of the learning model. a Y′ represents the adaptive weights. f Y′ represents the feature classification result. c This indicates the final classification result.
[0237] Example 1:
[0238] To verify the feasibility of this invention in practice, it was applied to the real-time transaction anti-fraud system of a large commercial bank. This bank processes over 20 million credit card transactions daily, with fraudulent transactions accounting for approximately 1.2%, meaning about 240,000 fraudulent transactions need to be accurately identified each day. Traditional rule-based methods, relying on manually set rules, are prone to failure when faced with new fraudulent methods. While deep learning-based methods can automatically learn transaction patterns, their generalization ability is often weak when fraudulent transactions change, leading to high false positive or false negative rates.
[0239] In the method of this invention, transaction data is first preprocessed, including format standardization, outlier detection, and feature extraction, and then input into a hybrid rule-learning model. The rule model employs knowledge graph reasoning to generate rules based on historical fraudulent transaction patterns, and combines this with reinforcement learning based on policy gradient optimization to optimize the rules, ensuring adaptive adjustment. The learning model uses an improved dual-contrast learning approach, performing comparative learning in the feature space, category space, and global space respectively, improving the model's ability to extract fraudulent transaction patterns. After combining the two, an improved dual attention mechanism is used for fusion, dynamically adjusting classification decisions to ensure the accuracy of the classification results.
[0240] To objectively evaluate the classification performance of different methods, a comparison was made on five metrics: recall, precision, F1-Score, false positive rate calculation latency.
[0241] Table 1 Comparison of Experimental Data
[0242] Indicators / Methods Based on rules Based on deep learning Based on the present invention Recall rate 82.3% 88.7% 94.5% Accuracy 74.5% 80.1% 91.2% F1-Score 78.2% 84.2% 92.8% False alarm rate 4.3% 3.1% 1.6% Calculate latency (ms) 32.5 48.7 39.1
[0243] This experiment compares the performance of traditional rule-based methods, deep learning methods, and the hybrid rule-learning model of this invention in fraud transaction detection tasks. The analysis focuses on five core metrics: recall, precision, F1-Score, false positive rate, and computational latency, to evaluate the advantages and disadvantages of different methods in practical applications.
[0244] Regarding recall, traditional rule-based methods can capture a certain proportion of fraudulent transactions, with a recall rate of 82.3%. Deep learning methods, due to their ability to automatically learn data patterns, achieve a recall rate of 88.7%. This invention employs a hybrid rule-based and learning model, combining knowledge graph reasoning and reinforcement learning rule optimization mechanisms, as well as an improved dual-contrast learning method to optimize feature representation, resulting in a recall rate of 94.5%, significantly higher than traditional methods. This demonstrates that this method can detect more fraudulent transactions, reduce false negatives, and improve risk identification capabilities.
[0245] In terms of accuracy, traditional rule-based methods, relying on fixed rules, suffer from a high false positive rate when dealing with new fraudulent methods, resulting in an accuracy of only 74.5%. Deep learning methods, to some extent, reduce false positives and improve accuracy to 80.1%. The method of this invention combines the interpretability of rule-based models with the generalization ability of learning models, and optimizes classification weights through an improved dual attention mechanism, thereby increasing accuracy to 91.2% and significantly reducing the false positive rate. This demonstrates that this method can not only identify more fraudulent transactions but also reduce false positives, avoiding interference with legitimate users.
[0246] In terms of F1-Score, traditional rule-based methods achieve 78.2%, deep learning methods improve to 84.2%, while the method of this invention reaches 92.8%, indicating that this method can maintain a high recall rate while still ensuring a high precision rate, resulting in a more balanced overall classification performance.
[0247] Regarding the false positive rate, traditional rule-based methods have a high false positive rate of 4.3%, meaning that approximately 4.3 out of every 100 transactions are mistakenly identified as fraudulent. Deep learning methods reduce the false positive rate to 3.1%, but some misjudgments still occur. This invention employs a rule optimization method based on knowledge graphs and reinforcement learning, combined with a dynamic weighted fusion strategy based on classification confidence, reducing the false positive rate to 1.6%, significantly lower than traditional methods. This demonstrates that the method of this invention, while ensuring the identification of fraudulent transactions, significantly reduces false positives and improves the user experience.
[0248] Regarding computational latency, traditional rule-based methods are faster, with an average latency of 32.5ms, while deep learning methods, due to their complex neural network computations, have a longer latency of 48.7ms. The method of this invention optimizes computational efficiency while ensuring high classification accuracy, keeping the computational latency at 39.1ms, close to that of traditional rule-based methods and significantly lower than that of deep learning methods, thus ensuring the real-time performance of the system in high-concurrency transaction environments.
[0249] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A dynamic data classification method based on a hybrid model of rules and learning, characterized in that, Includes the following steps: S1. Real-time acquisition of multi-source input data, and preprocessing to generate preprocessed data; S2. Construct a hybrid model of rules and learning, input the preprocessed data into the hybrid model of rules and learning for classification, output the classification confidence, and generate preliminary classification results; S3. Based on the classification confidence, the weights of the rule model and the learning model of the rule and learning hybrid model under different data distributions are adaptively adjusted according to the improved dual attention mechanism to optimize the preliminary classification results and generate the final classification results. S4. When a change in data distribution is detected, the rule-learning hybrid model adjusts the rule set to optimize the classification results. S5. Apply the rule-learning hybrid model to the actual classification task, and update the rule model and the learning model during the process; The multi-source input data includes structured and unstructured data, and supports parallel processing of streaming and batch data. The structured data includes database records, tabular data, and log files, while the unstructured data includes text, images, audio, and video data. S3 specifically includes: S31. Define the uncertainty of the rule model and use information entropy to measure classification stability: ; ; in, This represents the distribution of predicted categories in the rule-based model. This represents the uncertainty of the rule-based model. and Represents the category probability distribution of the rule model; S32. Define the uncertainty of the learning model and use information entropy to measure classification stability: ; ; in, This represents the distribution of predicted classes by the learning model. This indicates the uncertainty of the learning model. and Represents the category probability distribution of the rule model; S33. Define adaptive weights: ; in, Indicates adaptive weights; S34. An improved dual attention mechanism is adopted to calculate the feature attention matrix and perform weighted adjustments on the feature attention matrix to obtain the feature classification result. The improved dual attention mechanism includes feature attention and category attention. ; ; in, Represents the feature attention matrix. Indicates normalization, and These represent the query vector and the output vector of the rule and learning model, respectively, from the input feature matrix. Representing feature dimension, This indicates the transpose operation. This indicates the preliminary classification results. Indicates the feature classification result; S35. Calculate the category attention matrix and adjust it based on classification confidence and adaptive weights: ; ; in, Represents the category attention matrix, Indicates normalization, and These represent the query vector for category labels and the category output vector of the rule and learning model, respectively. Indicates the category label dimension. This indicates the transpose operation. This represents the classification confidence score of the rule-based model. This represents the classification confidence score of the learned model. Indicates adaptive weights, Indicates the feature classification result, This indicates the final classification result.
2. The dynamic data classification method based on a rule-based and learning hybrid model according to claim 1, characterized in that, The preprocessing includes format standardization, missing value imputation, outlier detection, feature extraction, and normalization.
3. The dynamic data classification method based on a rule-based and learning hybrid model according to claim 1, characterized in that, S2 specifically includes: S21. Construct a rule-learning hybrid model, input preprocessed data into the rule-learning hybrid model, the rule-learning hybrid model includes a rule model and a learning model, the rule model includes a knowledge graph and a reinforcement learning model based on policy gradient optimization, and the learning model uses improved dual contrastive learning for feature learning; S22. In the rule model, rules are generated based on knowledge graphs, and a reinforcement learning model based on policy gradient optimization is used to dynamically update the rules and adjust the weights of the rules. The classification results of the rule model are generated based on the weights. S23. In the learning model, an improved dual contrastive learning method is used for feature learning, and the joint loss is calculated. The gradient descent method is used to optimize the parameters, minimize the joint loss, and generate the classification result of the learning model. S24. Calculate the classification confidence scores of the rule model and the learning model based on their classification outputs: ; ; in, This represents the classification confidence score of the rule-based model. This represents the classification confidence score of the learned model. The first rule model represents the first rule model. The classification output for each sample. The first part represents the learning model. The classification output for each sample. Represents the probability distribution of categories. Indicates the total number of samples; S25. Calculate the preliminary classification results: ; in, This indicates the preliminary classification results.
4. The dynamic data classification method based on a rule-based and learning hybrid model according to claim 3, characterized in that, S22 specifically includes: S221. Constructing a knowledge graph Establish rule mapping relationships: ; in, Representing a knowledge graph, Represents a collection of entities, each entity Corresponding to the key concepts in the input data, the key concepts include category labels and attribute values. Represents a set of relationships between entities, each relationship Connect two entities to indicate their relationship; knowledge graph Each relation in With weight This indicates the importance of the relationship and is set during initialization. ; in, Representing relations The weight, Represents the total number of relations; S222. Perform rule generation and define the dataset. : ; in, Represents a dataset, Indicates the first Each data point From the eigenvector express: ; in, Represents the eigenvector. Represents a data instance The 1 eigenvalue, Indicates the total number of features; Define a set of rules: ; in, Represents a set of rules. Indicates the first Rule 1 This represents the total number of rules, and each rule consists of logical conditions. and decision composition: ; in, Indicates the first Rule 1 This indicates the preconditions for the rule. The decision result of the rule is represented by the data category and the prediction output; S223. Employ policy gradient optimization-based reinforcement learning model optimization rules to construct a policy gradient optimization-based reinforcement learning model: ; in, This represents a reinforcement learning model. This represents the state space, which shows the matching state between the current data and the rule set. This represents the set of rule adjustment operations. Indicates the execution of an operation After state Become The probability, This represents the reward function, used to measure the accuracy of rule-based classification: ; in, Represents the reward function, Indicates the true category, This represents the classification result of the rule-based model. This is an indicator function; it takes the value 1 if the classification is correct, and 0 otherwise. This represents the reward function, used to measure the accuracy of rule-based classification. Indicates the total number of data points: The set of rule adjustment operations include: Rule merging, merging similar rules and ; Detailing the rules and the prerequisites for refining the rules. ; Rule deletion: Delete rules with low contribution. S224. Dynamically adjust the importance of rules and update rule weights based on changes in data distribution: ; ; in, This indicates the updated rule weight. This indicates the rule update rate, controlling the adjustment rate of rule importance. This represents the rule weights from the previous training round. Indicates the total number of data. Indicates an indicator function, Representing data The true category; S225. Based on the updated rule weights, calculate the classification result of the rule model: ; in, This represents the classification result of the rule-based model. Representation rules, Indicates sample Does it comply with the rules? , This indicates the updated rule weight. Represents the set of candidate categories. This represents the variable value that takes the maximum value.
5. The dynamic data classification method based on a rule-based and learning hybrid model according to claim 3, characterized in that, S23 specifically includes: S231. Construct the input feature matrix: ; in, Represents the input feature matrix. Represents the total number of samples. Represents the total number of features. Represents the set of real numbers. Indicates "belongs to"; Each sample Depend on 3D feature vector composition; S232. Feature learning is performed using an improved dual contrastive learning approach, which involves contrastive learning in the feature space for each sample. Generate two samples from different perspectives to form a positive sample pair. : ; in, Indicates a positive sample pair. and This represents positive samples from two different perspectives; Selecting samples As negative samples, two samples from different perspectives are generated to form a negative sample pair. : ; in, Indicates negative sample pairs, and This represents negative samples from two different perspectives; Calculate the feature similarity between positive and negative sample pairs: ; ; in, This represents the feature similarity between positive and negative sample pairs. Represents the feature embedding function. Represents the norm, , , and Represents training parameters, Represents the ReLU activation function. Represents the projection matrix; S233. Perform contrastive learning in the category space, construct a set of category labels, and generate positive and negative sample pairs: ; ; in, Indicates a positive sample pair. Indicates negative sample pairs, and Represents a collection of category labels; Calculate the feature similarity between positive and negative sample pairs: ; in, This represents the feature similarity between pairs of positive and negative samples. This represents a category embedding function, which is mapped using a nonlinear transformation layer; S234. Perform contrastive learning in the global space and calculate the global feature center: ; in, Represents the global feature center. This represents the graph neural network embedding function; Calculate samples With global feature center Similarity: ; in, Indicates sample With global feature center similarity, This represents the graph neural network embedding function; S235. Calculate the feature space contrast loss: ; in, Represents the feature space contrast loss. The temperature parameter represents the feature contrastive learning parameter and controls the distribution range of the contrastive loss. Represents the natural exponential function; Calculate the class space contrast loss: ; in, Represents the category space contrast loss. Temperature parameters representing category comparison learning; Calculate the global spatial contrast loss: ; in, Represents the global spatial contrast loss. The temperature parameter represents the global comparative learning. This represents a positive sample pair with the global center. This represents a negative sample pair between a sample and the global center; Calculate the joint loss: ; in, Indicates joint loss, , and Indicates the weighting coefficient; S236. Optimize the parameters using gradient descent to minimize the joint loss, and finally generate the classification result of the learned model: ; in, This represents the classification result of the learned model. This indicates an improvement in dual-contrast learning. Represents the set of candidate categories. This represents the parameters for improving dual-contrast learning. Indicates a sample.
Citation Information
Patent Citations
Junk mail classification method based on sample difficulty
CN111582365A
Extraction of Anomaly Related Rules Using Data Mining and Machine Learning
US20200242417A1