# Research on Default Prediction for Credit Card Users Based on XGBoost-LSTM Model

Authors: Jing Gao; Wenjun Sun; Xin Sui
Journal: Discrete Dynamics in Nature and Society
 (2021)

---

## Abstract

The credit card business has become an indispensable financial service for commercial banks. With the development of credit card business, commercial banks have achieved outstanding results in maintaining existing customers, tapping potential customers, and market share. During credit card operations, massive amounts of data in multiple dimensions—including basic customer information; billing, installment, and repayment information; transaction flows; and overdue records—are generated. Compared with preloan and postloan links, user default prediction of the on-loan link has a huge scale of data, which makes it difficult to identify signs of risk. With the recent growing maturity and practicality of technologies such as big data analysis and artificial intelligence, it has become possible to further mine and analyze massive amounts of transaction data. This study mined and analyzed the transaction flow data that best reflected customer behavior. XGBoost, which is widely used in financial classification models, and Long-Short Term Memory (LSTM), which is widely used in time-series information, were selected for comparative research. The accuracy of the XGBoost model depends on the degree of expertise in feature extraction, while the LSTM algorithm can achieve higher accuracy without feature extraction. The resulting XGBoost-LSTM model showed good classification performance in default prediction. The results of this study can provide a reference for the application of deep learning algorithms in the field of finance.


---

## Body

## 1. Introduction

Both the issuance of credit cards and the scale of credit have increased steadily in recent years. According to data from the People’s Bank of China, at the end of 2020, the number of credit cards issued totaled 778 million, and the credit balance of credit cards was 7.91 trillion yuan. With the effects of the COVID-19 pandemic, the quality of credit card assets deteriorated in 2020, and indicators such as overdue scale and nonperforming indicators are trending upward in the short term. The total overdue credit for the last half year was 83.8 billion yuan, accounting for 1.06% of the outstanding credit card balance, which marked an increase of 0.08% from the end of 2019. On the premise of ensuring the stable development of the credit card business, determining the effective management of credit card customers and reducing the problems caused by customer default have become a focus of attention. Effective use of already-collected customer information to identify customers who may default is a key measure to increase profits. Based on the results of default predictions, banks can reduce or freeze the credit lines of accounts that may default, thereby reducing their risk exposure. This would prevent an increase in the balance of an account destined to default and save financial institutions hundreds of millions of yuan in losses each year.Current default prediction is primarily based on account, credit bureau, and transaction flow data. The account-level data include, among other information, month-end balance, credit limit, borrower income, account activity, and arrears. Credit bureau data include credit score, total credit limit, total outstanding balance on all cards, and the number of outstanding accounts. Transaction flow data contain a large amount of information related to default prediction, such as consumption, installment, and repayment habits. Transaction flow data is easy for financial institutions to obtain, is difficult to forge, and has a high degree of authenticity. Khandani et al. [1] integrated account credit records, financial behavior, and user-level transaction flow data to predict overdue payments; the total transaction amount of nearly 20 categories was extracted as the feature value for the flow data. Their research indicated that any forward-looking insights about consumer credit collected from historical consumer behavior data are crucial. Machine-learning predictions are highly adaptable and can capture the dynamics of the ever-changing credit cycle and the absolute level of default rates.With the widespread application of artificial intelligence technology, scholars are increasingly applying machines to research on default prediction [2–8]. Butaru et al. [9] collected customer credit card data from multiple banks. These data included internal account-level information from banks and consumer data from large credit bureaus in the United States. Three data mining models—decision tree, random forest, and logistic regression—were used to study customer default predictions; the comparison showed that the decision tree and random forest models were better than logistic regression in credit card prediction accuracy. Since Chen and Guestrin [10] proposed the XGBoost algorithm in 2016, it has been used in many fields, including disease diagnosis, image recognition, and personal credit. Studies have shown that XGBoost can provide better prediction accuracy than other methods. Zhang and Chen [11] applied XGBoost to bond default risk prediction and found that the XGBoost algorithm was superior to traditional algorithms (e.g., LR, SVM, and KNN) for dealing with imbalanced data. Given its high performance in various fields, this study used the XGBoost algorithm as a representative machine-learning algorithm to establish a default prediction model and used it as a benchmark for comparison with deep learning models.The default prediction model based on machine learning requires extracting features of the transaction flow data. The quality of the model largely depends on the application of feature engineering [12–14]. The LSTM [15] algorithm performs well in time-series data mining and has had many applications in the financial field [16–19], such as customer service marketing, risk control, and trading strategy. In the field of antifraud, for example, deep learning technology automatically recognizes fraudulent transactions from massive amounts of transaction data, realizes successful interception, and blocks fraudulent transactions, thereby improving system effectiveness, reducing the rate of false alarms, and reducing compliance risks [20]. This article focuses on exploring the application of deep learning technology in processing transaction flow data to improve the accuracy of default prediction. Machine learning algorithms and deep learning algorithms are used on the same data set to construct default prediction models, and the prediction accuracy and modeling workload are compared, ultimately revealing that the deep learning model has high prediction accuracy and does not require features for default prediction. The results of this study have practical significance for guiding financial institutions in reducing losses caused by credit card customers who default.


## 2. Data

The source used to establish the default prediction model is user data from a certain small-scale commercial bank’s credit card services. The use of the data is authorized by the bank, and the data is desensitized and does not contain the user’s identity information. Most cardholders are small business owners, and the consumption amount exceeds 500 yuan automatically in installments. Thus, most users use IOUs or cash withdrawals, and there are only a few outgoing transactions and repayment transactions every month.


### 2.1. Data Type Description

The data include basic user information and installment, billing, transaction flow, and credit information; the variables included in these are all monthly variables. In addition to directly using the monthly values within the observation period, statistical information is also used, including the maximum, minimum, and average values, as well as the ratio of the amount to the credit limit during the period.


#### 2.1.1. Basic Information

Basic information includes not only information such as age, gender, and marital status, but also customer hierarchical code, which is a comprehensive indicator based on the user’s occupation; company nature and size; position; and annual income. It also includes the number of days since the card was created to the first use of the credit card processed according to user behavior, which can reflect the user’s desire for funds.


#### 2.1.2. Billing, Installment, and Credit Information

