Credit risk prediction method based on deep learning
By using GatedTransformer and GEGLU units to process tabular data in credit risk prediction, the problem of difficulty in capturing complex structures and nonlinear relationships with traditional methods is solved, achieving more comprehensive feature extraction and higher prediction accuracy.
Patent Information
- Application Number
- CN202410273313.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-11
- Publication Date
- 2024-09-24
AI Technical Summary
Traditional deep learning methods cannot fully capture the complex structures and nonlinear relationships between features in tabular data in credit risk prediction, resulting in model limitations in feature extraction and information mining, and the inability to effectively understand and express the abstract characteristics of input data.
GatedTransformer is used as the feature extractor, the gating mechanism and GEGLU unit are introduced, combined with the multi-head attention module and the gated feed-forward neural network, and the feature fusion module and feature mapping module are used to process categorical features and continuous features, and the model is enhanced for nonlinear features. Modeling capabilities, and cross-tokens interaction through spatial gating units to achieve more comprehensive feature extraction.
It improves the model's ability to extract complex data features, enhances the modeling ability of nonlinear features, can better understand and express the abstract characteristics of input data, and improves the accuracy of credit risk prediction.
Smart Images

Figure CN118691394A
Abstract
Description
Technical Field
[0001] The present application relates to the field of credit risk prediction, and specifically to a credit risk prediction method based on deep learning. Background Art
[0002] Credit risk is one of the main risks faced by financial institutions. Establishing a credit risk prediction model is an important means to help financial institutions avoid risks and reduce losses. With the rapid development of the financial industry and computer technology, credit scoring methods are emerging in an endless stream. In the past, the most important statistical methods were represented by logistic regression and discriminant analysis. However, due to the strict requirements on data sets and the limitations of application scenarios, the scoring ability of statistical methods is limited and weak. Later, machine learning technologies such as artificial neural networks (ANN), support vector machines (SVM), and decision trees (DT) were widely used in the field of credit risk prediction. These single classifier learning algorithms can better solve nonlinear problems and improve prediction accuracy.
[0003] However, the data in credit risk prediction tasks are usually tabular and contain various types of information, such as personal identity information, financial data, historical lending records, etc. The diversity and complexity of these data complicate the modeling process, especially when there are nonlinear and interactive effects between features. Traditional deep learning methods may be limited in processing tabular data because these methods are usually designed for sequence or image data and it is difficult to effectively capture the complex structures and relationships in tabular data.
[0004] Therefore, in recent years, researchers have introduced the Transformer architecture for modeling tabular data. TabTransformer, as one of the innovative methods, can better capture the complex relationship between features in tabular data with the help of self-attention mechanism and context embedding, which makes it have potential advantages in credit risk prediction tasks. In order to further improve the model's ability to model complex relationships between features, GatedTabTransformer is introduced for credit risk prediction. GatedTabTransformer introduces a gating mechanism to enable the model to selectively focus on the information between different features. Nevertheless, GatedTabTransformer still has some shortcomings when used for credit risk prediction tasks. First, the model uses traditional Transformer as a feature extractor, which may not be able to fully capture the complex interactions and nonlinear relationships between different classification features; second, the model has limitations in fully mining feature information, which weakens the effectiveness of feature space information and cannot fully understand and express the abstract characteristics of input data. To this end, we propose a credit risk prediction method based on deep learning. Summary of the invention
[0005] The purpose of the present invention is to provide a credit risk prediction method based on deep learning to solve the problems raised in the above background technology.
[0006] The present invention provides the following technical solutions:
[0007] S1: Divide the sample data set and distinguish between categorical features and continuous features;
[0008] S2: Use column embedding and layer normalization to process categorical features and continuous features respectively;
[0009] S3: Build a feature extractor that can convert the categorical features after column embedding into contextual embeddings;
[0010] S4: construct a feature fusion module, which can combine the context features extracted by the feature extractor and the normalized continuous features;
[0011] S5: Construct a feature mapping and classification module, which processes the features output by the feature fusion module through a dual-channel feature extraction module and a spatial gating module, and completes the classification using a linear layer.
[0012] Preferably, the original credit risk dataset I∈R in S1 l×k (l is the number of samples, k is the number of features), divide the data set into training set Test Set (l1 is the number of samples in the training set, l2 is the number of samples in the test set); the features in the training set and the test set are divided into classification features x cat and continuous features x cont . Continuous feature x cont ∈R c Represents all c continuous features, categorical features x cat ≡{x1,x2,...,x m}, each x i is a categorical feature, where i∈{1,...,m}.
[0013] Preferably, S2 uses column embedding to embed x i The classification features are embedded into the d-dimensional parameter embedding, let i∈{1,...,m} is x i The embedding of features, is the embedding set of all categorical features; and continuous features are normalized using layer normalization.
[0014] Preferably, the feature extractor in S3 adopts a stacked GatedTransformer, which is composed of a multi-head attention module and a gated feedforward neural network.
[0015] Preferably, the S4 constructs a feature fusion module by splicing the final feature output result of the feature extractor with the continuous feature result after layer normalization.
[0016] Preferably, S5 constructs a feature mapping and classification module, and inputs the feature results obtained by the feature fusion module into the module for further feature processing and prediction tasks.
[0017] Preferably, the multi-head attention module in S3 includes:
[0018] The attention function essentially maps a query and a set of key-value pairs to an output, where the query, key, value, and output are all vectors. The process expression is as follows:
[0019]
[0020] in, is the dimension of the input, which is also the scaling factor. First, the attention score between each Q vector and K vector is calculated in the form of an inner product, and then the scaling factor is used. Scaling is performed, and then the scaled scores are processed by Softmax, and finally multiplied by the weights of the matrix V to obtain the output matrix of the attention function.
[0021] Preferably, the gated feedforward neural network module in S3 includes:
[0022] It consists of a linear layer and a gating mechanism, where the operation of the gating mechanism is as follows:
[0023] f(x)=x⊙GELU(x)
[0024]
[0025] Preferably, the feature fusion module in S4 includes:
[0026] The feature data input to the module is flattened using the flatten() operation, and the flattened feature data is concatenated with the continuous features after layer normalization. The concatenated vector dimension is (d×m+c).
[0027] Preferably, the feature mapping and classification module in S5 includes:
[0028] After extracting the input features in the channel dimension using a feedforward neural network, in order to achieve cross-token interaction, a gating unit operating in the spatial dimension is designed, which can be simply represented by a linear mapping:
[0029] f W,b (Z) = WZ + b
[0030] where W∈R n×n Represents the interaction parameter of spatial mapping. Apply gating operation to the above formula as follows:
[0031] s(Z)=Z⊙f W,b (Z)
[0032] Among them, Z is divided into two parts (Z1, Z2) from the channel dimension for gating. The formula is as follows:
[0033] s(Z)=Z1⊙f W,b (Z2)
[0034] The features output by the spatial gating unit are extracted using a feedforward neural network in the spatial dimension, and then passed through a fully connected layer to obtain the classified feature vector, which is then passed through a linear layer to produce the final classification result.
[0035] Compared with the prior art, the present invention has the following beneficial effects:
[0036] The present invention adopts GatedTransformer as a feature extractor. Compared with the traditional Transformer network, the invention introduces an improvement of the gating mechanism and introduces a gated linear unit (GEGLU) in the feedforward neural network module, which can enhance the modeling ability of the model for nonlinear features. By introducing the gating mechanism, the nonlinear modeling ability is enhanced and the network's ability to extract complex data features is improved.
[0037] The feature mapping module in the present invention introduces a joint mapping mechanism for feature data, covering both dimensional and spatial levels. By integrating the mapping results of these two aspects, a more comprehensive feature extraction is achieved. This module aims to effectively capture the complex relationship between input features. By comprehensively considering the association between the dimensional information and spatial information of the features, the model is better able to understand and express the abstract characteristics of the input data, and improves the modeling ability of complex data structures. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 is a schematic flow chart of the present invention;
[0039] Figure 2 is a schematic diagram of a feature extractor of the present invention;
[0040] Figure 3It is a schematic module diagram of the feature mapping and classification module of the present invention. DETAILED DESCRIPTION
[0041] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0042] See also Figure 1 The present application embodiment provides a credit risk prediction method based on deep learning, comprising the following steps:
[0043] S1: Divide the training set and the test set, and divide the features in the training set and the test set into categorical features and continuous features respectively.
[0044] S2: Data preprocessing, column embedding for categorical features and normalization for continuous features.
[0045] S3: Use feature extractor to map classification features to feature space.
[0046] S4: The features output by the feature extractor are concatenated with the features after layer normalization through the feature fusion module.
[0047] S5: Extract input features through feature mapping module and complete the credit risk prediction task.
[0048] In this embodiment, the data set in S1 is divided into a training set D train and the test set D test , where the corresponding relationship between each set is Remember V train 、V test are the categories of the training set and the test set, and their relationship satisfies the non-intersection.
[0049] The features x of the samples in the training set and the test set are divided into categorical features and continuous features, that is, x = (xcat, xcont) (where x cat ≡{x1,x2,...,x m} are all categorical features, and each xi is a categorical feature, where i∈{1,...,m}. cont ∈R c Define all c continuous features). And define the label as y.
[0050] In this embodiment, each classification feature i in S2 has an embedded lookup table where i∈{1,...,m}. Use column embedding to transform x iThe classification features are embedded into the d-dimensional parameter embedding, let For x i The embedding of features, is the embedding set of all categorical features. And use layer normalization to normalize the continuous features x cont ∈R c to be processed.
[0051] The samples after classification features are divided Perform column embedding to get samples Among them, b is batch_size, n is cat is the classification feature x cat , and d is the dimension of column embedding.
[0052] In this embodiment, the structure of the feature extractor in S3 is as follows: Figure 2 As shown in the figure, a stacked GatedTransformer is used, and each layer of GatedTransformer consists of a multi-head attention mechanism module and a gated feedforward neural network module, and residual connections are introduced in the two modules.
[0053] Sample after embedding the columns Input to the feature extractor, the output after the multi-head attention module and residual connection is It is then fed into the gated feedforward neural network module and the output of the residual connection
[0054] I1 will get the output of each layer after passing through the feature extractor z=1,2,...,N, where N represents the number of stacked layers of GatedTransformer modules.
[0055] In this embodiment, S4 uses the flatten() operation to flatten the feature data input to the module, and concatenates the flattened feature data with the continuous features after layer normalization.
[0056] f n Input to the feature fusion module and obtain it through the flatten() operation The continuous feature samples after layer normalization are Among them, n cat represents the number of categorical features. After splicing with I2, we get
[0057] In this embodiment, the feature data input to the module is transformed in dimension using the Rearrange() and Linear layers in S5. Figure 3As shown, the feature mapping module includes a feature mapping module and a spatial gating module.
[0058] Will Input to the feature mapping module and obtained through the Rearrange() operation Then through the Linear layer to get (d m represents the dimension after mapping). Send it to the feedforward neural network to get Will After being sent to the space gating module, The last dimension is divided into two It complies with the following formula: in After passing through the spatial gating unit, we get Will Transpose to get Bundle Send it to the feedforward neural network to get The obtained features are passed through the fully connected layer to obtain the classified feature vector, and finally through the linear layer to produce the final classification result.
[0059] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the technical ideas and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A credit risk prediction method based on deep learning, characterized in that: The method comprises: S1. Divide the sample data set into training set and test set, and distinguish between categorical features and continuous features; S2. Use column embedding and layer normalization to process the categorical features and the continuous features respectively, to obtain categorical features after column embedding and continuous features after layer normalization; S3. Build a GatedTransformer feature extractor to convert the categorical features after column embedding into context embedding to obtain context embedding features; S4. construct a feature fusion module to integrate the context embedding features and the continuous features after layer normalization to obtain the features after feature fusion; S5. Construct a feature mapping and classification module, process the features after the feature fusion through a dual-channel feature extraction module and a spatial gating module, and complete the classification using a linear layer.
2. The credit risk prediction method based on deep learning according to claim 1, characterized in that: The S1 includes: Original credit risk dataset I∈R l×k (l is the number of samples, k is the number of features), divide the data set into training set Test Set (l1 is the number of samples in the training set, l2 is the number of samples in the test set); Divide the features in the training set and the test set into classification features x cat and continuous features x cont . Continuous feature x cont ∈R c Represents all c continuous features, categorical features x cat ≡{x1,x2,...,x m }, each x i is a categorical feature, where i∈{1,...,m}.
3. The credit risk prediction method based on deep learning according to claim 1, characterized in that: The S2 includes: Use column embedding to transform x i The classification features are embedded into the d-dimensional parameter embedding, let For x i The embedding of features is is the embedding set of all categorical features, and layer normalization is used to normalize continuous features.
4. The credit risk prediction method based on deep learning according to claim 1, characterized in that: The S3 includes: a feature extractor adopts a stacked GatedTransformer, which is composed of a multi-head attention module and a gated feedforward neural network module.
5. The credit risk prediction method based on deep learning according to claim 1, characterized in that: The S4 includes: the feature fusion module performs splicing processing on the final feature output result of the feature extractor and the continuous feature result after layer normalization, and the dimension of the spliced vector is (d×m+c).
6. The credit risk prediction method based on deep learning according to claim 1, characterized in that: S5 includes: the feature mapping and classification module performs further feature processing on the feature results after the splicing process and performs prediction tasks.
7. A credit risk prediction method based on deep learning according to claim 4, characterized in that: The multi-head attention module includes: The attention function essentially maps a query and a set of key-value pairs to an output, where the query, key, value, and output are all vectors. The process expression is: in, Represents the dimension of the input, which is also the scaling factor. First, the attention score between each Q vector and K vector is calculated in the form of an inner product, and then the scaling factor is used. The scaled scores are then scaled and Softmax processed, and finally multiplied by the weights of the matrix V to obtain the output matrix of the attention function.
8. The feature extractor according to claim 4, characterized in that: The gated feedforward neural network module comprises: It consists of a linear layer and a gating mechanism, where the formula of the gating mechanism is as follows: f(x)=x⊙GELU(x) in, 9. The feature mapping and classification module according to claim 6, characterized in that: After extracting the input features in the channel dimension using a feedforward neural network, in order to achieve cross-token interaction, a gating unit operating in the spatial dimension is designed, which can be simply represented by a linear mapping: f W,b (From)=WZ+b where W∈R n×n Represents the interaction parameter of spatial mapping, using the gating operation on the above formula, namely: s(Z)=Z⊙f W,b (Z) Among them, Z is divided into two parts (Z1, Z2) from the channel dimension for gating, and the formula is: s(Z)=Z1⊙f W,b (Z2) The features output by the spatial gating unit are extracted using a feedforward neural network in the spatial dimension, and then passed through a fully connected layer to obtain the classified feature vector, which is then passed through a linear layer to produce the final classification result.
