Coder Social home page Coder Social logo

Comments (2)

kashevg avatar kashevg commented on May 18, 2024 2

Hi, @ageron
Ok, I get it.
As for me, it's so unnatural to have TP in the right lower corner. I know, it's a common approach for confusion matrices to sort classes in ascending order, but for binary classification, IMHO, it's better to have "positive" at the beginning, the same order as in wiki
Thank you.

from handson-ml2.

ageron avatar ageron commented on May 18, 2024

Hi @kashevg,

Thanks for your feedback. I suppose you are referring to figure 3-2?

mlst_0302

I'm not sure what you mean by "TP stays for False and TN stays for True class"? In the example, we are building a "5-detector", so "positive" means it's a 5, and "negative" means it's not a 5. So a TP is an image that is correctly labeled as positive. The figure does show 5s correctly labeled as 5s in the lower right cell, and that's the cell labeled as TP, so frankly I don't see the problem.

Regarding the confusion matrix's orientation, I'm not sure there is any official standard for the order of the columns and rows. I just did a quick informal search on Google Image for "confusion matrix" and among the first 11 confusion matrices for binary classifiers, 6 have the TP in the top left, and 5 in the lower right. That's almost 50%.

Moreover, Scikit-Learn itself puts the TP in the lower right, as the following code demonstrates:

>>> from sklearn.metrics import confusion_matrix
>>> #               1 TN  2 FP   3 FN      4 TP
>>> confusion_matrix([0,  0, 0,  1, 1, 1,  1, 1, 1, 1], # y_true
...                  [0,  1, 1,  0, 0, 0,  1, 1, 1, 1]) # y_pred
...
array([[1, 2],
       [3, 4]])

I find this order quite natural, as it just follows the order of the classes (0=negative, 1=positive). This allows it to be consistent even when there are more classes.

I hope this helps!

from handson-ml2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.