Billing information describes the user’s past bill amount and overdue status. Installment information is the number and amount of different installment states (e.g., new, activated, completed in advance, and completed), as well as the main installment type and expiration time. The credit information is the PBOC credit score, which is updated monthly.


#### 2.1.3. Transaction Flow Information

Transaction flow data contain the user ID and transaction date, time, type, and amount. The transaction type is a 4-digit code, covering more than 100 transaction types; the transaction amount is in RMB, and positive means outgoing, while negative means incoming. As shown in Table1, the length of monthly transaction data differs by cardholder, which is typical of unstructured data. With the large amount of data, this forms the main difficulty for processing transaction data.Table 1
Example of transactions flow data.
User IDInput dateInput timeTransaction typeBill amountCredit limit1000012017060515:25411048.28500001000012017060515:2521105000.00500001000012017060410:517098−10500.00500001000012017060515:26411050.00500001000012017061023:585000148.09500001000012017060515:2621105000.00500001000022017060521:057038−600.001000001000022017061020:0432541116.001000001000032017061020:0432541813.50200001000042017060514:0120006600.00500001000042017061020:04325080.00500001000042017061020:04325025.6050000………………


### 2.2. User-Defined

A good user is defined as one having no overdue situation within one year after the observation point. Bad users are defined as users who have been overdue for more than 60 days within one year after the observation point. Users who are overdue for 0–60 days are uncertain users and were not adopted. The total number of samples is 140,000, of which 80% are randomly selected as training samples and 20% as test samples. In both training data and test data, bad customers accounted for 20% of the sample.


## 2.1. Data Type Description

The data include basic user information and installment, billing, transaction flow, and credit information; the variables included in these are all monthly variables. In addition to directly using the monthly values within the observation period, statistical information is also used, including the maximum, minimum, and average values, as well as the ratio of the amount to the credit limit during the period.


### 2.1.1. Basic Information

Basic information includes not only information such as age, gender, and marital status, but also customer hierarchical code, which is a comprehensive indicator based on the user’s occupation; company nature and size; position; and annual income. It also includes the number of days since the card was created to the first use of the credit card processed according to user behavior, which can reflect the user’s desire for funds.


### 2.1.2. Billing, Installment, and Credit Information

Billing information describes the user’s past bill amount and overdue status. Installment information is the number and amount of different installment states (e.g., new, activated, completed in advance, and completed), as well as the main installment type and expiration time. The credit information is the PBOC credit score, which is updated monthly.


### 2.1.3. Transaction Flow Information

Transaction flow data contain the user ID and transaction date, time, type, and amount. The transaction type is a 4-digit code, covering more than 100 transaction types; the transaction amount is in RMB, and positive means outgoing, while negative means incoming. As shown in Table1, the length of monthly transaction data differs by cardholder, which is typical of unstructured data. With the large amount of data, this forms the main difficulty for processing transaction data.Table 1
Example of transactions flow data.
User IDInput dateInput timeTransaction typeBill amountCredit limit1000012017060515:25411048.28500001000012017060515:2521105000.00500001000012017060410:517098−10500.00500001000012017060515:26411050.00500001000012017061023:585000148.09500001000012017060515:2621105000.00500001000022017060521:057038−600.001000001000022017061020:0432541116.001000001000032017061020:0432541813.50200001000042017060514:0120006600.00500001000042017061020:04325080.00500001000042017061020:04325025.6050000………………


## 2.1.1. Basic Information

Basic information includes not only information such as age, gender, and marital status, but also customer hierarchical code, which is a comprehensive indicator based on the user’s occupation; company nature and size; position; and annual income. It also includes the number of days since the card was created to the first use of the credit card processed according to user behavior, which can reflect the user’s desire for funds.


## 2.1.2. Billing, Installment, and Credit Information

Billing information describes the user’s past bill amount and overdue status. Installment information is the number and amount of different installment states (e.g., new, activated, completed in advance, and completed), as well as the main installment type and expiration time. The credit information is the PBOC credit score, which is updated monthly.


## 2.1.3. Transaction Flow Information

Transaction flow data contain the user ID and transaction date, time, type, and amount. The transaction type is a 4-digit code, covering more than 100 transaction types; the transaction amount is in RMB, and positive means outgoing, while negative means incoming. As shown in Table1, the length of monthly transaction data differs by cardholder, which is typical of unstructured data. With the large amount of data, this forms the main difficulty for processing transaction data.Table 1
Example of transactions flow data.
User IDInput dateInput timeTransaction typeBill amountCredit limit1000012017060515:25411048.28500001000012017060515:2521105000.00500001000012017060410:517098−10500.00500001000012017060515:26411050.00500001000012017061023:585000148.09500001000012017060515:2621105000.00500001000022017060521:057038−600.001000001000022017061020:0432541116.001000001000032017061020:0432541813.50200001000042017060514:0120006600.00500001000042017061020:04325080.00500001000042017061020:04325025.6050000………………


## 2.2. User-Defined

A good user is defined as one having no overdue situation within one year after the observation point. Bad users are defined as users who have been overdue for more than 60 days within one year after the observation point. Users who are overdue for 0–60 days are uncertain users and were not adopted. The total number of samples is 140,000, of which 80% are randomly selected as training samples and 20% as test samples. In both training data and test data, bad customers accounted for 20% of the sample.


## 3. Model Evaluation Index

The confusion matrix and area under the curve (AUC) were used to evaluate the models. The confusion matrix summarizes the records in the data set in the form of a matrix according to the two criteria of the real category and the classification judgment made by the classification model [21]. The name is derived from the fact that it can easily be indicated whether there is confusion among multiple categories (i.e., a positive category is predicted as a negative category). P and N represent the positive and negative judgment results of the model, respectively. T and F represent the judgment results of the model as True and False. The confusion matrix is defined as follows:(1)confusion matrix=TPFNFPTN.Knowing the confusion matrix, the accuracy rate (ACC), precision, and recall can be calculated, and the formulas are as follows:(2)ACC=TP+TNTP+FN+FP+TN,precision=TPTP+FP,recall=TPTP+FN.The ACC value is calculated based on the cutoff value between positive and negative examples. Compared with the ACC value, the AUC value can integrate the predictive performance of all cutoff values [11, 22]. AUC represents the area under the receiver operating characteristic (ROC) curve, which is between 0 and 1. As a value, AUC can intuitively evaluate the quality of the classifier: the larger the value, the better. It is calculated as follows:(3)AUC=∑positiveranki−MM+1/2M∗N.


