Python Forum
Array NaN values? ValueError: continuous format is not supported
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array NaN values? ValueError: continuous format is not supported
#1
Hi,

I do have this ValueError: continuous format is not supported problem again.

auc_roc = roc_auc_score(fpr, tpr)

#"roc_auc" is a classification or ranking metric, not a regression metric. So it doesn't accept continuous

#However, I see no NaN values according to my test:

for num in fpr:
if num != num:
print ('This array has a NaN element') #all good, no nan in fpr
break
for num in tpr:
if num != num:
print ('This array has a NaN element') #all good, no nan in tpr
break
fpr and tpr have a few hundred rows so I dont think I can print them here.
Reply
#2
please, repost/edit your post in order to show correct indentation of your code. Indentation matter in python.
Also, when post traceback, post the full traceback, in error tags, not just the last line.
finally, num != num will NEVER evaluate True, so you if statements is useless
Reply
#3
(Jan-04-2018, 08:44 AM)metalray Wrote: pr and tpr have a few hundred rows so I dont think I can print them here.

You don't need to post them all, just a few so the snippet can be tested.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#4
OK, thanks for the hints. I have the feeling the continous format error is not because of NaN values. The array does look a bit odd with all the spaces in it.

def new_model():

    print(fpr) 
    print(tpr)
            
    print(np.argwhere(np.isnan(fpr))) 
    print(np.argwhere(np.isnan(tpr)))

    auc_roc = roc_auc_score(fpr, tpr)
            
    return
new_model()
fpr: [ 0. 0.98952194 1. ]
tpr: [ 0. 0.98547329 1. ]


Error:
ValueError Traceback (most recent call last) <ipython-input-2-82b3904c67a1> in <module>() 85 #print('auc on validation set {}'.format(auc_roc)) 86 return #roc_auc ---> 87 blight_model() 88 89 #The target variable is compliance = <ipython-input-2-82b3904c67a1> in blight_model() 80 81 #"roc_auc" is a classification or ranking metric, not a regression metric. So it doesn't accept continuous ---> 82 auc_roc = roc_auc_score(fpr, tpr) 83 84 /opt/conda/lib/python3.5/site-packages/sklearn/metrics/ranking.py in roc_auc_score(y_true, y_score, average, sample_weight) 258 return _average_binary_score( 259 _binary_roc_auc_score, y_true, y_score, average, --> 260 sample_weight=sample_weight) 261 262 /opt/conda/lib/python3.5/site-packages/sklearn/metrics/base.py in _average_binary_score(binary_metric, y_true, y_score, average, sample_weight) 79 y_type = type_of_target(y_true) 80 if y_type not in ("binary", "multilabel-indicator"): ---> 81 raise ValueError("{0} format is not supported".format(y_type)) 82 83 if y_type == "binary": ValueError: continuous format is not supported
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to multiply tuple values in array? EngiPorem 3 2,951 Aug-27-2021, 03:26 AM
Last Post: naughtyCat
  ValueError: setting an array element with a sequence ying9309 2 7,599 Jul-15-2018, 07:04 AM
Last Post: ying9309
  reshaping numpy array ValueError: total size of new array must be unchanged metalray 0 5,867 Jul-15-2017, 05:41 PM
Last Post: metalray
  ValueError: shape mismatch: value array of shape... ulrich48155 2 23,570 Jul-10-2017, 02:17 PM
Last Post: ulrich48155

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020