Search code examples
scikit-learnconfusion-matrix

confusion_matrix() takes 2 positional arguments but 3 were given


enter image description here

As can be seen from above picture,this problem makes me very confused.


Solution

  • labels is not a positional argument but a keyword argument.

    Therefore, you should call the function as follow:

    from sklearn.metrics import confusion_matrix
    confusion_matrix(y_true, y_pred, labels=classes)