## 4. XGBoost Model

### 4.1. XGBoost Algorithm

Extreme gradient boosting (XGBoost) is a boosting-type tree algorithm proposed by Chen and Guestrin. It is widely used in web text and product classification, as well as customer behavior prediction, and it has achieved the most advanced results in many machine learning competitions [10]. Its wide application benefits from optimization in the following four aspects: a distributed weighted square graph algorithm that solves the problem of segmentation point selection, better processing of sparse data, efficient cache-aware block data storage structure, and better usage of parallel and distributed computing.The prediction results of the model consisting of K decision trees are(4)y^i=ϕxi=∑k=1Kfkxi,fk∈ℱ,where xi is the i-th input sample; y^i is the predicted value calculated through the mapping relationship fk; and ℱ is the collection of mapping relationships. The optimization objective and loss function are defined as(5)ℒϕ=∑ily^i,yi+∑kΩfk,Ωf=γT+12λω2.Here,l is the differentiable convex loss function, which measures the difference between the predicted value y^i and the target value yi, and Ω is an additional regularization term to help smooth the weight of the model to avoid overfitting.The above test contains functions as parameters, which cannot be optimized in Euclidean space using traditional methods;y^it is defined as the i-th prediction of the t-th iteration. Then, the loss function is defined as(6)ℒt=∑i=1nlyi,y^it−1+ftxi+Ωft.A second-order Taylor expansion is performed on the previous equation:(7)ℒt≅∑i=1nlyi,y^it−1+giftxi+12hift2xi+Ωft.The constant term is removed to yield the simplified objective function of thet-th iteration:(8)ℒ˜t=∑i=1ngiftxi+12hift2xi+Ωft,gi=∂y^it−1lyi,y^it−1,hi=∂y^it−12lyi,y^it−1,where gi is the first-order partial derivative of lyi,y^it−1 to y^it−1 and hi is the second-order partial derivative of lyi,y^it−1 to y^it−1. Ij is defined as the sample set on each leaf node, and ωj as the weight of the corresponding leaf node. Formula (8) can be rewritten as(9)ℒ˜t=∑i=1ngiftxi+12hift2xi+γT+12λ∑j=1Tωj2,ℒ˜t=∑j=1T∑i∈Ijgiωj+12∑i∈Ijhi+λωj2+γT.For a certain tree structureqx, the optimal weight ωj∗ for the leaf nodes can be calculated by the following formula:(10)ωj∗=−∑i∈Ijgi∑i∈Ijhi+λ.The corresponding optimal objective function can be calculated as follows:(11)ℒ˜tq=−12∑j=1T∑i∈Ijgi2∑i∈Ijhi+λ+γT.


### 4.2. Transaction Flow Feature Extraction

Using the XGBoost model for overdue forecasting requires feature extraction of the original transaction data and conversion of original data of unequal length into feature data of equal length. The transaction data was first classified and counted based on business experience and historical documents. The process of feature extraction is to initially screen out important features based on business experience and then derive feature statistics. First, the data was divided into four main categories according to transaction type: consumption, cash withdrawal, fee, and repayment. The number of transactions was then separately counted, and the total transaction amount for each major category was found. Finally, the statistics were calculated for three months. In the first stage, 48 feature values were extracted, as shown in Table2. However, the prediction results obtained from these features are not ideal. In the second stage, we continued to dig into the data to understand the business background and added 34 features (totaling 82 features, as shown in Table 2). The added features include the number of days for repayment in advance, statistics on the number of transactions per month, and separate statistics for a special transaction type: penalty.Table 2
Extracted features from transaction data.
Transaction typeFirst monthSecond monthThird monthMaxMinMeanOthersAmount of consumptionc_sum_1c_sum_2c_sum_3c_sum_maxc_sum_minc_sum_meanc_sum_max/creditNumber of consumptionc_num_1c_num_2c_num_3c_num_maxc_num_minc_num_meanAmount of feesf_sum_1f_sum_2f_sum_3f_sum_maxf_sum_minf_sum_meanf_sum_max/creditNumber of feesf_num_1f_num_2f_num_3f_num_maxf_num_minf_num_meanAmount of repaymentsr_sum_1r_sum_2r_sum_3r_sum_maxr_sum_minr_sum_meanr_sum_max/creditNumber of repaymentsr_num_1r_num_2r_num_3r_num_maxr_num_minr_num_meanAmount of cash withdrawalscw_sum_1cw_sum_2cw_sum_3cw_sum_maxcw_sum_mincw_sum_meancw_sum_max/creditNumber of cash withdrawalscw_num_1cw_num_2cw_num_3cw_num_maxcw_num_mincw_num_meanAmount of penaltypenalty_sum_1penalty_sum_2penalty_sum_3penalty_sum_maxpenalty_sum_minpenalty_sum_medianpenalty_sum_max/creditNumber of penaltypenalty_num_1penalty_num_2penalty_num_3penalty_num_maxpenalty_num_minpenalty_numRepayment days in advancepre_pay_days_1pre_pay_days_2pre_pay_days_3pre_pay_days_maxpre_pay_days_minpre_pay_days_medianNumber of transaction flowevent_counts_1event_counts_2event_counts_3event_counts_maxevent_counts_minevent_counts_medianevent_counts_sumMain transaction typestrans_type_mode_1trans_type_mode_2trans_type_mode_3trans_type_mode_all


### 4.3. XGBoost Model Establishment

The flowchart for XGBoost model establishment is shown in Figure1. First, user-related basic information, credit information, and billing, installment, and transaction flow were collected and preprocessed (e.g., data screening, classification label generation, and missing data supplementation). Then, the flow characteristics of the transaction flow data were extracted and input into the XGBoost classification model. For other types of data, monthly data generation and statistical calculation were performed for the observation period and then entered into the XGBoost classification model as feature values. Finally, the XGBoost classification model was trained. If the model evaluation conditions are met, the establishment of the default prediction model is complete.Figure 1
The flow chart of XGBoost model establishment.


