Coder Social home page Coder Social logo

Comments (5)

magesh-technovator avatar magesh-technovator commented on July 22, 2024

Can you verify that all your test labels and predictions labels are binary?
MultiLabelIssue
It should like the above one

And also please add a screenshot/traceback of the exception

from blog_references.

rajae-Bens avatar rajae-Bens commented on July 22, 2024

Hi,

here is my labels format

Screen Shot 2020-10-12 at 9 25 52 AM

and the predictions
Screen Shot 2020-10-12 at 9 30 07 AM

and here is the error I got

Screen Shot 2020-10-12 at 9 30 57 AM

Thanks for ur help

from blog_references.

magesh-technovator avatar magesh-technovator commented on July 22, 2024

Reference from sklearn:
ValueError("Classification metrics can't handle a mix of {0} "
"and {1} targets".format(type_true, type_pred))

I think your prediction results are in multiclass-multioutput type, you can verify it here(https://github.com/scikit-learn/scikit-learn/blob/e6555decf8a72958d26d499deb17aabca41a562a/sklearn/utils/multiclass.py#L175)

And one more thing, Your model seems to output "0" for all classes those 5 samples, Can you please verify the predictions once?

And also check the step where you've transformed your output labels to fit for multi-label problem, something like this:

from sklearn.preprocessing import MultiLabelBinarizer
mlb = MultiLabelBinarizer()
test_labels = mlb.transform(test_categories)

from blog_references.

rajae-Bens avatar rajae-Bens commented on July 22, 2024

Hi,

Thank s for ur answer. Actually, I solved the problem by modifying the format of my data, and then I used MultiLabelBinarizer to transform them into a convenient format. Now all the metrics are calculated correctly.
However, I have another question plz, I've read that when handling a multi-label classification problem, f1-score is more significant as an evaluation metric do u agree? also, I am getting a very good f1 micro score but the macro score is not that good with a difference of 3x% do u have an explanation for that?

thank s for ur help

from blog_references.

magesh-technovator avatar magesh-technovator commented on July 22, 2024

Thanks for the response.

Regarding micro vs macro, it actually depends on your business needs,

Micro averaging takes into account the proportion for each class, but macro-averaging averages f1-score(or any metric) for all classes treating them equally.

If you have an imbalanced dataset(this is typical in real-world scenarios), micro-average is preferable.

And one more suggestion, if you have an imbalanced dataset, based on your business problem figure out the cost of mis-prediction and do some manual error analysis to get insights, and choose the model that gives better performance for your business need.

Example: Class A being mis-predicted as Class B will have a major impact, but if Class C gets mis-predicted as Class B it can be tolerated.

from blog_references.

Related Issues (2)

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.