Why is roc_curve return an additional value for the thresholds (2.0) for some classes?

Dr. Fabien Tarrade

I am using python 3.5.2 and sklearn 0.19.1

I have a muticlass problem (3 classes) and I am using RandomForestClassifier. For one of the cass I have 19 unique predict_proba values :

{0.0,
0.6666666666666666,
0.6736189855024448,
0.6773290780865037,
0.7150826826468751,
0.7175236925236925,
0.7775446850962057,
0.8245648135911781,
0.8631035080004867,
0.8720525244880196,
0.8739595855873906,
0.8787152225755167,
0.9289844333343654,
0.954439314892936,
0.9606503912532541,
0.9771342285323964,
0.9883370916703461,
0.9957401423931763,
1.0}

I am computing roc_curve and I am expecting the same number of point for the roc curve as I have unique value of probablitity. This is only true for 2 of the 3 classes!

When I looked at the thresholds returned that the roc_curve function:

fpr, tpr, proba = roc_curve(....):

I see the same exact value as the one in the list of probability + one new value 2.0 !

[2.,
1.,
0.99574014,
0.98833709,
0.97713423,
0.96065039,
0.95443931,
0.92898443,
0.87871522,
0.87395959,
0.87205252,
0.86310351,
0.82456481,
0.77754469,
0.71752369,
0.71508268,
0.67732908,
0.67361899,
0.66666667,
0. ]

Why is a new thresholds 2.0 is returned ? I didn't see anything related to that in the documentation.

Any idea ? I am missing something

zdgriffith

roc_curve is written so that ROC point corresponding to the highest threshold (fpr[0], tpr[0]) is always (0, 0). If this is not the case, a new threshold is created with an arbitrary value of max(y_score)+1. The relevant code from the source:

thresholds : array, shape = [n_thresholds]
    Decreasing thresholds on the decision function used to compute
    fpr and tpr. `thresholds[0]` represents no instances being predicted
    and is arbitrarily set to `max(y_score) + 1`.

and

if tps.size == 0 or fps[0] != 0:
    # Add an extra threshold position if necessary
    tps = np.r_[0, tps]
    fps = np.r_[0, fps]
    thresholds = np.r_[thresholds[0] + 1, thresholds]

So it seems in the case you showed you have data given a score of 1.0 that is incorrectly classified.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Why does this function return 0

分類Dev

How to set to some values (thresholds) the elements of a numpy array for values greater than thresholds specified in another numpy array?

分類Dev

Why would you return(0*ap++)?

分類Dev

Return value gets assigned but always returns as 0

分類Dev

waitpid() return value 0 along with errno EINTR

分類Dev

Why json.dumps() in python 3 return a different value of python 2?

分類Dev

Why does Number(null) return 0, and parseFloat(null) return NaN?

分類Dev

Why does "0 && true" return 0 in javascript instead of a boolean?

分類Dev

Why does PDFBox return image dimension of size 0 x 0

分類Dev

Why does __func__ return <unknown> in some functions in C?

分類Dev

Why does my method return the wrong value?

分類Dev

Why does a void function return a value?

分類Dev

Why is there a colon in some Programs between 2 statements

分類Dev

Laravel 5.6, where to keep additional classes (additional functional)?

分類Dev

Why does this expression return 2 in javaScript?

分類Dev

Why does the value of i become negative after some iterations

分類Dev

Getting an additional "0" after for loop

分類Dev

About the Customer Annotation Processor, Why the size of set return by getElementsAnnotatedWith() is 0

分類Dev

Why count doesn't return 0 on empty table

分類Dev

Why is "IF @@ROWCOUNT = 0 RETURN" used in Instead of Insert trigger?

分類Dev

if 2 cells match, return the value on another spreadsheet

分類Dev

how to return value of 0 when no radio button is selected in php

分類Dev

Delimiting some sibling nodes without additional element

分類Dev

Why does 1 / 2 == 0 using double?

分類Dev

How to make violin plots with additional single value points in ggplot2

分類Dev

Why virtual inherit 2 classes raises object size?

分類Dev

Why isn't setInterval() returning my function's return value?

分類Dev

Why do scrollHeight, clientHeight & offsetHeight all return the same value?

分類Dev

Why does search for matching value in multi dimensional array not return a result?

Related 関連記事

  1. 1

    Why does this function return 0

  2. 2

    How to set to some values (thresholds) the elements of a numpy array for values greater than thresholds specified in another numpy array?

  3. 3

    Why would you return(0*ap++)?

  4. 4

    Return value gets assigned but always returns as 0

  5. 5

    waitpid() return value 0 along with errno EINTR

  6. 6

    Why json.dumps() in python 3 return a different value of python 2?

  7. 7

    Why does Number(null) return 0, and parseFloat(null) return NaN?

  8. 8

    Why does "0 && true" return 0 in javascript instead of a boolean?

  9. 9

    Why does PDFBox return image dimension of size 0 x 0

  10. 10

    Why does __func__ return <unknown> in some functions in C?

  11. 11

    Why does my method return the wrong value?

  12. 12

    Why does a void function return a value?

  13. 13

    Why is there a colon in some Programs between 2 statements

  14. 14

    Laravel 5.6, where to keep additional classes (additional functional)?

  15. 15

    Why does this expression return 2 in javaScript?

  16. 16

    Why does the value of i become negative after some iterations

  17. 17

    Getting an additional "0" after for loop

  18. 18

    About the Customer Annotation Processor, Why the size of set return by getElementsAnnotatedWith() is 0

  19. 19

    Why count doesn't return 0 on empty table

  20. 20

    Why is "IF @@ROWCOUNT = 0 RETURN" used in Instead of Insert trigger?

  21. 21

    if 2 cells match, return the value on another spreadsheet

  22. 22

    how to return value of 0 when no radio button is selected in php

  23. 23

    Delimiting some sibling nodes without additional element

  24. 24

    Why does 1 / 2 == 0 using double?

  25. 25

    How to make violin plots with additional single value points in ggplot2

  26. 26

    Why virtual inherit 2 classes raises object size?

  27. 27

    Why isn't setInterval() returning my function's return value?

  28. 28

    Why do scrollHeight, clientHeight & offsetHeight all return the same value?

  29. 29

    Why does search for matching value in multi dimensional array not return a result?

ホットタグ

アーカイブ