2

I'm trying to run ROC auc, the code is:

actuals = gs.predict(feature_set) 
probas = gs.predict_proba(feature_set)
plt.plot(roc_curve(data[['Won_YES']], probas[:,1])[0],
                       roc_curve(data[['Won_YES']], probas[:,1])[1])

Won_YES is the Y variable and has both '1' and '0' values. It was sorted by value, so I used data['Won_YES'].sample(frac=0.1, replace=True) to apply a random order. So not sure what else could be missing.

This is the error I get: ValueError: Only one class present in y_true. ROC AUC score is not defined in that case.

Eksapsy
  • 1,541
  • 3
  • 18
  • 26
mterrestre
  • 23
  • 3
  • You claim that `Won_YES` contains both 1 and 0 values. `roc_curve` claims the opposite. Can you please `print(data[['Won_YES']])` or something similar to ensure you are correct? – Calimo Jan 24 '17 at 09:43
  • I checked Won_YES and can see both values, only thing is that observations are sorted in descending order, so in order words the 1s come first and then the 0s, what do u mean that roc_curve claims the opposite? – mterrestre Jan 25 '17 at 04:30
  • The error message clearly suggests otherwise, which is why I am asking for more output. The sorting is irrelevant here. – Calimo Jan 25 '17 at 06:06
  • (I mean, as long as it is consistent with your predictions) – Calimo Jan 25 '17 at 06:10
  • May have a similar problem to this: https://stackoverflow.com/questions/39018097/sklearn-auc-valueerror-only-one-class-present-in-y-true?rq=1 – StatsSorceress Nov 19 '18 at 21:27

0 Answers0