### 4.4. Feature Importance

Figure2 shows the top 20 most important features and their weights for the XGBoost model. The default classification is primarily based on penalty-related features and the PBOC score. Five of the top 20 most important indicators are related to transaction flow data, and the importance accounts for a total of 24%. This shows that the transaction flow data contain important information related to default prediction. Penalty-related features are not in the preliminary extraction of the transaction flow data but are important features selected after in-depth analysis of each transaction type. The model evaluation indicators of XGBoost algorithm models using different features are shown in Table 3. When the transaction features are not used for overdue prediction, the AUC value of the XGBoost model is 71%. The prediction effect of using 48 preliminary extracted transaction features in the first stage is better than not using them. Compared with using preliminary extracted transaction features, the AUC is increased by 13%, and the recall rate is increased by 34% when using all 82 transaction features, which is a significant improvement, indicating that the features mined in the second stage have better distinguishing ability. Feature extraction is thus the most important and most arduous step in machine learning modeling.Figure 2
Feature importance index ranking of the XGBoost model.Table 3
Model evaluation indicators of XGBoost algorithm models using different features.
FeaturesTrain AUCTrain ACCTest AUCTest ACCTest recallTest precisionWithout transaction features0.7160.8010.7100.7990.0080.493The first stage0.7640.8210.7590.8190.1630.714The first and second stages0.8950.8730.8930.8700.5070.768


### 4.5. XGBoost Model Evaluation

The confusion matrix of the test data based on the XGBoost model is shown in Figure3(a). According to the confusion matrix, the ACC is 86.5%, the precision is 74.1%, and the recall is 51.5%. The ROC curve of the test data is shown in Figure 3(b), and the AUC is 89%.Figure 3
The confusion matrix and ROC of the XGBoost model. (a) The confusion matrix of the test data. (b) The ROC curve of the test data.
(a)(b)


### 4.6. Comparison of Machine Learning Models

The corresponding data packages in Python were used to train the machine learning models for default prediction. Model parameter settings and data preprocessing methods are shown in Table4. Except for the necessary normalization of the K neighborhood and SVM algorithm, the other algorithms used the same original data. The principle of parameter setting was to set as few parameters as possible without overfitting.Table 4
Machine learning model data processing methods and model settings.
AlgorithmData processingModel settingsK neighborsNormalization, missing value supplementn_neighbors = 10SVMNormalization, missing value supplementkernel = “rbf,” max_iter = 500DecisionTree—max_depth = 4RandomForest—max_depth = 4AdaBoost—max_depth = 4XGBoost—max_depth = 4The model evaluation indicators of machine learning algorithms are shown in Table5. The K neighborhood and SVM algorithm for default prediction appear to be less effective, and the decision tree, random forest, AdaBoost, and XGBoost algorithms are better; of these, the XGBoost algorithm is the best. Figure 4 shows the ROC curves for the different algorithms.Table 5
Model evaluation indicators of machine learning algorithms.
AlgorithmTrain AUCTrain ACCTest AUCTest ACCTest recallTest precisionK neighbors0.8440.8360.5470.7940.0170.274SVM0.7140.7930.7380.7720.4550.435DecisionTree0.8550.8550.8520.8530.4590.705RandomForest0.8570.8410.8540.8380.2450.818AdaBoost0.8900.8660.8840.8630.5070.725XGBoost0.9200.9160.8890.8650.5150.734Figure 4
The ROC curve of machine learning algorithms.


## 4.1. XGBoost Algorithm

Extreme gradient boosting (XGBoost) is a boosting-type tree algorithm proposed by Chen and Guestrin. It is widely used in web text and product classification, as well as customer behavior prediction, and it has achieved the most advanced results in many machine learning competitions [10]. Its wide application benefits from optimization in the following four aspects: a distributed weighted square graph algorithm that solves the problem of segmentation point selection, better processing of sparse data, efficient cache-aware block data storage structure, and better usage of parallel and distributed computing.The prediction results of the model consisting of K decision trees are(4)y^i=ϕxi=∑k=1Kfkxi,fk∈ℱ,where xi is the i-th input sample; y^i is the predicted value calculated through the mapping relationship fk; and ℱ is the collection of mapping relationships. The optimization objective and loss function are defined as(5)ℒϕ=∑ily^i,yi+∑kΩfk,Ωf=γT+12λω2.Here,l is the differentiable convex loss function, which measures the difference between the predicted value y^i and the target value yi, and Ω is an additional regularization term to help smooth the weight of the model to avoid overfitting.The above test contains functions as parameters, which cannot be optimized in Euclidean space using traditional methods;y^it is defined as the i-th prediction of the t-th iteration. Then, the loss function is defined as(6)ℒt=∑i=1nlyi,y^it−1+ftxi+Ωft.A second-order Taylor expansion is performed on the previous equation:(7)ℒt≅∑i=1nlyi,y^it−1+giftxi+12hift2xi+Ωft.The constant term is removed to yield the simplified objective function of thet-th iteration:(8)ℒ˜t=∑i=1ngiftxi+12hift2xi+Ωft,gi=∂y^it−1lyi,y^it−1,hi=∂y^it−12lyi,y^it−1,where gi is the first-order partial derivative of lyi,y^it−1 to y^it−1 and hi is the second-order partial derivative of lyi,y^it−1 to y^it−1. Ij is defined as the sample set on each leaf node, and ωj as the weight of the corresponding leaf node. Formula (8) can be rewritten as(9)ℒ˜t=∑i=1ngiftxi+12hift2xi+γT+12λ∑j=1Tωj2,ℒ˜t=∑j=1T∑i∈Ijgiωj+12∑i∈Ijhi+λωj2+γT.For a certain tree structureqx, the optimal weight ωj∗ for the leaf nodes can be calculated by the following formula:(10)ωj∗=−∑i∈Ijgi∑i∈Ijhi+λ.The corresponding optimal objective function can be calculated as follows:(11)ℒ˜tq=−12∑j=1T∑i∈Ijgi2∑i∈Ijhi+λ+γT.


## 4.2. Transaction Flow Feature Extraction

