Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Understanding Multiclass classification problem #36

Open
naeemulhassan opened this issue Jul 23, 2015 · 1 comment
Open

Understanding Multiclass classification problem #36

naeemulhassan opened this issue Jul 23, 2015 · 1 comment

Comments

@naeemulhassan
Copy link

Here is the thing.

I have 3 class labels in my data. The predict function returns an array of shape (N, 3) where N is the size of the train set. Here is an example,

>>> prediction = model.predict(tokenizer.transform(test_text))
>>> prediction
    array([[ 0.99999995,  0.99998585,  0.99999268],
       [ 0.99999993,  0.99998351,  0.99999069],
       [ 0.9999999 ,  0.99997884,  0.99998756],
       [ 0.99999992,  0.99998125,  0.99998932],
       [ 0.99999988,  0.99997679,  0.99998638],
       [ 0.99999996,  0.99998655,  0.99999323],
       [ 0.99999942,  0.99992762,  0.99995597],
       [ 0.99999987,  0.99997481,  0.99998479],
       [ 0.99999995,  0.99998605,  0.99999269],
       [ 0.99999996,  0.99998733,  0.99999372]])

How to interpret the prediction. I have 3 class labels but the array is giving close to 1 in all the classes. The value don't even sum up to 1. I must be doing something wrong. Any suggestion is highly appreciated.

Thanks!

@youralien
Copy link

@naeemulhassan Mind posting your code so I can try to reproduce this error?

I turned the gender two class problem into a multiclass problem, by replacing sigmoid with softmax, setting the size of the final dense layer equal to 2, and bce (binary cross entropy) with cce (categorical cross entropy).

It's important that the multi-class problem is handled through a softmax, because the softmax outputs a normalized distribution of probability values for the classes. I hope this was the simple change you needed! Let me know and we can try to hash it out together.

Check out the gender_multiclass.py file in my PR: #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants