Python Forum

Full Version: Array NaN values? ValueError: continuous format is not supported
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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
(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.
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