Using the XGBoost model for overdue forecasting requires feature extraction of the original transaction data and conversion of original data of unequal length into feature data of equal length. The transaction data was first classified and counted based on business experience and historical documents. The process of feature extraction is to initially screen out important features based on business experience and then derive feature statistics. First, the data was divided into four main categories according to transaction type: consumption, cash withdrawal, fee, and repayment. The number of transactions was then separately counted, and the total transaction amount for each major category was found. Finally, the statistics were calculated for three months. In the first stage, 48 feature values were extracted, as shown in Table2. However, the prediction results obtained from these features are not ideal. In the second stage, we continued to dig into the data to understand the business background and added 34 features (totaling 82 features, as shown in Table 2). The added features include the number of days for repayment in advance, statistics on the number of transactions per month, and separate statistics for a special transaction type: penalty.Table 2
Extracted features from transaction data.
Transaction typeFirst monthSecond monthThird monthMaxMinMeanOthersAmount of consumptionc_sum_1c_sum_2c_sum_3c_sum_maxc_sum_minc_sum_meanc_sum_max/creditNumber of consumptionc_num_1c_num_2c_num_3c_num_maxc_num_minc_num_meanAmount of feesf_sum_1f_sum_2f_sum_3f_sum_maxf_sum_minf_sum_meanf_sum_max/creditNumber of feesf_num_1f_num_2f_num_3f_num_maxf_num_minf_num_meanAmount of repaymentsr_sum_1r_sum_2r_sum_3r_sum_maxr_sum_minr_sum_meanr_sum_max/creditNumber of repaymentsr_num_1r_num_2r_num_3r_num_maxr_num_minr_num_meanAmount of cash withdrawalscw_sum_1cw_sum_2cw_sum_3cw_sum_maxcw_sum_mincw_sum_meancw_sum_max/creditNumber of cash withdrawalscw_num_1cw_num_2cw_num_3cw_num_maxcw_num_mincw_num_meanAmount of penaltypenalty_sum_1penalty_sum_2penalty_sum_3penalty_sum_maxpenalty_sum_minpenalty_sum_medianpenalty_sum_max/creditNumber of penaltypenalty_num_1penalty_num_2penalty_num_3penalty_num_maxpenalty_num_minpenalty_numRepayment days in advancepre_pay_days_1pre_pay_days_2pre_pay_days_3pre_pay_days_maxpre_pay_days_minpre_pay_days_medianNumber of transaction flowevent_counts_1event_counts_2event_counts_3event_counts_maxevent_counts_minevent_counts_medianevent_counts_sumMain transaction typestrans_type_mode_1trans_type_mode_2trans_type_mode_3trans_type_mode_all


## 4.3. XGBoost Model Establishment

The flowchart for XGBoost model establishment is shown in Figure1. First, user-related basic information, credit information, and billing, installment, and transaction flow were collected and preprocessed (e.g., data screening, classification label generation, and missing data supplementation). Then, the flow characteristics of the transaction flow data were extracted and input into the XGBoost classification model. For other types of data, monthly data generation and statistical calculation were performed for the observation period and then entered into the XGBoost classification model as feature values. Finally, the XGBoost classification model was trained. If the model evaluation conditions are met, the establishment of the default prediction model is complete.Figure 1
The flow chart of XGBoost model establishment.


## 4.4. Feature Importance

Figure2 shows the top 20 most important features and their weights for the XGBoost model. The default classification is primarily based on penalty-related features and the PBOC score. Five of the top 20 most important indicators are related to transaction flow data, and the importance accounts for a total of 24%. This shows that the transaction flow data contain important information related to default prediction. Penalty-related features are not in the preliminary extraction of the transaction flow data but are important features selected after in-depth analysis of each transaction type. The model evaluation indicators of XGBoost algorithm models using different features are shown in Table 3. When the transaction features are not used for overdue prediction, the AUC value of the XGBoost model is 71%. The prediction effect of using 48 preliminary extracted transaction features in the first stage is better than not using them. Compared with using preliminary extracted transaction features, the AUC is increased by 13%, and the recall rate is increased by 34% when using all 82 transaction features, which is a significant improvement, indicating that the features mined in the second stage have better distinguishing ability. Feature extraction is thus the most important and most arduous step in machine learning modeling.Figure 2
Feature importance index ranking of the XGBoost model.Table 3
Model evaluation indicators of XGBoost algorithm models using different features.
FeaturesTrain AUCTrain ACCTest AUCTest ACCTest recallTest precisionWithout transaction features0.7160.8010.7100.7990.0080.493The first stage0.7640.8210.7590.8190.1630.714The first and second stages0.8950.8730.8930.8700.5070.768


## 4.5. XGBoost Model Evaluation

The confusion matrix of the test data based on the XGBoost model is shown in Figure3(a). According to the confusion matrix, the ACC is 86.5%, the precision is 74.1%, and the recall is 51.5%. The ROC curve of the test data is shown in Figure 3(b), and the AUC is 89%.Figure 3
The confusion matrix and ROC of the XGBoost model. (a) The confusion matrix of the test data. (b) The ROC curve of the test data.
(a)(b)


## 4.6. Comparison of Machine Learning Models

The corresponding data packages in Python were used to train the machine learning models for default prediction. Model parameter settings and data preprocessing methods are shown in Table4. Except for the necessary normalization of the K neighborhood and SVM algorithm, the other algorithms used the same original data. The principle of parameter setting was to set as few parameters as possible without overfitting.Table 4
Machine learning model data processing methods and model settings.
AlgorithmData processingModel settingsK neighborsNormalization, missing value supplementn_neighbors = 10SVMNormalization, missing value supplementkernel = “rbf,” max_iter = 500DecisionTree—max_depth = 4RandomForest—max_depth = 4AdaBoost—max_depth = 4XGBoost—max_depth = 4The model evaluation indicators of machine learning algorithms are shown in Table5. The K neighborhood and SVM algorithm for default prediction appear to be less effective, and the decision tree, random forest, AdaBoost, and XGBoost algorithms are better; of these, the XGBoost algorithm is the best. Figure 4 shows the ROC curves for the different algorithms.Table 5
Model evaluation indicators of machine learning algorithms.
AlgorithmTrain AUCTrain ACCTest AUCTest ACCTest recallTest precisionK neighbors0.8440.8360.5470.7940.0170.274SVM0.7140.7930.7380.7720.4550.435DecisionTree0.8550.8550.8520.8530.4590.705RandomForest0.8570.8410.8540.8380.2450.818AdaBoost0.8900.8660.8840.8630.5070.725XGBoost0.9200.9160.8890.8650.5150.734Figure 4
The ROC curve of machine learning algorithms.


