Supervised learning with numeric data applying KNN classifier giving an error while I am calling metrics.confusion_matrix(y_test, y_pred). The conducting error message is: Found input variables with inconsistent numbers of samples: [40000, 2000]. Thanks in advance for showing lights.
Asked
Active
Viewed 301 times
0
-
You should check [this post](https://stackoverflow.com/questions/30813044/sklearn-found-arrays-with-inconsistent-numbers-of-samples-when-calling-linearre) – Willy satrio nugroho Aug 18 '20 at 11:44
1 Answers
0
The confusion matrix compares the values in both arrays and basically tells how many samples were labelled same and how many differed in both of them. For this, the number of elements in both arrays should be the same. This is what the error says.
So make sure that both of them have same number of elements.
Perhaps if you include previous code that deals with y_test and y_pred, it would be easier to see why the sizes are different.

mk03
- 98
- 7