Transaction classification method and device, equipment and storage medium
By filtering user transaction data and inputting it into the fusion offline model and text online model, and calculating and fusing classification probability, the problem of low classification efficiency of existing user trading systems is solved, more efficient and accurate transaction classification is achieved, and real-time results are provided.
Patent Information
- Application Number
- CN202411576292.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-04-18
AI Technical Summary
The existing user trading system has low classification efficiency, is difficult to cope with rapid changes in transaction types, and is insufficient real-time.
By filtering user transaction data, input it into the fusion offline model and the text online model, the first and second classification probabilities are calculated respectively, and the target classification results are determined through probability fusion.
It improves the efficiency and accuracy of transaction classification, can better cope with rapid changes in transaction types, and provides real-time classification results.
Smart Images

Figure CN119850335A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of transaction classification, and in particular to a transaction classification method, apparatus, device and storage medium. Background Art
[0002] Currently, the classification of user trading systems mostly relies on traditional expert rules or single classification models that are manually labeled and refined. This approach has several limitations: the rule base needs to rely on manual maintenance, and when unforeseen new transaction types or new financial products appear, the rules may not be covered, resulting in inaccurate classification, and it is difficult to cope with the rapid changes in transaction types; a single model may not be able to adequately recognize certain complex transaction patterns, and has weak robustness to data changes, affecting classification accuracy; traditional systems mostly use pure offline models to calculate classification results, and update models and classification results T+1, which is not real-time enough for real-time classification scenarios of user transactions. Therefore, how to solve the low efficiency of classification in existing user trading systems has become an urgent problem to be solved. Summary of the invention
[0003] The main purpose of this application is to provide a transaction classification method, device, equipment and storage medium, aiming to solve the technical problem of low classification efficiency of existing user transaction systems.
[0004] To achieve the above objectives, the present application proposes a transaction classification method, which includes:
[0005] Filter user transaction data according to transaction type screening rules and preset screening order to obtain model transaction data;
[0006] Inputting the model transaction data into the fusion offline model to obtain a first classification probability;
[0007] Inputting the model transaction data into the text online model to obtain a second classification probability;
[0008] A target classification result is determined according to the first classification probability and the second classification probability.
[0009] In one embodiment, the step of determining a target classification result according to the first classification probability and the second classification probability includes:
[0010] Normalizing the first classification probability and the second classification probability respectively to obtain a first normalized probability and a second normalized probability;
[0011] Performing a fusion calculation according to the first normalized probability and the second normalized probability to obtain a target fusion probability;
[0012] The corresponding target classification result is determined according to the target fusion probability.
[0013] In one embodiment, the step of inputting the model transaction data into the fusion offline model to obtain the first classification probability includes:
[0014] Input the model transaction data into the fusion offline model, perform probability calculation on the model transaction data according to the general classification rules in the fusion offline model, and obtain a general transaction probability;
[0015] Probability calculation is performed according to the keyword classification rules in the fused offline model, the model transaction data and the background database to obtain the keyword transaction probability;
[0016] Probability calculation is performed according to the label classification rules in the fused offline model, the model transaction data and the background database to obtain the label transaction probability;
[0017] The general transaction probability, the keyword transaction probability and the tag transaction probability are summarized to obtain a first classification probability.
[0018] In one embodiment, before the step of performing probability calculation according to the keyword classification rules in the fused offline model, the model transaction data and the background database to obtain the keyword transaction probability, the step further includes:
[0019] Obtain multiple historical transaction probabilities based on the machine learning classification model and historical transaction data;
[0020] Fusion of multiple historical transaction probabilities according to a preset fusion model to obtain a historical fusion probability;
[0021] The initial database is updated according to the historical fusion probability to obtain a background database.
[0022] In one embodiment, inputting the model transaction data into the text online model to obtain the second classification probability includes:
[0023] Preprocessing the model transaction data to obtain preprocessed transaction data;
[0024] Input the pre-processed transaction data into the text online model for probability calculation to obtain the text transaction probability and the model version number;
[0025] When the model version number is a preset version number, the text transaction probability is determined to be a second classification probability.
[0026] In one embodiment, before the step of inputting the pre-processed transaction data into the text online model for probability calculation to obtain the text transaction probability and the model version number, the step further includes:
[0027] Perform classification processing based on the fused offline model and initial transaction data to obtain classified transaction data;
[0028] Marking the classified transaction data to obtain model training data;
[0029] The initial online model is trained according to the model training data to obtain a text online model.
[0030] In one embodiment, after the step of inputting the model transaction data into the text online model to obtain the second classification probability, the step further includes:
[0031] Get the fusion calculation time and text calculation time;
[0032] Determine a time comparison result based on a timeout threshold, the fusion calculation time, and the text calculation time;
[0033] When the time comparison result is that the fusion calculation time is less than the timeout threshold and the text calculation time is greater than or equal to the timeout threshold, the target classification result is determined according to the first classification probability.
[0034] In addition, to achieve the above purpose, the present application also proposes a transaction classification device, the transaction classification device comprising:
[0035] A screening module is used to screen user transaction data according to transaction type screening rules and preset screening order to obtain model transaction data;
[0036] A calculation module, used for inputting the model transaction data into the fusion offline model to obtain a first classification probability;
[0037] The calculation module is further used to input the model transaction data into the text online model to obtain a second classification probability;
[0038] A classification module is used to determine a target classification result according to the first classification probability and the second classification probability.
[0039] In addition, to achieve the above objectives, the present application also proposes a transaction classification device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the transaction classification method described above.
[0040] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the transaction classification method described above are implemented.
[0041] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the transaction classification method described above are implemented.
[0042] This application obtains model transaction data by filtering user transaction data according to transaction type screening rules and preset screening order; inputs the model transaction data into the fusion offline model to obtain the first classification probability; inputs the model transaction data into the text online model to obtain the second classification probability; and determines the target classification result according to the first classification probability and the second classification probability. The classification results are returned in real time based on the offline model analysis platform model and the BERT text classification algorithm online model respectively. Both methods will return the probability value in each classification, and the returned probability values will be normalized and averaged and fused to finally determine the target classification result, thereby improving the efficiency and accuracy of transaction classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0045] Figure 1 A flowchart of the first embodiment of the transaction classification method of the present application is provided;
[0046] Figure 2 A schematic diagram of the income and expenditure classification process provided for the first embodiment of the transaction classification method of this application;
[0047] Figure 3 Schematic diagram of the TinyBERT deep learning model provided for Example 1 of the transaction classification method of this application;
[0048] Figure 4 A flow chart of the second embodiment of the transaction classification method of the present application;
[0049] Figure 5 A brief flowchart of the transaction classification method provided in Example 1 of the present application;
[0050] Figure 6 This is a schematic diagram of the module structure of the transaction classification device according to an embodiment of the present application;
[0051] Figure 7A schematic diagram of the device structure of the hardware operating environment involved in the transaction classification method in the embodiment of the present application.
[0052] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0053] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0054] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0055] The main solution of the embodiment of the present application is: filter the user transaction data according to the transaction type screening rules and the preset screening order to obtain the model transaction data; input the model transaction data to the fusion offline model to obtain the first classification probability; input the model transaction data to the text online model to obtain the second classification probability; determine the target classification result according to the first classification probability and the second classification probability.
[0056] Currently, the classification of user trading systems mostly relies on traditional expert rules or single classification models that are manually labeled and refined. This approach has several limitations: the rule base needs to rely on manual maintenance, and when unforeseen new transaction types or new financial products appear, the rules may not be covered, resulting in inaccurate classification, and it is difficult to cope with the rapid changes in transaction types; a single model may not be able to adequately recognize certain complex transaction patterns, and has weak robustness to data changes, affecting classification accuracy; traditional systems mostly use pure offline models to calculate classification results, and update models and classification results T+1, which is not real-time enough for real-time classification scenarios of user transactions. Therefore, how to solve the low efficiency of classification in existing user trading systems has become an urgent problem to be solved.
[0057] This application obtains model transaction data by filtering user transaction data according to transaction type screening rules and preset screening order; inputs the model transaction data into the fusion offline model to obtain the first classification probability; inputs the model transaction data into the text online model to obtain the second classification probability; and determines the target classification result according to the first classification probability and the second classification probability. The classification results are returned in real time based on the offline model analysis platform model and the BERT text classification algorithm online model respectively. Both methods will return the probability value in each classification, and the returned probability values will be normalized and averaged and fused to finally determine the target classification result, thereby improving the efficiency and accuracy of transaction classification.
[0058] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a transaction classification device capable of realizing the above functions, etc. The following takes the transaction classification device as the execution subject as an example to illustrate this embodiment and the following embodiments.
[0059] Based on this, the present application embodiment provides a transaction classification method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the transaction classification method of the present application.
[0060] In this embodiment, the transaction classification method includes steps S10 to S40:
[0061] Step S10, filtering the user transaction data according to the transaction type filtering rule and the preset filtering order to obtain model transaction data;
[0062] It should be noted that the retail income and expenditure classification has designed a label system according to user consumption preferences to meet users' refined management needs for different transaction types. The classification labels include 3 first-level categories of income, expenditure, and personal fund transactions, 41 second-level categories including red envelopes, insurance, other investments, etc., and 84 third-level categories including red envelope income, auto insurance, stocks, etc. Each category has a corresponding classification code. Currently, the second-level classification is displayed to users, and the third-level classification is used for detailed analysis. The classification diagram is shown in Table 1.
[0063] Table 1:
[0064]
[0065] It should be noted that in this embodiment, Zhonghe's current real-time income and expenditure machine learning solution is implemented by integrating two machine learning models. One is based on the calculation results of the offline model analysis platform model. This model adopts the Bayesian model and the CNN model (Convolutional Neural Network) for fusion calculation. The result is loaded into the real-time hbase table (hbase is a distributed, column-oriented open source database designed to process large-scale data sets) through the exchange platform on day t+1 as background data. The real-time stream computing application dynamically calculates the probability value of the user transaction in each category based on the user transaction input elements and the associated background data. The other is based on the BERT (Bidirectional Encoder Representations from Transformers) text classification algorithm online model to return the classification results in real time. Both methods will return the probability value in each category, normalize the returned probability value and average it, and finally take the category with the highest probability as the final user transaction category.
[0066] It can be understood that the transaction type screening rules include user personalized classification rules, general crowdsourcing classification rules, basic classification rules and machine learning classification rules, etc. The preset screening order refers to the pre-set classification screening order, user transaction data refers to the data records generated when users conduct various transaction activities, and model transaction data refers to data that needs to be classified by machine (model).
[0067] In the specific implementation, the flow chart of income and expenditure classification is as follows: Figure 2 As shown, the income and expenditure transaction process in this embodiment is mainly divided into four parts, user personalized classification, general crowdsourcing classification, basic classification, and machine learning classification. The funnel-type screening enters the next level of classification in order, and finally screens out the data that needs to be classified by the machine. User personalized classification is based on the rules extracted by users who have modified the classification rules for specific transactions many times. The general crowdsourcing classification is the rules extracted by analyzing the historical modification records of all users under the same merchant name. The general crowdsourcing rules are valid for all users and are only applicable to consumer shopping transactions. Basic rules business experts classify transactions based on business knowledge and extract calculation rules after manual analysis of data. Machine learning mainly further classifies transactions that cannot be directly classified by user personalized classification, general crowdsourcing classification, and basic classification to further improve the correctness of classification, and finally obtains data that needs to be classified by machine (model), that is, model transaction data.
[0068] Step S20, inputting the model transaction data into the fusion offline model to obtain a first classification probability;
[0069] It can be understood that the fused offline model refers to a model based on the offline model analysis platform. This model adopts the Bayes model and the CNN model for fusion calculation. The first classification probability refers to the probability value of user transactions in each classification output by the fused offline model.
[0070] In the specific implementation, the Bayesian model and CNN model (Convolutional Neural Network) are used to perform fusion calculations on the model transaction data. The results are loaded into the real-time HBase table as background data through the exchange platform on day t+1 (HBase is a distributed, column-oriented open source database designed to process large-scale data sets). The real-time stream computing application dynamically calculates the probability value of the user transaction in each category based on the user transaction input elements and the associated background data, that is, the first category probability.
[0071] Step S30, inputting the model transaction data into the text online model to obtain a second classification probability;
[0072] It can be understood that the text online model refers to an online model based on the BERT (Bidirectional Encoder Representations from Transformers) text classification algorithm, and the second classification probability refers to the probability value of user transactions in each category output by the text online model.
[0073] In the specific implementation, the data that needs to be classified by the machine (model) is input into the online model based on the BERT text classification algorithm for probability calculation, and then the probability value of user transactions in each category based on the output of the online model of the BERT text classification algorithm is obtained, that is, the second classification probability.
[0074] In a feasible implementation, step S30 may include steps A31 to A33:
[0075] Step A31, preprocessing the model transaction data to obtain preprocessed transaction data;
[0076] It can be understood that preprocessed transaction data refers to the preprocessed data that needs to be machine classified, for example, removing irrelevant information: removing data fields that are not related to the classification task, such as user ID, transaction timestamp, etc.; processing missing values: filling or deleting records with missing values to ensure data integrity; deduplication: removing duplicate records to avoid interference with model training.
[0077] Step A32, inputting the pre-processed transaction data into the text online model for probability calculation to obtain the text transaction probability and the model version number;
[0078] It can be understood that the text transaction probability refers to the probability value of user transactions in each category calculated by the model, and the model version number refers to the version number returned after the model is calculated in real time (conventionally marked with 0 or 1).
[0079] In the specific implementation, the pre-processed data that needs to be machine classified is input into the online model based on the BERT text classification algorithm for probability calculation, and the probability value of the user transaction in each category is obtained by the model calculation. The version number, i.e., the model version number, is returned after the model is calculated in real time.
[0080] Step A33, when the model version number is a preset version number, determining the text transaction probability as a second classification probability.
[0081] It can be understood that the preset version number refers to a pre-selected model version number, and in this embodiment, 1 is taken for explanation.
[0082] In a specific implementation, when the model version number is 1, it indicates that the current model can return the classification results normally and timely, and then the probability value of the user transaction in each classification calculated by the model is used as the second classification probability.
[0083] In a feasible implementation manner, step A33 may include steps B31 to B33:
[0084] Step B31, performing classification processing based on the fused offline model and the initial transaction data to obtain classified transaction data;
[0085] It can be understood that the initial transaction data refers to unclassified transaction data, and the classified transaction data refers to transaction data after classification processing.
[0086] In the specific implementation, the PU-Learning (positive unlabeled learning) framework is used for semi-supervised learning of new sample labels, and the Bayes model and CNN model are fused with the offline model to perform preliminary classification of unclassified transaction data to obtain the transaction data after classification processing, namely, classified transaction data.
[0087] Step B32, labeling the classified transaction data to obtain model training data;
[0088] It can be understood that model training data refers to the sample data used to train the BERT model.
[0089] In the specific implementation, the classified data is sampled and manually labeled, and then the manually labeled data is used as sample data for training the BERT model, that is, model training data.
[0090] Step B33, training the initial online model according to the model training data to obtain a text online model.
[0091] In the specific implementation, the initial online model refers to the initial BERT algorithm online model. BERT is fine-tuned according to the sample data used to train the BERT model, and the fine-tuned model is used to predict new samples. Samples with low confidence rates are manually annotated and added to the training samples. After continuous iteration, more accurate and balanced samples are obtained. Finally, an online model based on the BERT text classification algorithm is obtained, namely, a text online model.
[0092] In a feasible implementation manner, step A33 may include steps C31 to C33:
[0093] Step C31, obtaining fusion calculation time and text calculation time;
[0094] It can be understood that the fusion calculation time refers to the time for calculating the transaction classification probability based on the offline model analysis platform model (offline Bayes+CNN model), and the text calculation time refers to the time for calculating the transaction classification probability based on the BERT text classification algorithm online model.
[0095] Step C32, determining a time comparison result based on a timeout threshold, the fusion calculation time, and the text calculation time;
[0096] It can be understood that the timeout threshold refers to the critical time value used to determine whether the model calculation has timed out, and the time comparison result refers to the comparison result of whether the time for calculating the transaction classification probability based on the offline model analysis platform model and / or the BERT text classification algorithm online model has timed out.
[0097] In a specific implementation, the time for calculating the transaction classification probability based on the offline model analysis platform model (offline Bayes+CNN model) and the time for calculating the transaction classification probability based on the BERT text classification algorithm online model are compared with the time critical value for determining whether the model calculation has timed out, so as to obtain a comparison result of whether the time for calculating the transaction classification probability based on the offline model analysis platform model and / or the time for calculating the transaction classification probability based on the BERT text classification algorithm online model has timed out.
[0098] Step C33, when the time comparison result is that the fusion calculation time is less than the timeout threshold and the text calculation time is greater than or equal to the timeout threshold, determine the target classification result according to the first classification probability.
[0099] In a specific implementation, when the time comparison result is that the time for calculating the transaction classification probability based on the offline model analysis platform model is less than the time critical value for judging whether the model calculation has timed out, and the time for calculating the transaction classification probability based on the BERT text classification algorithm online model is greater than or equal to the time critical value for judging whether the model calculation has timed out, it indicates that the calculation based on the offline model analysis platform model has not timed out and the calculation based on the BERT text classification algorithm online model has timed out, and then the target classification result is determined only based on the first classification probability output by the offline model analysis platform model.
[0100] It should be noted that if Figure 3 As shown, in this embodiment, the online model based on the BERT text classification algorithm calculates the user transaction classification in real time. The advancement of the BERT model lies in its deep learning ability, which can quickly capture the contextual information of the text and can handle complex semantics and polysemous words. Especially when dealing with newly emerged vocabulary and sentence patterns, its generalization ability is significant, avoiding the overfitting problem that traditional models may encounter. (1) Semi-supervised learning of new sample labels with the help of the PU-Learning framework. The Bayes model and the CNN model are used to fuse the offline model for preliminary classification, and the classified data are sampled and manually labeled. The BERT is fine-tuned with the manually labeled samples, and the fine-tuned model is used to predict new samples. Samples with low confidence rates are manually labeled and added to the training samples. After continuous iteration, more accurate and balanced samples are obtained; (2) TinyBERT is used to improve timeliness. Compared with BERT, TinyBERT consumes less resources and has higher efficiency. Although its structure is compact, it can still capture the key information of the text and quickly assign probability values to user transactions. It can meet the requirements of fast classification speed and high accuracy when processing a large amount of transaction data in real time. As follows Figure 2 The following is a TinyBERT deep learning model. The model calculates the probability value of user transactions in each category (0-1 distribution); (3) Version management model. After the model is calculated in real time, the version number returned is usually 0 or 1. Returning 1 means that the current model can return the classification result normally and in a timely manner. Returning 0 means that the model has timed out and the classification result is not returned normally. If the model is abnormal and does not return or the model returns 0 due to internal timeout, the real-time machine learning classification of income and expenditure will ignore the calculation result.
[0101] Step S40: determining a target classification result according to the first classification probability and the second classification probability.
[0102] It can be understood that the target classification result refers to the final classification result of the user transaction data. The probability normalization and fusion calculation, the classification probability values (first classification probability and second classification probability) returned by the two models are normalized to the range of 0-1, and the probability values of each classification are averaged to obtain the comprehensive probability of each transaction in each classification. The classification with the highest probability is selected as the classification of the final user transaction, that is, the target classification result is determined.
[0103] In a feasible implementation, step S40 may include steps A41 to A43:
[0104] Step A41, normalizing the first classification probability and the second classification probability respectively to obtain a first normalized probability and a second normalized probability;
[0105] It should be noted that the first normalized probability refers to the probability value of user transactions in each category output by the normalized fusion offline model, and the second normalized probability refers to the probability value of user transactions in each category output by the normalized text online model.
[0106] In the specific implementation, the probability values of user transactions in each category output by the fusion offline model and the probability values of user transactions in each category output by the text online model are normalized respectively, that is, the probability values of user transactions in each category output by the fusion offline model and the probability values of user transactions in each category output by the text online model are normalized to the range of 0-1, and then the normalized probability values of user transactions in each category output by the fusion offline model and the normalized probability values of user transactions in each category output by the text online model are obtained.
[0107] Step A42, performing fusion calculation according to the first normalized probability and the second normalized probability to obtain a target fusion probability;
[0108] It can be understood that the target fusion probability refers to the probability value of the fusion of the first normalized probability and the second normalized probability.
[0109] In the specific implementation, the probability values of user transactions in each category output by the normalized fusion offline model and the probability values of user transactions in each category output by the normalized text online model are averaged to obtain the comprehensive probability of each transaction in each category, that is, the target fusion probability.
[0110] Step A43, determining the corresponding target classification result according to the target fusion probability.
[0111] In a specific implementation, the comprehensive probability of each transaction in each category is arranged in descending order, and the category with the highest probability is selected as the category of the end-user transaction according to the sorting result, that is, the target classification result is determined.
[0112] It should be noted that in this embodiment, the real-time user machine learning classification model of income and expenditure is integrated, wherein the real-time machine learning classification of income and expenditure integrates the probability distribution of user transactions calculated by the above two models in each classification to obtain the highest classification as the final user transaction classification. (1) Data screening and preprocessing. The transaction data is first preliminarily screened in sequence by user personalized classification, general crowdsourcing classification, and basic classification rules, and the transactions that are obviously classifiable are quickly filtered out to reduce the amount of data that requires in-depth analysis; (2) Model input. The complex transaction data remaining after classification in (1) is used as model input for offline Bayes+CNN model and online BERT model calculation. The input parameters include key information such as merchant information, income and expenditure categories, and transaction descriptions; (3) Model calculation. The calculation results generated by the offline Bayes+CNN model are updated to the hbase background table on day t+1, and the real-time SparkStreaming obtains the final probability LOG values of each classification based on the transaction input information and matching rules, and uses local cache to reduce repeated calculations. The online BERT model calculates and updates the model results in real time based on the input, and uses Redis cache to reduce a large number of repeated calculations to improve timeliness; (4) Probability normalization and fusion calculation. The classification probability values returned by the two models are normalized to the range of 0-1, and the probability values of each classification are averaged to obtain the comprehensive probability of each transaction in each classification. The classification with the highest probability is selected as the classification of the end user's transaction; (5) Exception handling. If the model itself has anomalies or delays, the stream computing application used to integrate the model classification results will set a timeout. Within the set timeout, if any model does not return a result or the model itself times out and does not update the user's machine learning classification normally, the income and expenditure will ignore the results calculated by the model and will not be used to calculate the average. Avoiding single point failures makes the system more reliable and stable.
[0113] It can be understood that the probability calculation of the fusion of the income and expenditure machine learning model is shown in Table 2. If there is a transaction under the premise that the results of the two machine learning models return the classification value normally, and the probability value after model normalization is shown in the above table, then the final user classification result takes the classification with the largest probability average of the two model results in each classification as the final classification, that is, the user classification corresponding to Max((PA1+PB1 / 2), (PA2+PB2 / 2), (PA3+PB3 / 2)). Based on this architecture, when calculating the machine learning classification of user transactions in real time, there is no need to care about the internal model calculation process. The update and optimization of the model will not affect the continuity of the real-time end calculation of the user machine learning classification business, and the calculation process is simple. You only need to enter simple parameters to obtain the model calculation results. The offline model that integrates the Bayes model and the CNN model is simple, efficient, and has high stability, but has limited semantic understanding and cannot capture complex contextual information and the ambiguity of words. Based on this, the text BERT algorithm is introduced to handle complex and ambiguous cases, and has good generalization ability for unseen vocabulary and sentence patterns. While ensuring high efficiency, the accuracy of classification is further improved.
[0114] Table 2:
[0115]
[0116] This embodiment obtains model transaction data by filtering user transaction data according to transaction type screening rules and preset screening order; inputs the model transaction data into the fusion offline model to obtain the first classification probability; inputs the model transaction data into the text online model to obtain the second classification probability; and determines the target classification result according to the first classification probability and the second classification probability. The classification results are returned in real time by the offline model analysis platform model and the BERT text classification algorithm online model respectively. Both methods will return the probability value in each classification. The returned probability values are normalized and averaged, and finally the target classification result is determined, which improves the efficiency and accuracy of transaction classification.
[0117] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 4 , step S20 in the transaction classification method further includes steps S21 to S24:
[0118] Step S21, inputting the model transaction data into the fusion offline model, performing probability calculation on the model transaction data according to the general classification rules in the fusion offline model, and obtaining a general transaction probability;
[0119] It can be understood that the general classification rule refers to the classification rule of the "classification-probability" mapping data calculated by the machine model, and the general transaction probability refers to the classification probability corresponding to the general classification rule.
[0120] In the specific implementation, the data that needs to be machine classified is input into the general probability model in the offline model based on the fusion of the Bayes model and the CNN model, and the probability calculation is performed based on the general classification rules to obtain the classification probability corresponding to the general classification rules, that is, the general transaction probability.
[0121] Step S22, performing probability calculation according to the keyword classification rules in the fused offline model, the model transaction data and the background database to obtain the keyword transaction probability;
[0122] It can be understood that the keyword classification rule refers to the "keyword-classification-hit / unnamed hit probability" mapping classification rule given by the machine model calculation, the background database refers to the Hbase table, and the keyword transaction probability refers to the classification probability corresponding to the keyword classification rule.
[0123] In the specific implementation, the probability model in the offline model is integrated with the Bayes model and the CNN model and combined with the Hbase table to perform probability calculation on the data that needs to be machine classified, and then the classification probability corresponding to the keyword classification rule is obtained, that is, the keyword transaction probability.
[0124] In a feasible implementation manner, step S22 may include steps A221 to A223:
[0125] Step A221, obtaining multiple historical transaction probabilities according to the machine learning classification model and historical transaction data;
[0126] It can be understood that the machine learning classification model includes a general probability model, a keyword probability model and a merchant tag probability model. Historical transaction data refers to a large amount of past historical classification data, and historical transaction probability refers to the classification probability of historical transaction data.
[0127] In the specific implementation, the classification probability is calculated for a large amount of past historical classification data through the general probability model, the keyword probability model and the merchant tag probability model, and finally the classification probability of each historical transaction data is obtained.
[0128] Step A222, fusing multiple historical transaction probabilities according to a preset fusion model to obtain a historical fusion probability;
[0129] It can be understood that the preset fusion model refers to the pre-set Bayes model and CNN model, and the historical fusion probability refers to the probability after the classification probabilities of various historical transaction data are fused.
[0130] In the specific implementation, the classification probability of each historical transaction data is fused through the pre-set Bayes model and CNN model, and the probability value between 0-1 is mapped to the Log value of 0-1500. Finally, the LOG value of all classification probabilities of the transaction can be calculated, that is, the historical fusion probability.
[0131] Step A223, updating the initial database according to the historical fusion probability to obtain a background database.
[0132] In the specific implementation, the historical fusion probability generated by the offline model is processed by the offline analysis platform and added to the Hbase table as background data via the exchange platform on day t+1, thereby obtaining a background database.
[0133] Step S23, performing probability calculation according to the label classification rules in the fused offline model, the model transaction data and the background database to obtain the label transaction probability;
[0134] It can be understood that the label classification rule refers to the label rule of the four-paradigm machine learning model, and the label transaction probability refers to the transaction probability corresponding to the label rule of the four-paradigm machine learning model.
[0135] In the specific implementation, the merchant label probability model in the offline model is integrated with the Bayes model and the CNN model, and the probability calculation of the data that needs to be machine classified is performed in combination with the Hbase table, so as to obtain the classification probability corresponding to the label rule of the four-paradigm machine learning model, that is, the label transaction probability.
[0136] Step S24, summarizing the general transaction probability, the keyword transaction probability and the tag transaction probability to obtain a first classification probability.
[0137] In a specific implementation, the general transaction probability, keyword transaction probability and tag transaction probability are summarized, and the summarized probabilities are calculated to obtain the probability distribution LOG value of a user's transaction in each category, that is, the first category probability.
[0138] It should be noted that in this embodiment, the offline model is based on the fusion of the Bayesian model and the CNN model, in which the machine learning classification of income and expenditure mainly includes the following algorithm models: (1) General probability model: Analyze a large amount of past historical classification data and calculate the probability of any transaction being classified into each category; (2) Keyword probability model: Collect high-frequency keywords, analyze past historical effective classification data, and calculate the probability of whether the transaction keyword matches and is classified into each category; (3) Merchant label probability model: Perform word segmentation analysis on the merchant-related information of the transaction, label it by calculating the similarity between the semantics and the established label, analyze the past historical effective classification data according to the label results, and calculate the probability of whether the transaction merchant label matches and is classified into each category; Based on the probability values calculated by the above (1), (2), and (3) models, the Bayesian model and the CNN model are used for fusion, and the probability values between 0 and 1 are mapped to the Log value of 0-1500, and finally the probability LOG value of the transaction in all classifications can be calculated.
[0139] It should be noted that in this embodiment, the offline model calculation rules are matched to calculate the user classification in real time, wherein the offline model generates the calculation results which are processed by the offline analysis platform and added to the Hbase table as background data via the exchange platform on day t+1. The following are the three types of rules after the real-time matching model calculation: (1) General classification model rules: The machine model calculation gives the "classification-probability" mapping data; (2) Keyword classification model rules: The machine model calculation gives the "keyword-classification-hit / unnamed probability" mapping, and each transaction performs keyword matching, and the probability values of all keywords are summarized to obtain the "classification-probability" mapping value; (3) Four-paradigm machine learning model label rules: The machine model calculation gives the "label-classification-hit / unnamed probability" mapping, and each transaction is first associated with the four-paradigm machine learning model label result, and then the label matching is performed, and the probability values of all labels are summarized to obtain the "classification-probability" mapping value. Finally, the "classification-probability" mapping values of the above three rules can be summarized, and the specific algorithms are shown in Tables 3, 4, and 5: If a transaction only matches the keyword KFC, and the four-paradigm label matches label 2, then:
[0140] LOG value of category 1: L1 = A1 + (B1 + C2 + D2) + (F2 + G1 + H2);
[0141] LOG value of category 2: L2 = A2 + (B3 + C4 + D4) + (F4 + G3 + H4);
[0142] LOG value of category 3: L3 = A3 + (B5 + C6 + D6) + (F6 + G5 + H6);
[0143] By analogy, the probability distribution LOG value of a user's transaction in each category can be obtained through the above calculation method.
[0144] Table 3:
[0145] Classification LOG value Category 1 A1 Category 2 A2 Category 3 A3
[0146] Table 4:
[0147]
[0148] Table 5:
[0149]
[0150] In this embodiment, the model transaction data is input into the fused offline model, and the model transaction data is probability calculated according to the general classification rules in the fused offline model to obtain the general transaction probability; the probability is calculated according to the keyword classification rules in the fused offline model, the model transaction data and the background database to obtain the keyword transaction probability; the probability is calculated according to the label classification rules in the fused offline model, the model transaction data and the background database to obtain the label transaction probability; the general transaction probability, the keyword transaction probability and the label transaction probability are summarized to obtain the first classification probability. By using multiple models for parallel prediction and performing probability fusion, the accuracy and robustness of classification are improved, and the limitations of a single model are compensated.
[0151] For example, to help understand the implementation process of the transaction classification method obtained by combining this embodiment with the above-mentioned embodiment 1, please refer to Figure 5 , Figure 5 A brief flow chart of a transaction classification method is provided. Specifically, the transaction data is first classified by the user's real-time transaction classification. First, the transaction data is preliminarily screened in sequence through the user's personalized classification, general crowdsourcing classification, and basic classification rules. The transactions that are obviously classifiable are quickly filtered out to reduce the amount of data that needs in-depth analysis. The remaining complex transaction data after classification is used as the model input for calculation by the offline Bayes+CNN model and the online BERT model. The input parameters include key information such as merchant information, income and expenditure categories, and transaction descriptions. The calculation results generated by the offline Bayes+CNN model are updated to the hbase background table on day t+1. The real-time SparkStreaming obtains the final probability LOG value of each classification based on the transaction input information and matching rules, and uses the local cache to reduce repeated calculations. The online BERT model calculates and updates the model results in real time according to the input, and uses the Redis cache to reduce a large number of repeated calculations to improve timeliness. Probability normalization and fusion calculation. The classification probability values returned by the two models are normalized to the range of 0-1, and the probability values of each classification are averaged to obtain the comprehensive probability of each transaction in each classification.
[0152] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the transaction classification method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0153] This application also provides a transaction classification device, please refer to Figure 6 , the transaction classification device comprises:
[0154] A screening module 10, for screening user transaction data according to transaction type screening rules and a preset screening order to obtain model transaction data;
[0155] A calculation module 20, used for inputting the model transaction data into the fusion offline model to obtain a first classification probability;
[0156] The calculation module 20 is further used to input the model transaction data into the text online model to obtain a second classification probability;
[0157] The classification module 30 is used to determine a target classification result according to the first classification probability and the second classification probability.
[0158] Optionally, the classification module 30 is further used for:
[0159] Normalizing the first classification probability and the second classification probability respectively to obtain a first normalized probability and a second normalized probability;
[0160] Performing a fusion calculation according to the first normalized probability and the second normalized probability to obtain a target fusion probability;
[0161] The corresponding target classification result is determined according to the target fusion probability.
[0162] Optionally, the calculation module 20 is further used for:
[0163] Input the model transaction data into the fusion offline model, perform probability calculation on the model transaction data according to the general classification rules in the fusion offline model, and obtain a general transaction probability;
[0164] Probability calculation is performed according to the keyword classification rules in the fused offline model, the model transaction data and the background database to obtain the keyword transaction probability;
[0165] Probability calculation is performed according to the label classification rules in the fused offline model, the model transaction data and the background database to obtain the label transaction probability;
[0166] The general transaction probability, the keyword transaction probability and the tag transaction probability are summarized to obtain a first classification probability.
[0167] Optionally, the calculation module 20 is further used for:
[0168] Obtain multiple historical transaction probabilities based on the machine learning classification model and historical transaction data;
[0169] Fusion of multiple historical transaction probabilities according to a preset fusion model to obtain a historical fusion probability;
[0170] The initial database is updated according to the historical fusion probability to obtain a background database.
[0171] Optionally, the calculation module 20 is further used for:
[0172] Preprocessing the model transaction data to obtain preprocessed transaction data;
[0173] Input the pre-processed transaction data into the text online model for probability calculation to obtain the text transaction probability and the model version number;
[0174] When the model version number is a preset version number, the text transaction probability is determined to be a second classification probability.
[0175] Optionally, the calculation module 20 is further used for:
[0176] Perform classification processing based on the fused offline model and initial transaction data to obtain classified transaction data;
[0177] Marking the classified transaction data to obtain model training data;
[0178] The initial online model is trained according to the model training data to obtain a text online model.
[0179] Optionally, the calculation module 20 is further used for:
[0180] Get the fusion calculation time and text calculation time;
[0181] Determine a time comparison result based on a timeout threshold, the fusion calculation time, and the text calculation time;
[0182] When the time comparison result is that the fusion calculation time is less than the timeout threshold and the text calculation time is greater than or equal to the timeout threshold, the target classification result is determined according to the first classification probability.
[0183] The transaction classification device provided by the present application adopts the transaction classification method in the above embodiment, which can solve the technical problem of low classification efficiency of the existing user transaction system. Compared with the prior art, the beneficial effects of the transaction classification device provided by the present application are the same as the beneficial effects of the transaction classification method provided by the above embodiment, and the other technical features in the transaction classification device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0184] The present application provides a transaction classification device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the transaction classification method in the above-mentioned embodiment one.
[0185] Reference below Figure 7 , which shows a schematic diagram of the structure of a transaction classification device suitable for implementing the embodiment of the present application. The transaction classification device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The transaction classification device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0186] like Figure 7As shown, the transaction classification device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the transaction classification device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the transaction classification device to communicate with other devices wirelessly or wired to exchange data. Although the transaction classification device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0187] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0188] The transaction classification device provided by the present application adopts the transaction classification method in the above embodiment, which can solve the technical problem of low classification efficiency of the existing user transaction system. Compared with the prior art, the beneficial effects of the transaction classification device provided by the present application are the same as the beneficial effects of the transaction classification method provided by the above embodiment, and the other technical features in the transaction classification device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0189] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0190] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0191] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the transaction classification method in the above-mentioned embodiment.
[0192] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0193] The computer-readable storage medium may be included in the transaction classification device; or may exist independently without being assembled into the transaction classification device.
[0194] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the transaction classification device, the transaction classification device: screens the user transaction data according to the transaction type screening rules and the preset screening order to obtain model transaction data; inputs the model transaction data to the fusion offline model to obtain the first classification probability; inputs the model transaction data to the text online model to obtain the second classification probability; determines the target classification result according to the first classification probability and the second classification probability.
[0195] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0196] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0197] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0198] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned transaction classification method, and can solve the technical problem of low classification efficiency of the existing user transaction system. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the transaction classification method provided by the above-mentioned embodiment, and will not be elaborated here.
[0199] The present application also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the steps of the transaction classification method as described above are implemented.
[0200] The computer program product provided by this application can solve the technical problem of low classification efficiency of existing user transaction systems. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as those of the transaction classification method provided by the above embodiment, which will not be repeated here.
[0201] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A transaction classification method, characterized in that: The transaction classification method comprises: Filter user transaction data according to transaction type screening rules and preset screening order to obtain model transaction data; Inputting the model transaction data into the fusion offline model to obtain a first classification probability; Inputting the model transaction data into the text online model to obtain a second classification probability; A target classification result is determined according to the first classification probability and the second classification probability.
2. The method according to claim 1, characterized in that The step of determining a target classification result according to the first classification probability and the second classification probability comprises: Normalizing the first classification probability and the second classification probability respectively to obtain a first normalized probability and a second normalized probability; Performing a fusion calculation according to the first normalized probability and the second normalized probability to obtain a target fusion probability; The corresponding target classification result is determined according to the target fusion probability.
3. The method according to claim 1, characterized in that The step of inputting the model transaction data into the fusion offline model to obtain the first classification probability includes: Input the model transaction data into the fusion offline model, perform probability calculation on the model transaction data according to the general classification rules in the fusion offline model, and obtain a general transaction probability; Probability calculation is performed according to the keyword classification rules in the fused offline model, the model transaction data and the background database to obtain the keyword transaction probability; Probability calculation is performed according to the label classification rules in the fused offline model, the model transaction data and the background database to obtain the label transaction probability; The general transaction probability, the keyword transaction probability and the tag transaction probability are summarized to obtain a first classification probability.
4. The method according to claim 3, characterized in that Before the step of performing probability calculation according to the keyword classification rules in the fused offline model, the model transaction data and the background database to obtain the keyword transaction probability, the step further includes: Obtain multiple historical transaction probabilities based on the machine learning classification model and historical transaction data; Fusion of multiple historical transaction probabilities according to a preset fusion model to obtain a historical fusion probability; The initial database is updated according to the historical fusion probability to obtain a background database.
5. The method according to claim 1, characterized in that The step of inputting the model transaction data into the text online model to obtain a second classification probability includes: Preprocessing the model transaction data to obtain preprocessed transaction data; Input the pre-processed transaction data into the text online model for probability calculation to obtain the text transaction probability and the model version number; When the model version number is a preset version number, the text transaction probability is determined to be a second classification probability.
6. The method according to claim 5, characterized in that Before inputting the pre-processed transaction data into the text online model for probability calculation to obtain the text transaction probability and the model version number, the method further includes: Perform classification processing based on the fused offline model and initial transaction data to obtain classified transaction data; Marking the classified transaction data to obtain model training data; The initial online model is trained according to the model training data to obtain a text online model.
7. The method according to any one of claims 1 to 6, characterized in that After the step of inputting the model transaction data into the text online model to obtain the second classification probability, the method further includes: Get the fusion calculation time and text calculation time; Determine a time comparison result based on a timeout threshold, the fusion calculation time, and the text calculation time; When the time comparison result is that the fusion calculation time is less than the timeout threshold and the text calculation time is greater than or equal to the timeout threshold, the target classification result is determined according to the first classification probability.
8. A transaction classification device, characterized in that: The device comprises: A screening module is used to screen user transaction data according to transaction type screening rules and preset screening order to obtain model transaction data; A calculation module, used for inputting the model transaction data into the fusion offline model to obtain a first classification probability; The calculation module is further used to input the model transaction data into the text online model to obtain a second classification probability; A classification module is used to determine a target classification result according to the first classification probability and the second classification probability.
9. A transaction classification device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the transaction classification method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the transaction classification method according to any one of claims 1 to 7 are implemented.