如何解决roc_auc与混乱矩阵
我正在使用Roc_auc分数测试不同的树与LightGBM。结果却很奇怪。
代码在这里:
### Locate X and y in the dataset
X = final_df.iloc[:,2:].values
y = final_df.loc[:,'TARGET'].values
### Split X and y
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.3,random_state=0)
### Call algos
tree = DecisionTreeClassifier(criterion = 'entropy',random_state = 0 )
LGBM = LGBMClassifier()
### Train the model
tree.fit(X_train,y_train)
LGBM.fit(X_train,y_train)
使用上面的代码,我得到了LGBM和树这样的混淆矩阵。到目前为止,一切看起来还不错。
for model in [LGBM,tree]:
model.fit(X_train,y_train)
matrix = plot_confusion_matrix(model,y_test,cmap=plt.cm.Blues,normalize='true')
plt.title('Confusion matrix for our classifier')
plt.show(matrix)
plt.show()
然后我想看看这两个的Roc_auc得分,如下:
for model in [LGBM,tree]:
y_predict = model.predict_proba(X_test) ### predict the probability
y_prob = y_predict[:,1]
auc = roc_auc_score(y_test,y_prob)
print('{}: AUC score {}'.format(models_dict[model],auc))
显示以下内容:
LGBM: AUC score 0.982679224930189
Decision Tree: AUC score 0.8728317459710319
我非常困惑为什么AUC分数如此之高……是因为我的模型还是我的代码?请让我知道您的想法,谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。