+4 votes
in Programming Languages by (74.9k points)

The following code is giving error: TypeError: 'numpy.int64' object is not iterable.

for k, v in y_true_pred:

y_true.append[v[0]]

y_pred.append[v[1]]

y_pred_prob.append[v[2]]

In this code, y_true_pred is a dictionary.  How can I fix the error?

1 Answer

+1 vote
by (353k points)
selected by
 
Best answer

You are missing "items()" after "y_true_pred". That's why you are getting the error. Make the following change and it should work.

for k, v in y_true_pred.items():
    y_true.append[v[0]]
    y_pred.append[v[1]]
    y_pred_prob.append[v[2]]

Related questions


...