Reputation: 1
What could be the reason for the difference in accuracies?
y_pred = model.predict(x_test)
ans = []
for i in y_pred:
ans.append(0 if i[0]<0.5 else 1)
ans = np.array(ans)
print("Accuracy:",metrics.roc_auc_score(y_test, ans))
Accuracy: 0.7781798160210841
While
print("Accuracy:",metrics.roc_auc_score(y_test, y_pred))
Accuracy: 0.8949947592358702
Upvotes: 0
Views: 51
Reputation: 66775
ROC score is not accuracy. It is an area under the curve, that emerges when you construct your predcition by varying a threshold. In your code you removed the notion of "uncertainty", by outputing only 0s and 1s, and thus the ROC curve became flat - there is no threshold that affects your predictions.
Upvotes: 1