## 5. XGBoost-LSTM Model

### 5.1. LSTM Algorithm

The traditional neural network model is fully connected from the input layer to the hidden layer and then to the output layer, which means there is no connection between nodes in the same layer, and the propagation of the network is sequential. This kind of network structure often appears powerless to deal with sequence or time-series problems because of its lack of memory. Therefore, a new kind of network—recurrent neural network (RNN)—is required. LSTM is a type of RNN that is especially good at processing sequence data. The ingenuity of LSTM is that, by increasing the input, forgetting, and output thresholds, the weight of the self-loop is changed. In the case of fixed model parameters, the integration scale at different times can be dynamically changed, thereby avoiding the problem of gradient disappearance or expansion. Figure5 illustrates the structure of the LSTM unit.Figure 5
The structure of the LSTM unit.


#### 5.1.1. Input Gate

The input gate (git) controls the information entered into the internal storage unit, which can be expressed as follows:(12)git=σ⋅big+∑jUijgxjt+∑jWijghjt−1.σ is the sigmoid function; xt is input vector at time t; ht is hidden layer vector, including the output of all LSTM units; and bg, Ug, and Wg represent the deviation, the input weight, and the cycle weight of the input gate, respectively.


#### 5.1.2. Forget Gate

The forget gate (fit) controls how much information from the previous time is stored in the internal storage unit, which can be expressed as(13)fit=σ⋅bif+∑jUijfxjt+∑jWijfhjt−1.In formula (13), bf, Uf, and Wf represent, respectively, the deviation, input weight, and loop weight of the forget gate. The expression of the internal storage unit of the LSTM unit is as follows:(14)Sit=fitSit−1+gitσ⋅bi+∑jUijxjt+∑jWijhjt−1,where b, U, and W represent the deviation, input weight, and cycle weight of the LSTM unit, respectively. On the right side of formula (14), the first half is the cell state information controlled by the forget gate, and the second half is the input information controlled by the input gate [16].


#### 5.1.3. Output Gate

The output gate (Oit) controls the internal storage unit by releasing and generating the required information, which can be given by the following formula:(15)Oit=σ⋅bio+∑jUijoxjt+∑jWijohjt−1,hit=tanhSitOit.Here,bo, Uo, and Wo represent the deviation, input weight, and loop weight, respectively, of the output gate.


### 5.2. Transaction Flow Data Processing

The establishment of a default prediction model using the LSTM algorithm does not require feature extraction; the data processing work mainly involves interception and complementation. According to the distribution of the average number of transactions per month by user, 30 was selected as the threshold for the number of transactions per month. Data exceeding the threshold were discarded, and insufficient data were filled with zeros. The 3 months of transaction flow data were then spliced. Table6 shows the input data for the LSTM model of a certain account after processing.Table 6
Example of LSTM model input data example.
No.Days before billingInput timeTransaction typeBill amountBill amount/creditlimit∗100130207028−200021877028−1013−331007028−9.450410032549.450510020201000360137028−95.67070203254125.5508020325436.270900000………………310177028−1560320203254121.5033020325435.1034020325427.41035020325424.303600000370000038000003900000………………6120167028−1150−36220167028−1480−4632016325412.8706420162020260086519167028−8000−266619177028−1045−3671917325448.606819172020900030690147028−300−1………………


### 5.3. XGBoost Model Establishment

The flowchart for establishing the XGBoost-LSTM model is shown in Figure6. The processing of transaction flow data is different from the process of establishing the XGBoost model. There is no need to perform feature extraction for the transaction flow data; directly train the LSTM flow data classification model on the spliced flow data during the observation period. The classification results of the LSTM model were used as features input into the XGBoost model for training.Figure 6
The flow chart of the XGBoost-LSTM model establishment.


### 5.4. Feature Importance

Figure7 shows the top 20 most important features and their weights for the XGBoost-LSTM model. The default classification of the XGBoost-LSTM model was based on outputs of LSTM model and the PBOC score.Figure 7
Feature importance index ranking of the XGBoost-LSTM model.


### 5.5. XGBoost-LSTM Model Evaluation

The confusion matrix for the test data based on the XGBoost-LSTM model is shown in Figure8(a). The ACC is 93.6%, the precision is 92.8%, and the recall is 73.6%. The ROC curve of the test data is shown in Figure 8(b), and the AUC is 0.95.Figure 8
The confusion matrix and ROC of the XGBoost-LSTM model. (a) The confusion matrix of the test data. (b) The ROC curve of the test data.
(a)(b)


### 5.6. Comparison of XGBoost Model and XGBoost-LSTM Model

#### 5.6.1. Data Processing

Table7 shows the data sources and data processing methods required by different algorithms. The XGBoost-LSTM model requires the least amount of work, which reduces the work of feature extraction from the transaction flow data.Table 7
Data processing methods for modeling with different algorithms.
XGBoostXGBoost_LSTMData processingNumberData processingNumberBasic information—19—19Credit informationMonthly data6Monthly data6Calculate statisticsCalculate statisticsBilling informationMonthly data106Monthly data106Calculate statisticsCalculate statisticsInstallment informationMonthly data113Monthly data113Calculate statisticsCalculate statisticsTransaction flow informationFeature extraction83Interception or zero padding, splicing2Calculate statisticsLSTM


#### 5.6.2. Model Performance

