Credit card fraud detection method and device based on clustering samples and extreme gradient
By combining clustered samples, extreme gradient enhancement tree and adaptive weight calculation methods in credit card fraud detection, the problems of low accuracy and long detection time in the prior art are solved, and more efficient and accurate credit card fraud detection is achieved.
Patent Information
- Application Number
- CN202210478879.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-05
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2042-05-05
AI Technical Summary
The prior art has problems with low accuracy and long detection time in credit card fraud detection, especially when processing unbalanced data sets.
The detection method based on clustered samples and limit gradients is adopted, and a balanced number of manual data sets are generated through data cleaning, feature engineering, clustering algorithm, adaptive weight calculation and oversampling algorithm, and the credit card fraud detection model is trained using the limit gradient enhancement tree algorithm.
It effectively overcomes the problem of inter-class and intra-class imbalance, improves detection accuracy and data quality, and the generated credit card fraud detection model has good detection results.
Smart Images

Figure CN114862404B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of data mining technology, and in particular to a credit card fraud detection method and device based on cluster samples and extreme gradients. Background Art
[0002] Before the advent of the era of big data and artificial intelligence, the establishment of credit card fraud detection models was completed by some traditional means, including manual detection, building detection models based on expert rules, and cost analysis models, etc. However, these traditional methods have defects such as low accuracy and long detection time. With the rise and development of big data and artificial intelligence technology, both traditional statistical-based machine learning algorithms and various emerging deep learning methods have been modified by domestic and foreign researchers based on the characteristics of the credit card fraud field and applied to this field. A notable feature of credit card fraud data sets is data imbalance. Common machine learning algorithms, such as logistic regression algorithms and decision tree algorithms, will have greatly reduced effects when directly training such unbalanced data sets. Therefore, the development of a credit card fraud detection method and device based on clustering samples and extreme gradients can effectively overcome the defects in the above-mentioned related technologies, which has become a technical problem that needs to be solved urgently in the industry. Summary of the invention
[0003] In view of the above problems existing in the prior art, an embodiment of the present invention provides a credit card fraud detection method and device based on cluster samples and extreme gradients.
[0004] In a first aspect, an embodiment of the present invention provides a credit card fraud detection method based on cluster samples and extreme gradients, comprising: step 1: firstly, data cleaning and feature engineering processing are performed on the original data directly obtained from the bank database to obtain an original data set that can be used for machine learning; step 2: clustering the original data set using a clustering algorithm to obtain multiple sub-clusters, and discarding the sub-clusters without minority class samples or with only 1 minority class sample; step 3: for other sub-clusters, the imbalance rate is calculated according to the ratio of the number of minority class samples to the number of majority class samples in the sub-cluster, and then the sub-clusters to be oversampled are screened out according to the set imbalance rate threshold; step 4: the sparse factors of all sub-clusters to be oversampled are calculated, Determine the corresponding oversampling weight of each subcluster to be oversampled according to the sparse factor; Step 5: assign different adaptive weights according to the degree of learning of boundary information by each minority class sample within the subcluster to be oversampled, and determine the oversampling weight of each minority class sample; Step 6: perform oversampling interpolation calculation based on its own adaptive weight for each minority class sample to generate an artificial data set with a balanced number of majority class samples and minority class samples; Step 7: Use the extreme gradient boosting tree algorithm to train the balanced data set in the previous step to obtain the final credit card fraud detection model; Step 8: Use the credit card fraud detection model trained in step 7 to detect credit card transaction data.
[0005] Based on the content of the above method embodiment, the credit card fraud detection method based on cluster samples and extreme gradients provided in the embodiment of the present invention, the corresponding oversampling weight of each subcluster to be oversampled is determined according to the sparse factor in step 4, including: step 4.1: calculating the Euclidean distance matrix of the subcluster to be oversampled; step 4.2: calculating the average spacing of the minority class of the subcluster to be oversampled; step 4.3: calculating the density and sparse factor of the minority class of the subcluster to be oversampled; step 4.4: calculating the oversampling index corresponding to each subcluster to be oversampled, that is, the total number of samples to be generated multiplied by the sparse factor corresponding to the subcluster.
[0006] Based on the content of the above method embodiment, the credit card fraud detection method based on cluster samples and extreme gradient provided in the embodiment of the present invention, the Euclidean distance matrix includes:
[0007]
[0008] in, is the square of the Euclidean distance between the feature vectors of the minority class samples xi and xj in the subcluster i to be oversampled, n is the number of minority class samples in the subcluster, and A(i) is the Euclidean distance matrix.
[0009] Based on the content of the above method embodiment, the credit card fraud detection method based on clustered samples and extreme gradients provided in the embodiment of the present invention, the calculation of the average distance of the minority class of the sub-cluster to be oversampled includes:
[0010]
[0011] Among them, ∑a xy represents the sum of all non-diagonal elements in the Euclidean distance matrix A(i), c(i) represents the number of non-diagonal elements in the Euclidean distance matrix A(i), and averDist(i) is the average distance between the minority classes of the sub-clusters to be oversampled.
[0012] Based on the content of the above method embodiment, in the credit card fraud detection method based on cluster samples and extreme gradient provided in the embodiment of the present invention, the density of the minority class includes:
[0013]
[0014] Where dens(i) is the density of the minority class, numOfMin(FC i ) is the number of minority class samples in the sub-cluster, averDist m (i) is the mth power of the average distance of the minority class, where m represents the number of features of the sample.
[0015] Based on the content of the above method embodiment, the credit card fraud detection method based on cluster samples and extreme gradient provided in the embodiment of the present invention, the sparse factor includes:
[0016]
[0017]
[0018] Among them, spar(i) is the sub-cluster FC to be oversampled i The minority class density of , sparFac(i) is the sparse factor, and ∑spar is the sum of the sparsity of all subclusters to be oversampled.
[0019] Based on the content of the above method embodiment, the credit card fraud detection method based on cluster samples and extreme gradient provided in the embodiment of the present invention, the determining of the oversampling weight of each minority class sample in step 5 includes: step 5.1: using the nearest neighbor algorithm to obtain K nearest neighbor samples of each minority class sample in the subcluster to be oversampled, and calculating the majority class neighbor rate corresponding to each minority class sample, which is the number of majority class samples in the nearest neighbors divided by K; step 5.2: calculating the adaptive sampling weight corresponding to each minority class sample, which is the majority class neighbor rate corresponding to the minority class sample divided by the sum of the majority class neighbor rates corresponding to all minority class samples in the subcluster; step 5.3: calculating the sampling index corresponding to each minority class sample, which is the sampling index of the cluster where the minority class sample is located multiplied by the adaptive sampling weight of the minority class.
[0020] In a second aspect, an embodiment of the present invention provides a credit card fraud detection device based on cluster samples and extreme gradients, comprising: a first main module, used to implement step 1: firstly perform data cleaning and feature engineering processing on the original data directly obtained from the bank database to obtain an original data set that can be used for machine learning; a second main module, used to implement step 2: use a clustering algorithm to cluster the original data set to obtain multiple sub-clusters, and discard the sub-clusters without minority class samples or with only 1 minority class sample; a third main module, used to implement step 3: for other sub-clusters, calculate their imbalance rate according to the ratio of the number of minority class samples to the number of majority class samples in the sub-cluster, and then screen out the sub-clusters to be oversampled according to the set imbalance rate threshold; a fourth main module, used to implement step 4: calculate the sparse factors of all sub-clusters to be oversampled, Determine the corresponding oversampling weight of each subcluster to be oversampled according to the sparse factor; the fifth main module is used to implement step 5: assign different adaptive weights according to the degree of learning of boundary information by each minority class sample within the subcluster to be oversampled, and determine the oversampling weight of each minority class sample; the sixth main module is used to implement step 6: perform oversampling interpolation calculation based on its own adaptive weight for each minority class sample, and generate an artificial data set with a balanced number of majority class samples and minority class samples; the seventh main module is used to implement step 7: use the extreme gradient boosting tree algorithm to train the balanced data set in the previous step to obtain the final credit card fraud detection model; the eighth main module is used to implement step 8: use the credit card fraud detection model trained in step 7 to detect credit card transaction data.
[0021] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0022] at least one processor; and
[0023] at least one memory in communication with the processor, wherein:
[0024] The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the credit card fraud detection method based on cluster samples and extreme gradients provided by any one of the various implementations of the first aspect.
[0025] In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable a computer to execute a credit card fraud detection method based on clustered samples and extreme gradients provided in any one of the various implementation methods of the first aspect.
[0026] The credit card fraud detection method and device based on clustering samples and extreme gradients provided in the embodiments of the present invention combine the clustering algorithm, sample adaptive weight calculation and oversampling algorithm, thereby solving the problem of imbalance between classes and effectively avoiding the problem of imbalance within classes, improving the data quality of artificially synthesized samples, and using the extreme gradient boosting tree as a classifier in the credit card fraud detection model to obtain better classification results. After combining the oversampling algorithm based on clustering and adaptive weights, the credit card fraud detection model finally generated has good detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0028] Figure 1 A flow chart of a credit card fraud detection method based on cluster samples and extreme gradients provided in an embodiment of the present invention;
[0029] Figure 2 A schematic diagram of the structure of a credit card fraud detection device based on cluster samples and extreme gradients provided in an embodiment of the present invention;
[0030] Figure 3 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In addition, the technical features in the various embodiments or single embodiments provided by the present invention can be arbitrarily combined with each other to form a feasible technical solution. This combination is not subject to the constraints of the sequence of steps and / or the structural composition mode, but must be based on the ability of ordinary technicians in this field to achieve. When the combination of technical solutions is contradictory or cannot be achieved, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0032] The embodiment of the present invention provides a credit card fraud detection method based on cluster samples and extreme gradients, see Figure 1 The method comprises: step 1: firstly, data cleaning and feature engineering are performed on the original data directly obtained from the bank database to obtain the original data set that can be used for machine learning; step 2: clustering the original data set using a clustering algorithm to obtain multiple sub-clusters, and discarding the sub-clusters with no minority class samples or with only 1 minority class sample; step 3: for other sub-clusters, the imbalance rate is calculated according to the ratio of the number of minority class samples to the number of majority class samples in the sub-cluster, and then the sub-clusters to be oversampled are screened out according to the set imbalance rate threshold; step 4: the sparse factors of all sub-clusters to be oversampled are calculated, and the sparse factors of each sub-cluster to be oversampled are determined according to the sparse factors. Corresponding oversampling weights; Step 5: According to the degree of learning of boundary information by each minority class sample in the subcluster to be oversampled, different adaptive weights are assigned to determine the oversampling weight of each minority class sample; Step 6: For each minority class sample, oversampling interpolation calculation based on its own adaptive weight is performed to generate an artificial data set with a balanced number of majority class samples and minority class samples; Step 7: Use the extreme gradient boosting tree algorithm to train the balanced data set in the previous step to obtain the final credit card fraud detection model; Step 8: Use the credit card fraud detection model trained in step 7 to detect credit card transaction data. It should be noted that in step 1, the original data directly obtained from the bank database is first subjected to dirty data removal and PCA principal component analysis to obtain the original data set that can be used for machine learning. Then the original data set is divided into a training set and a test set.
[0033] Based on the content of the above method embodiment, as an optional embodiment, the credit card fraud detection method based on clustered samples and extreme gradients provided in the embodiment of the present invention, step 4 determines the corresponding oversampling weight of each subcluster to be oversampled according to the sparse factor, including: step 4.1: calculating the Euclidean distance matrix of the subcluster to be oversampled; step 4.2: calculating the average spacing of the minority class of the subcluster to be oversampled; step 4.3: calculating the minority class density and sparse factor of the subcluster to be oversampled; step 4.4: calculating the oversampling index corresponding to each subcluster to be oversampled, that is, the total number of samples to be generated multiplied by the sparse factor corresponding to the subcluster.
[0034] Based on the content of the above method embodiment, as an optional embodiment, in the credit card fraud detection method based on cluster samples and extreme gradient provided in the embodiment of the present invention, the Euclidean distance matrix includes:
[0035]
[0036] in, is the square of the Euclidean distance between the feature vectors of the minority class samples xi and xj in the subcluster i to be oversampled, n is the number of minority class samples in the subcluster, and A(i) is the Euclidean distance matrix.
[0037] Based on the content of the above method embodiment, as an optional embodiment, the credit card fraud detection method based on clustered samples and extreme gradients provided in the embodiment of the present invention, the calculation of the average distance of the minority class of the sub-cluster to be oversampled includes:
[0038]
[0039] Among them, ∑a xy represents the sum of all non-diagonal elements in the Euclidean distance matrix A(i), c(i) represents the number of non-diagonal elements in the Euclidean distance matrix A(i), and averDist(i) is the average distance between the minority classes of the sub-clusters to be oversampled.
[0040] Based on the content of the above method embodiment, as an optional embodiment, in the credit card fraud detection method based on cluster samples and extreme gradient provided in the embodiment of the present invention, the density of the minority class includes:
[0041]
[0042] Where dens(i) is the density of the minority class, numOfMin(FC i ) is the number of minority class samples in the sub-cluster, averDist m (i) is the mth power of the average distance of the minority class, where m represents the number of features of the sample.
[0043] Based on the content of the above method embodiment, as an optional embodiment, in the credit card fraud detection method based on cluster samples and extreme gradient provided in the embodiment of the present invention, the sparse factor includes:
[0044]
[0045]
[0046] Among them, spar(i) is the sub-cluster FC to be oversampled i The minority class density of , sparFac(i) is the sparse factor, and ∑spar is the sum of the sparsity of all subclusters to be oversampled.
[0047] Based on the content of the above method embodiment, as an optional embodiment, the credit card fraud detection method based on cluster samples and extreme gradient provided in the embodiment of the present invention, the determining of the oversampling weight of each minority class sample in step 5 includes: step 5.1: using the nearest neighbor algorithm to obtain K nearest neighbor samples of each minority class sample in the subcluster to be oversampled, and calculating the majority class neighbor rate corresponding to each minority class sample, which is the number of majority class samples in the nearest neighbors divided by K; step 5.2: calculating the adaptive sampling weight corresponding to each minority class sample, which is the majority class neighbor rate corresponding to the minority class sample divided by the sum of the majority class neighbor rates corresponding to all minority class samples in the subcluster; step 5.3: calculating the sampling index corresponding to each minority class sample, which is the sampling index of the cluster where the minority class sample is located multiplied by the adaptive sampling weight of the minority class.
[0048] The credit card fraud detection method based on clustering samples and extreme gradients provided in the embodiment of the present invention combines the clustering algorithm, sample adaptive weight calculation and oversampling algorithm, thereby solving the problem of imbalance between classes and effectively avoiding the problem of imbalance within classes, thereby improving the data quality of artificially synthesized samples. By using the extreme gradient boosting tree as a classifier in the credit card fraud detection model, better classification effect can be obtained. After combining the oversampling algorithm based on clustering and adaptive weights, the credit card fraud detection model finally generated has good detection accuracy.
[0049] The implementation basis of each embodiment of the present invention is to implement programmed processing through a device with a processor function. Therefore, in engineering practice, the technical solutions and functions of each embodiment of the present invention can be encapsulated into various modules. Based on this reality, on the basis of the above embodiments, an embodiment of the present invention provides a credit card fraud detection device based on cluster samples and extreme gradients, which is used to execute the credit card fraud detection method based on cluster samples and extreme gradients in the above method embodiment. Figure 2The device includes: a first main module, which is used to implement step 1: firstly perform data cleaning and feature engineering processing on the original data directly obtained from the bank database to obtain the original data set that can be used for machine learning; a second main module, which is used to implement step 2: use a clustering algorithm to cluster the original data set to obtain multiple sub-clusters, and discard the sub-clusters without minority class samples or with only 1 minority class sample; a third main module, which is used to implement step 3: for other sub-clusters, calculate the imbalance rate according to the ratio of the number of minority class samples to the number of majority class samples in the sub-cluster, and then select the sub-clusters to be oversampled according to the set imbalance rate threshold; a fourth main module, which is used to implement step 4: calculate the sparse factors of all sub-clusters to be oversampled, and determine each sub-cluster to be oversampled according to the sparse factor The fifth main module is used to implement step 5: assign different adaptive weights according to the degree of learning of boundary information by each minority class sample in the subcluster to be oversampled, and determine the oversampling weight of each minority class sample; the sixth main module is used to implement step 6: perform oversampling interpolation calculation based on its own adaptive weight for each minority class sample, and generate an artificial data set with a balanced number of majority class samples and minority class samples; the seventh main module is used to implement step 7: use the extreme gradient boosting tree algorithm to train the balanced data set in the previous step to obtain the final credit card fraud detection model; the eighth main module is used to implement step 8: use the credit card fraud detection model trained in step 7 to detect credit card transaction data.
[0050] The credit card fraud detection device based on cluster samples and extreme gradient provided by the embodiment of the present invention adopts Figure 2 Several modules in the paper combine clustering algorithm, sample adaptive weight calculation and oversampling algorithm to solve the imbalance problem between classes while effectively avoiding the imbalance problem within classes, improving the data quality of artificially synthesized samples, and using the extreme gradient boosting tree as a classifier in the credit card fraud detection model to obtain better classification results. After combining the oversampling algorithm based on clustering and adaptive weights, the final generated credit card fraud detection model has good detection accuracy.
[0051] It should be noted that the device in the device embodiment provided by the present invention can be used to implement the method in the above method embodiment as well as the method in other method embodiments provided by the present invention. The only difference is that the corresponding functional modules are set, and the principle is basically the same as the principle of the above device embodiment provided by the present invention. As long as the technical personnel in the field refer to the specific technical solutions in other method embodiments on the basis of the above device embodiment, obtain the corresponding technical means and the technical solutions composed of these technical means by combining technical features, the device in the above device embodiment can be improved on the premise of ensuring the practicality of the technical solution, thereby obtaining the corresponding device class embodiment, which is used to implement the methods in other method class embodiments. For example:
[0052] Based on the content of the above-mentioned device embodiment, as an optional embodiment, the credit card fraud detection device based on clustered samples and extreme gradients provided in the embodiment of the present invention further includes: a first submodule, used to implement the determination of the corresponding oversampling weight of each subcluster to be oversampled according to the sparse factor in step 4, including: step 4.1: calculating the Euclidean distance matrix of the subcluster to be oversampled; step 4.2: calculating the average spacing of the minority class of the subcluster to be oversampled; step 4.3: calculating the minority class density and sparse factor of the subcluster to be oversampled; step 4.4: calculating the oversampling index corresponding to each subcluster to be oversampled, that is, the total number of samples to be generated multiplied by the sparse factor corresponding to the subcluster.
[0053] Based on the content of the above device embodiment, as an optional embodiment, the credit card fraud detection device based on cluster samples and extreme gradient provided in the embodiment of the present invention further includes: a second submodule, which is used to implement the Euclidean distance matrix, including:
[0054]
[0055] in, is the square of the Euclidean distance between the feature vectors of the minority class samples xi and xj in the subcluster i to be oversampled, n is the number of minority class samples in the subcluster, and A(i) is the Euclidean distance matrix.
[0056] Based on the content of the above device embodiment, as an optional embodiment, the credit card fraud detection device based on clustered samples and extreme gradients provided in the embodiment of the present invention further includes: a third submodule, which is used to implement the calculation of the average distance of the minority class of the subcluster to be oversampled, including:
[0057]
[0058] Among them, ∑a xyrepresents the sum of all non-diagonal elements in the Euclidean distance matrix A(i), c(i) represents the number of non-diagonal elements in the Euclidean distance matrix A(i), and averDist(i) is the average distance between the minority classes of the sub-clusters to be oversampled.
[0059] Based on the content of the above device embodiment, as an optional embodiment, the credit card fraud detection device based on cluster samples and extreme gradient provided in the embodiment of the present invention further includes: a fourth submodule, which is used to realize the density of the minority class, including:
[0060]
[0061] Where dens(i) is the density of the minority class, numOfMin(FC i ) is the number of minority class samples in the sub-cluster, averDist m (i) is the mth power of the average distance of the minority class, where m represents the number of features of the sample.
[0062] Based on the content of the above device embodiment, as an optional embodiment, the credit card fraud detection device based on cluster samples and extreme gradient provided in the embodiment of the present invention further includes: a fifth submodule, which is used to implement the sparse factor, including:
[0063]
[0064]
[0065] Among them, spar(i) is the sub-cluster FC to be oversampled i The minority class density of , sparFac(i) is the sparse factor, and ∑spar is the sum of the sparsity of all subclusters to be oversampled.
[0066] Based on the content of the above device embodiment, as an optional embodiment, the credit card fraud detection device based on cluster samples and extreme gradient provided in the embodiment of the present invention further includes: a sixth submodule, which is used to implement the determination of the oversampling weight of each minority class sample in step 5, including: step 5.1: using the nearest neighbor algorithm to obtain K nearest neighbor samples of each minority class sample in the subcluster to be oversampled, and calculating the majority class neighbor rate corresponding to each minority class sample, which is the number of majority class samples in the nearest neighbors divided by K; step 5.2: calculating the adaptive sampling weight corresponding to each minority class sample, which is the majority class neighbor rate corresponding to the minority class sample divided by the sum of the majority class neighbor rates corresponding to all minority class samples in the subcluster; step 5.3: calculating the sampling index corresponding to each minority class sample, which is the sampling index of the cluster where the minority class sample is located multiplied by the adaptive sampling weight of the minority class.
[0067] The method of the embodiment of the present invention is implemented by relying on electronic devices, so it is necessary to introduce the relevant electronic devices. Based on this purpose, the embodiment of the present invention provides an electronic device, such as Figure 3 As shown, the electronic device includes: at least one processor, a communication interface, at least one memory, and a communication bus, wherein at least one processor, the communication interface, and at least one memory communicate with each other through the communication bus. At least one processor can call the logic instructions in at least one memory to execute all or part of the steps of the method provided by the aforementioned various method embodiments.
[0068] In addition, the logic instructions in the at least one memory mentioned above can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each method embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0069] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0070] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.
[0071] The flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present invention. Based on this understanding, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a 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 box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and sometimes in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0072] In this patent, the terms "include", "comprises" or any other variation thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of more restrictions, the elements defined by the sentence "includes..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A credit card fraud detection method based on clustering samples and extreme gradients, characterized in that: include: Step 1: First, perform data cleaning and feature engineering on the original data directly obtained from the bank database to obtain the original data set that can be used for machine learning; Step 2: Use a clustering algorithm to cluster the original data set to obtain multiple sub-clusters, and discard the sub-clusters with no minority class samples or only 1 minority class sample; Step 3: For other sub-clusters, calculate their imbalance rate based on the ratio of the number of minority class and majority class samples within the sub-cluster, and then filter out the sub-clusters to be oversampled based on the set imbalance rate threshold; Step 4: Calculate the sparse factors of all sub-clusters to be oversampled, and determine the corresponding Oversampling weight; Step 5: According to the degree of learning of boundary information by each minority class sample in the subcluster to be oversampled, different adaptive weights are assigned to determine the oversampling weight of each minority class sample; Step 6: For each minority class sample, oversampling interpolation calculation based on its own adaptive weight is performed to generate an artificial data set with a balanced number of majority class samples and minority class samples; Step 7: Use the extreme gradient boosting tree algorithm to train the balanced data set in the previous step to obtain the final credit card fraud detection model; Step 8: Use the credit card fraud detection model trained in step 7 to detect credit card transaction data.
2. The credit card fraud detection method based on cluster samples and extreme gradient according to claim 1, characterized in that: The step 4 of determining the corresponding oversampling weight of each subcluster to be oversampled according to the sparse factor includes: step 4.1: calculating the Euclidean distance matrix of the subcluster to be oversampled; step 4.2: calculating the average spacing of the minority class of the subcluster to be oversampled; step 4.3: calculating the density and sparse factor of the minority class of the subcluster to be oversampled; step 4.4: calculating the oversampling index corresponding to each subcluster to be oversampled, that is, the total number of samples to be generated multiplied by the sparse factor corresponding to the subcluster.
3. The credit card fraud detection method based on cluster samples and extreme gradient according to claim 2, characterized in that: The Euclidean distance matrix includes: in, is the minority class sample x in the sub-cluster i to be oversampled i With x j is the square of the Euclidean distance of the eigenvector of , n is the number of minority class samples in the subcluster, and A(i) is the Euclidean distance matrix.
4. The credit card fraud detection method based on clustering samples and extreme gradient according to claim 3, characterized in that: The calculating of the average distance of the minority class of the sub-cluster to be oversampled includes: Among them, ∑a xy represents the sum of all non-diagonal elements in the Euclidean distance matrix A(i), c(i) represents the number of non-diagonal elements in the Euclidean distance matrix A(i), and averDist(i) is the average distance between the minority classes of the sub-clusters to be oversampled.
5. The credit card fraud detection method based on clustering samples and extreme gradient according to claim 4, characterized in that: The minority class density includes: Where dens(i) is the density of the minority class, numOfMin(FC i ) is the number of minority class samples in the sub-cluster, averDist m (i) is the mth power of the average distance of the minority class, where m represents the number of features of the sample.
6. The credit card fraud detection method based on clustering samples and extreme gradient according to claim 5, characterized in that: The sparse factor includes: Among them, spar(i) is the sub-cluster FC to be oversampled i The minority class density of , sparFac(i) is the sparse factor, and ∑spar is the sum of the sparsity of all subclusters to be oversampled.
7. The credit card fraud detection method based on clustering samples and extreme gradient according to claim 6, characterized in that: Determining the oversampling weight of each minority class sample in step 5 includes: step 5.1: using the nearest neighbor algorithm to obtain K nearest neighbor samples of each minority class sample in the subcluster to be oversampled, and calculating the majority class neighbor rate corresponding to each minority class sample, which is the number of majority class samples in the nearest neighbor divided by K; step 5.2: calculating the adaptive sampling weight corresponding to each minority class sample, which is the majority class neighbor rate corresponding to the minority class sample divided by the sum of the majority class neighbor rates corresponding to all minority class samples in the subcluster; step 5.3: calculating the sampling index corresponding to each minority class sample, which is the sampling index of the cluster where the minority class sample is located multiplied by the adaptive sampling weight of the minority class.
8. A credit card fraud detection device based on clustering samples and extreme gradients, characterized in that: include: The first main module is used to implement step 1: first perform data cleaning and feature engineering on the original data directly obtained from the bank database to obtain an original data set that can be used for machine learning; the second main module is used to implement step 2: use a clustering algorithm to cluster the original data set to obtain multiple sub-clusters, and discard sub-clusters with no minority class samples or only 1 minority class sample; the third main module is used to implement step 3: for other sub-clusters, calculate their imbalance rate according to the ratio of the number of minority class samples to the majority class samples in the sub-cluster, and then screen out the sub-clusters to be oversampled according to the set imbalance rate threshold; the fourth main module is used to implement step 4: calculate the sparse factors of all sub-clusters to be oversampled, and determine the corresponding oversampling weight of each sub-cluster to be oversampled according to the sparse factor; The fifth main module is used to implement step 5: assign different adaptive weights according to the degree of learning of boundary information by each minority class sample within the subcluster to be oversampled, and determine the oversampling weight of each minority class sample; the sixth main module is used to implement step 6: perform oversampling interpolation calculation based on its own adaptive weight for each minority class sample, and generate an artificial data set with a balanced number of majority class samples and minority class samples; the seventh main module is used to implement step 7: use the extreme gradient boosting tree algorithm to train the balanced data set in the previous step to obtain the final credit card fraud detection model; the eighth main module is used to implement step 8: use the credit card fraud detection model trained in step 7 to detect credit card transaction data.
9. An electronic device, characterized in that: include: At least one processor, at least one memory and a communication interface; wherein, The processor, memory and communication interface communicate with each other; The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, which cause the computer to execute the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Credit card fraud detection method and system based on undersampling, medium and equipment
CN111461855A
Non-intrusive load identification method based on XGBoost and Stacking model fusion
CN113408617A