+4 votes
in Programming Languages by (14.6k 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

0 votes
by (25.6k points)

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]]

...