The model evaluation indicators are shown in Table8. Combining the data in Table 3, when the transaction features are not used for overdue prediction, the test set AUC of the model is 71%, the recall rate is 0.8%, and the accuracy is 49%. Adding the two output results of the LSTM model, the AUC of the model test set increased by 24%, the recall rate increased by 73%, and the accuracy rate increased by 43%. The significant increase in evaluation indicators proves the usefulness of the output features of the LSTM model. At the same time, the XGBoost-LSTM model has less improvement in AUC and accuracy compared with the XGBoost model building with the extracted transaction features. This shows that, under the premise of extracting useful features, the XGBoost model can also have good predictive performance. However, the extraction of useful features is based on deep business experience and a large amount of data mining. As shown in Figures 3(a) and 8(a), the XGBoost-LSTM model identified 2035 more bad samples than the XGBoost model (a total of 8,863 bad samples), and the number of false identifications of good samples decreased by 957. It means that bad customers are detected 23% more, and the false identification rate of samples predicted to be bad users decreased by 16% in the actual application of the model. The XGBoost-LSTM model thus obtains best prediction results on the data set used in this study. The results verify that the XGBoost-LSTM model can be realized without feature extraction and still have high classification accuracy.Table 8
Model evaluation indicators for XGBoost model and XGBoost-LSTM model.
AlgorithmTrain AUCTrain ACCTest AUCTest ACCTest recallTest precisionXGBoost0.8950.8730.8930.8700.5070.768XGBoost-LSTM0.9540.9370.9530.9360.7360.928


## 5.1. LSTM Algorithm

The traditional neural network model is fully connected from the input layer to the hidden layer and then to the output layer, which means there is no connection between nodes in the same layer, and the propagation of the network is sequential. This kind of network structure often appears powerless to deal with sequence or time-series problems because of its lack of memory. Therefore, a new kind of network—recurrent neural network (RNN)—is required. LSTM is a type of RNN that is especially good at processing sequence data. The ingenuity of LSTM is that, by increasing the input, forgetting, and output thresholds, the weight of the self-loop is changed. In the case of fixed model parameters, the integration scale at different times can be dynamically changed, thereby avoiding the problem of gradient disappearance or expansion. Figure5 illustrates the structure of the LSTM unit.Figure 5
The structure of the LSTM unit.


### 5.1.1. Input Gate

The input gate (git) controls the information entered into the internal storage unit, which can be expressed as follows:(12)git=σ⋅big+∑jUijgxjt+∑jWijghjt−1.σ is the sigmoid function; xt is input vector at time t; ht is hidden layer vector, including the output of all LSTM units; and bg, Ug, and Wg represent the deviation, the input weight, and the cycle weight of the input gate, respectively.


### 5.1.2. Forget Gate

The forget gate (fit) controls how much information from the previous time is stored in the internal storage unit, which can be expressed as(13)fit=σ⋅bif+∑jUijfxjt+∑jWijfhjt−1.In formula (13), bf, Uf, and Wf represent, respectively, the deviation, input weight, and loop weight of the forget gate. The expression of the internal storage unit of the LSTM unit is as follows:(14)Sit=fitSit−1+gitσ⋅bi+∑jUijxjt+∑jWijhjt−1,where b, U, and W represent the deviation, input weight, and cycle weight of the LSTM unit, respectively. On the right side of formula (14), the first half is the cell state information controlled by the forget gate, and the second half is the input information controlled by the input gate [16].


### 5.1.3. Output Gate

The output gate (Oit) controls the internal storage unit by releasing and generating the required information, which can be given by the following formula:(15)Oit=σ⋅bio+∑jUijoxjt+∑jWijohjt−1,hit=tanhSitOit.Here,bo, Uo, and Wo represent the deviation, input weight, and loop weight, respectively, of the output gate.


## 5.1.1. Input Gate

The input gate (git) controls the information entered into the internal storage unit, which can be expressed as follows:(12)git=σ⋅big+∑jUijgxjt+∑jWijghjt−1.σ is the sigmoid function; xt is input vector at time t; ht is hidden layer vector, including the output of all LSTM units; and bg, Ug, and Wg represent the deviation, the input weight, and the cycle weight of the input gate, respectively.


## 5.1.2. Forget Gate

The forget gate (fit) controls how much information from the previous time is stored in the internal storage unit, which can be expressed as(13)fit=σ⋅bif+∑jUijfxjt+∑jWijfhjt−1.In formula (13), bf, Uf, and Wf represent, respectively, the deviation, input weight, and loop weight of the forget gate. The expression of the internal storage unit of the LSTM unit is as follows:(14)Sit=fitSit−1+gitσ⋅bi+∑jUijxjt+∑jWijhjt−1,where b, U, and W represent the deviation, input weight, and cycle weight of the LSTM unit, respectively. On the right side of formula (14), the first half is the cell state information controlled by the forget gate, and the second half is the input information controlled by the input gate [16].


## 5.1.3. Output Gate

The output gate (Oit) controls the internal storage unit by releasing and generating the required information, which can be given by the following formula:(15)Oit=σ⋅bio+∑jUijoxjt+∑jWijohjt−1,hit=tanhSitOit.Here,bo, Uo, and Wo represent the deviation, input weight, and loop weight, respectively, of the output gate.


## 5.2. Transaction Flow Data Processing

The establishment of a default prediction model using the LSTM algorithm does not require feature extraction; the data processing work mainly involves interception and complementation. According to the distribution of the average number of transactions per month by user, 30 was selected as the threshold for the number of transactions per month. Data exceeding the threshold were discarded, and insufficient data were filled with zeros. The 3 months of transaction flow data were then spliced. Table6 shows the input data for the LSTM model of a certain account after processing.Table 6
Example of LSTM model input data example.
No.Days before billingInput timeTransaction typeBill amountBill amount/creditlimit∗100130207028−200021877028−1013−331007028−9.450410032549.450510020201000360137028−95.67070203254125.5508020325436.270900000………………310177028−1560320203254121.5033020325435.1034020325427.41035020325424.303600000370000038000003900000………………6120167028−1150−36220167028−1480−4632016325412.8706420162020260086519167028−8000−266619177028−1045−3671917325448.606819172020900030690147028−300−1………………


## 5.3. XGBoost Model Establishment

The flowchart for establishing the XGBoost-LSTM model is shown in Figure6. The processing of transaction flow data is different from the process of establishing the XGBoost model. There is no need to perform feature extraction for the transaction flow data; directly train the LSTM flow data classification model on the spliced flow data during the observation period. The classification results of the LSTM model were used as features input into the XGBoost model for training.Figure 6
The flow chart of the XGBoost-LSTM model establishment.


