问题描述
我正在使用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 (将#修改为@)