python金融风控评分卡模型和数据分析

在这里插入图片描述
在这里插入图片描述


import matplotlib.pyplot as plt

from sklearn.ensemble import RandomForestClassifier

from sklearn.model_selection import train_test_split

df=pd.read_excel(readFileName)

list_columns=list(df.columns[:-1])

x_train,x_test,y_train,y_test=train_test_split(X,y,random_state=0)

#n_estimators表示树的个数,测试中100颗树足够

forest=RandomForestClassifier(n_estimators=trees,random_state=0)

forest.fit(x_train,y_train)

print("random forest with %d trees:"%trees)

print("accuracy on the training subset:{:.3f}".format(forest.score(x_train,y_train)))

print("accuracy on the test subset:{:.3f}".format(forest.score(x_test,y_test)))

print('Feature importances:{}'.format(forest.feature_importances_))

plt.barh(range(n_features),forest.feature_importances_,align='center')

plt.yticks(np.arange(n_features),names)

plt.title("random forest with %d trees:"%trees)

plt.xlabel('Feature Importance')


决策树可视化
在这里插入图片描述

神经网络可视化
在这里插入图片描述

版权声明:文章来自公众号(python风控模型),未经许可,不得抄袭。遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

  • 5
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值