## 5.4. Feature Importance

Figure7 shows the top 20 most important features and their weights for the XGBoost-LSTM model. The default classification of the XGBoost-LSTM model was based on outputs of LSTM model and the PBOC score.Figure 7
Feature importance index ranking of the XGBoost-LSTM model.


## 5.5. XGBoost-LSTM Model Evaluation

The confusion matrix for the test data based on the XGBoost-LSTM model is shown in Figure8(a). The ACC is 93.6%, the precision is 92.8%, and the recall is 73.6%. The ROC curve of the test data is shown in Figure 8(b), and the AUC is 0.95.Figure 8
The confusion matrix and ROC of the XGBoost-LSTM model. (a) The confusion matrix of the test data. (b) The ROC curve of the test data.
(a)(b)


## 5.6. Comparison of XGBoost Model and XGBoost-LSTM Model

### 5.6.1. Data Processing

Table7 shows the data sources and data processing methods required by different algorithms. The XGBoost-LSTM model requires the least amount of work, which reduces the work of feature extraction from the transaction flow data.Table 7
Data processing methods for modeling with different algorithms.
XGBoostXGBoost_LSTMData processingNumberData processingNumberBasic information—19—19Credit informationMonthly data6Monthly data6Calculate statisticsCalculate statisticsBilling informationMonthly data106Monthly data106Calculate statisticsCalculate statisticsInstallment informationMonthly data113Monthly data113Calculate statisticsCalculate statisticsTransaction flow informationFeature extraction83Interception or zero padding, splicing2Calculate statisticsLSTM


### 5.6.2. Model Performance

The model evaluation indicators are shown in Table8. Combining the data in Table 3, when the transaction features are not used for overdue prediction, the test set AUC of the model is 71%, the recall rate is 0.8%, and the accuracy is 49%. Adding the two output results of the LSTM model, the AUC of the model test set increased by 24%, the recall rate increased by 73%, and the accuracy rate increased by 43%. The significant increase in evaluation indicators proves the usefulness of the output features of the LSTM model. At the same time, the XGBoost-LSTM model has less improvement in AUC and accuracy compared with the XGBoost model building with the extracted transaction features. This shows that, under the premise of extracting useful features, the XGBoost model can also have good predictive performance. However, the extraction of useful features is based on deep business experience and a large amount of data mining. As shown in Figures 3(a) and 8(a), the XGBoost-LSTM model identified 2035 more bad samples than the XGBoost model (a total of 8,863 bad samples), and the number of false identifications of good samples decreased by 957. It means that bad customers are detected 23% more, and the false identification rate of samples predicted to be bad users decreased by 16% in the actual application of the model. The XGBoost-LSTM model thus obtains best prediction results on the data set used in this study. The results verify that the XGBoost-LSTM model can be realized without feature extraction and still have high classification accuracy.Table 8
Model evaluation indicators for XGBoost model and XGBoost-LSTM model.
AlgorithmTrain AUCTrain ACCTest AUCTest ACCTest recallTest precisionXGBoost0.8950.8730.8930.8700.5070.768XGBoost-LSTM0.9540.9370.9530.9360.7360.928


## 5.6.1. Data Processing

Table7 shows the data sources and data processing methods required by different algorithms. The XGBoost-LSTM model requires the least amount of work, which reduces the work of feature extraction from the transaction flow data.Table 7
Data processing methods for modeling with different algorithms.
XGBoostXGBoost_LSTMData processingNumberData processingNumberBasic information—19—19Credit informationMonthly data6Monthly data6Calculate statisticsCalculate statisticsBilling informationMonthly data106Monthly data106Calculate statisticsCalculate statisticsInstallment informationMonthly data113Monthly data113Calculate statisticsCalculate statisticsTransaction flow informationFeature extraction83Interception or zero padding, splicing2Calculate statisticsLSTM


## 5.6.2. Model Performance

The model evaluation indicators are shown in Table8. Combining the data in Table 3, when the transaction features are not used for overdue prediction, the test set AUC of the model is 71%, the recall rate is 0.8%, and the accuracy is 49%. Adding the two output results of the LSTM model, the AUC of the model test set increased by 24%, the recall rate increased by 73%, and the accuracy rate increased by 43%. The significant increase in evaluation indicators proves the usefulness of the output features of the LSTM model. At the same time, the XGBoost-LSTM model has less improvement in AUC and accuracy compared with the XGBoost model building with the extracted transaction features. This shows that, under the premise of extracting useful features, the XGBoost model can also have good predictive performance. However, the extraction of useful features is based on deep business experience and a large amount of data mining. As shown in Figures 3(a) and 8(a), the XGBoost-LSTM model identified 2035 more bad samples than the XGBoost model (a total of 8,863 bad samples), and the number of false identifications of good samples decreased by 957. It means that bad customers are detected 23% more, and the false identification rate of samples predicted to be bad users decreased by 16% in the actual application of the model. The XGBoost-LSTM model thus obtains best prediction results on the data set used in this study. The results verify that the XGBoost-LSTM model can be realized without feature extraction and still have high classification accuracy.Table 8
Model evaluation indicators for XGBoost model and XGBoost-LSTM model.
AlgorithmTrain AUCTrain ACCTest AUCTest ACCTest recallTest precisionXGBoost0.8950.8730.8930.8700.5070.768XGBoost-LSTM0.9540.9370.9530.9360.7360.928


## 6. Conclusions

In the method used in this study, features related to transaction flow had the highest importance weight, showing that the transaction flow data could effectively predict credit card default. Second, in the process of XGBoost modeling, the accuracy of default prediction mainly depended on feature extraction. It takes a lot of time to understand the specific meaning of each transaction type, but only when there is a deep understanding of the credit card business background can transaction types be correctly classified and useful features extracted. Third, when applying LSTM to process transaction flow data, it was only necessary to complement and splice the data, without any feature extraction work, which again confirms that the advantage of deep learning is that it does not require manual feature extraction. Finally, the XGBoost-LSTM fusion model combined basic, billing, and installment information, as well as PBOC branch and transaction flow, and it obtained extremely good test accuracy. This study shows that LSTM is an effective method for dealing with credit card transaction flow data.



---

*Source: 5080472-2021-12-16.xml*