本文主要是介绍金融贷款逾期模型 -- 029,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
内容目录
一、导入相关库二、数据读取三、数据清洗——删除无关、重复数据四、数据清洗——类型转换1、数据集划分2、缺失值处理3、异常值处理4、离散特征编码5、日期特征处理6、特征组合五、数据集划分六、模型构建七、模型评估八、模型调优九、分类模型和集成模型评分和ROC曲线
一、导入相关库
# -*- coding:utf-8 -*-
# 一、导入相关库
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
import xgboost as xgb
import lightgbm as lgb
from sklearn.metrics import accuracy_score, precision_score, recall_score
from sklearn.metrics import roc_auc_score
import matplotlib.pyplot as pltimport warnings
import numpy as np
import matplotlib
import pandas as pd
warnings.filterwarnings("ignore")
matplotlib.rcParams['font.sans-serif']=['SimHei'] # 用黑体显示中文
matplotlib.rcParams['axes.unicode_minus']=False # 正常显示负号
np.set_printoptions(precision=5,suppress=True)pd.set_option('display.max_columns', 10000)
#显示所有行
pd.set_option('display.max_rows', 10000)
pd.set_option('max_colwidth',10000)
pd.set_option('display.width', 10000)#不换行
print(X.shape) #(4754, 84)
Unnamed: 0 custid trade_no bank_card_no low_volume_percent middle_volume_percent take_amount_in_later_12_month_highest trans_amount_increase_rate_lately trans_activity_month trans_activity_day transd_mcc trans_days_interval_filter trans_days_interval regional_mobility student_feature repayment_capability is_high_user number_of_trans_from_2011 first_transaction_time historical_trans_amount historical_trans_day rank_trad_1_month trans_amount_3_month avg_consume_less_12_valid_month abs top_trans_count_last_1_month avg_price_last_12_month avg_price_top_last_12_valid_month reg_preference_for_trad trans_top_time_last_1_month trans_top_time_last_6_month consume_top_time_last_1_month consume_top_time_last_6_month cross_consume_count_last_1_month trans_fail_top_count_enum_last_1_month trans_fail_top_count_enum_last_6_month trans_fail_top_count_enum_last_12_month consume_mini_time_last_1_month max_cumulative_consume_later_1_month max_consume_count_later_6_month railway_consume_count_last_12_month pawns_auctions_trusts_consume_last_1_month pawns_auctions_trusts_consume_last_6_month jewelry_consume_count_last_6_month status source first_transaction_day trans_day_last_12_month id_name apply_score apply_credibility query_org_count query_finance_count query_cash_count query_sum_count latest_query_time latest_one_month_apply latest_three_month_apply latest_six_month_apply loans_score loans_credibility_behavior loans_count loans_settle_count loans_overdue_count loans_org_count_behavior consfin_org_count_behavior loans_cash_count latest_one_month_loan latest_three_month_loan latest_six_month_loan history_suc_fee history_fail_fee latest_one_month_suc latest_one_month_fail loans_long_time loans_latest_time loans_credit_limit loans_credibility_limit loans_org_count_current loans_product_count loans_max_limit loans_avg_limit consfin_credit_limit consfin_credibility consfin_org_count_current consfin_product_count consfin_max_limit consfin_avg_limit latest_query_day loans_latest_day
0 5 2791858 20180507115231274000000023057383 卡号1 0.01 0.99 0 0.90 0.55 0.313 17.0 27.0 26.0 3.0 NaN 19890 0 30.0 20130817.0 149050 151.0 0.40 34030 7.0 3920 0.15 1020 0.55 一线城市 4.0 19.0 4.0 19.0 1.0 1.0 2.0 2.0 5.0 2170 6.0 0.0 1970 18040 0.0 1 xs 1738.0 85.0 蒋红 583.0 79.0 8.0 2.0 6.0 10.0 2018-04-25 2.0 5.0 8.0 552.0 73.0 37.0 34.0 2.0 10.0 1.0 9.0 1.0 1.0 13.0 37.0 7.0 1.0 0.0 341.0 2018-04-19 2200.0 72.0 9.0 10.0 2900.0 1688.0 1200.0 75.0 1.0 2.0 1200.0 1200.0 12.0 18.0
1 10 534047 20180507121002192000000023073000 卡号1 0.02 0.94 2000 1.28 1.00 0.458 19.0 30.0 14.0 4.0 1.0 16970 0 23.0 20160402.0 302910 224.0 0.35 10590 5.0 6950 0.05 1210 0.50 一线城市 13.0 30.0 13.0 30.0 0.0 0.0 3.0 3.0 330.0 2100 9.0 0.0 1820 15680 0.0 0 xs 779.0
这篇关于金融贷款逾期模型 -- 029的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!