import pandas as pd
import numpy as np
#导入划分数据集函数
from sklearn.model_selection import train_test_split
#混淆矩阵可视化函数cm_plot
def cm_plot(y, yp):
from sklearn.metrics import confusion_matrix #
cm = confusion_matrix(y, yp)
import matplotlib.pyplot as plt
plt.matshow(cm, cmap=plt.cm.Greens)
plt.colorbar()
for x in range(len(cm)):
for y in range(len(cm)):
plt.annotate(cm[x,y], xy=(x, y), horizontalalignment='center', verticalalignment='center')
plt.ylabel('True label')
plt.xlabel('Predicted label')
return plt
#读取数据
datafile = r'G:/data/data/bankloan.xls'#文件路径
data = pd.read_excel(datafile)
x = data.iloc[:,:8]
y = data.iloc[:,8]
#划分数据集
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=100)
#导入模型和函数
from keras.models import Sequential
from keras.layers import Dense,Dropout
#导入指标
from keras.metrics import BinaryAccu
银行风控神经网络
于 2022-03-30 13:02:38 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)