Reputation: 61
I seem to be getting an error when calling confusion_matrix
, please see below. How can I get this to work?
from sklearn.metrics import confusion_matrix
confusion_matrix = confusion_matrix(normalisedArr_y5,predicted5)
Upvotes: 5
Views: 12622
Reputation: 123
In my case, I was defining
normalisedArr_x5 = df.iloc[:,:-1]
and
normalisedArr_y5 = data.iloc[:,-1:]
and this Error was coming.
So just check if both the dataframe variables are the same (here df
) and perform the steps again @Garch2017
Upvotes: 0
Reputation: 3634
1 Be sure that both values are np arrays or lists as specified by @Roelant
2 do not assign to your variable's name the same name as the function name
from sklearn.metrics import confusion_matrix
cfm = confusion_matrix(normalisedArr_y5,predicted5)
print(cfm)
Upvotes: 2
Reputation: 5119
Both normalisedArr_y5
and predicted5
should be np.arrays or lists. Apparently one or both are not. You could try:
confusion_matrix = confusion_matrix(normalisedArr_y5.tolist(),predicted5.tolist())
Upvotes: 1