ROC作圖問題
在D48的作業中
from sklearn.tree import DecisionTreeClassifier
modell = DecisionTreeClassifier(criterion='gini',max_depth=5)
modell.fit(X_train, y_train)
predicted= modell.predict(X_test)
print('accuracy_score: ',accuracy_score(y_test, predicted))
print('AUC: ',roc_auc_score(y_test, predicted))
# Compute ROC curve and ROC area for each class
fpr,tpr,threshold = roc_curve(y_test.values, predicted) ###計算真正率和假正率
roc_auc = auc(fpr,tpr) ###计算auc的值
plt.figure()
lw = 2
plt.figure(figsize=(10,10))
plt.plot(fpr, tpr, color='darkorange',
lw=lw, label='ROC curve (area = %0.3f)' % roc_auc) ###假正率為橫坐標,真正率為縱坐標做曲線
plt.plot([0, 1], [0, 1], color='navy', lw=lw, linestyle='--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic example')
plt.legend(loc="lower right")
plt.show()
為何我的fpr,tpr,threshold會只有這樣
(array([0. , 0.17834395, 1. ]),
array([0. , 0.76300578, 1. ]),
array([2, 1, 0], dtype=int64))
但隨金森林和Lasso 就不會有這個問題
請教這是為什麼?
回答列表
-
2020/01/07 上午 01:10Jeffrey贊同數:0不贊同數:0留言數:0
請問一下,是否都用同一個gini 的值?