I'm building a two class classification model using KNN
I tried to calculate auc_score with
from sklearn.metrics import auc
auc(y_test, y_pred)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-183-980dc3c4e3d7> in <module>
----> 1 auc(y_test, y_pred)
~/.local/lib/python3.6/site-packages/sklearn/metrics/ranking.py in auc(x, y, reorder)
117 else:
118 raise ValueError("x is neither increasing nor decreasing "
--> 119 ": {}.".format(x))
120
121 area = direction * np.trapz(y, x)
ValueError: x is neither increasing nor decreasing : [1 1 1 ... 1 1 1].
Then I used roc_auc_score
from sklearn.metrics import roc_auc_score
roc_auc_score(y_test, y_pred)
0.5118361429056588
Why is it auc
is not working where as roc_auc_score
is working. I though they both were same? What am I missing here?
Here y_test
is actual target values and y_pred
is my predicted values.