Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I seem to be getting an error when calling confusion_matrix, please see below. How can I get this to work?
confusion_matrix
from sklearn.metrics import confusion_matrix confusion_matrix = confusion_matrix(normalisedArr_y5,predicted5)
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)
Add a comment
Both normalisedArr_y5 and predicted5 should be np.arrays or lists. Apparently one or both are not. You could try:
normalisedArr_y5
predicted5
confusion_matrix = confusion_matrix(normalisedArr_y5.tolist(),predicted5.tolist())
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
df
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
confusion_matrix- use a different variable name.