docs icon indicating copy to clipboard operation
docs copied to clipboard

Multi Label Classifier sample

Open ronbutan opened this issue 8 years ago • 20 comments

I look forward to a sample illustrating Multiclass Classification model. Common example will be News categorization.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ronbutan avatar May 15 '18 08:05 ronbutan

@asthana86 @aditidugar please take a look at this request for a new tutorial for ML.NET.

mairaw avatar May 15 '18 19:05 mairaw

Thanks for the feedback, @ronbutan! We're still working on building out all of our tutorials and samples, but a multi-classification sample will be added soon.

aditidugar-zz avatar May 15 '18 20:05 aditidugar-zz

The Iris example on the getting started page is a multiclass classifier: https://www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started

brendankowitz avatar May 16 '18 05:05 brendankowitz

Maybe we should add that link to this page then: https://docs.microsoft.com/en-us/dotnet/machine-learning/tutorials/?

mairaw avatar May 16 '18 06:05 mairaw

Yes, @brendankowitz is right, that's a multi-classification sample. @mairaw, we can certainly link from there temporarily, but it's not really a step-by-step tutorial like our other walkthroughs. We're working on creating a more end-to-end multi classification sample based on some of the demos we showed, and will have that ready soon.

aditidugar-zz avatar May 16 '18 16:05 aditidugar-zz

Appreciate the speedy response. I was wondering how to construct the class (i.e. IrisData) with multi labels (e.g. public string Label vs public string[] Labels). A simple code sample will definitely help.

ronbutan avatar May 17 '18 07:05 ronbutan

Hey @ronbutan! Thanks for the clarification here, I think we may have misunderstood your earlier question. Here is some guidance that may help:

  1. Multi-label classification: If you're looking to classify more than one label (predicting iris type in addition to petal size for example), then we unfortunately do not support this at the moment. The guidance here would be to train individual models for each of these, and then combine the predictions together. If you're interested in this support please open an issue on our GitHub repo.

  2. Multi-class classification. If you are looking for an array output since there are multiple values for each label, the "Score" attribute can provide the array of scores (one per class). You can check out a sample for that here. We also have an open issue about this because you currently cannot get the string labels for the classes other than the top class.

Hope this helps!

aditidugar-zz avatar May 18 '18 16:05 aditidugar-zz

Hi

The sample with flowers looks and works awesome. I am impressed. Could you please avice me what kind of classifier should I use if one (or more) of my input features contains descreet values like color of the flower?

Thanks Marek

Finansnet avatar May 25 '18 05:05 Finansnet

Hi @Finansnet! If I understand your question correctly, you're looking to handle input features for the color of flower such as "yellow", "pink", "blue", etc.

You can use the CategoricalOneHotVectorizer() function to transform these into numeric values so you can then process them in your learning algorithm. Please take a look at the Taxi Fare example to see how this can be implemented.

aditidugar-zz avatar May 25 '18 16:05 aditidugar-zz

Hi @aditidugar

That was exactly I was looking for. I have checked in on my training data and the results are very promising. Thank you.

Marek

Finansnet avatar May 27 '18 07:05 Finansnet

@aditidugar Any update on Multi-label classification support please?

stephenstroud avatar Oct 02 '18 14:10 stephenstroud

@stephenstroud - on the way soon! In the meantime, check out the sample here: https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/end-to-end-apps/MulticlassClassification-GitHubLabeler

JRAlexander avatar Nov 19 '18 18:11 JRAlexander

@stephenstroud - on the way soon! In the meantime, check out the sample here: https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/end-to-end-apps/MulticlassClassification-GitHubLabeler

Hi Alexander, sorry to bother but I've been looking for multi-label support/doc and can't find it anywhere. It is currently supported by ml.net?

slarrieu avatar Jun 05 '19 21:06 slarrieu

Any update on this?

Lukaa0 avatar Jun 08 '19 19:06 Lukaa0

@JRAlexander what's the update on multi-label classification?

It's been over a year now since the 'on the way soon' comment. Only examples are multi-class algorithms which produce only a single label.

We much need a solution for this – including scoring that accounts for the multi-label aspect of things (ie: whether the algorithm correctly labelled with the right number of tags)

marchy avatar Oct 16 '19 22:10 marchy

Hi @marchy, ML.NET currently does not have native support for multi-label classification. You could raise an issue over on the product GitHub repo if you like - it's also open source: https://github.com/dotnet/machinelearning.

Your other option would be to use a pre-trained TensorFlow or ONNX model that already provided this functionality. You can see an example of how to load a pre-trained model here: https://docs.microsoft.com/en-us/dotnet/machine-learning/tutorials/text-classification-tf

natke avatar Oct 16 '19 23:10 natke

@JRAlexander @natke Since the last comment on this question was over a year ago, is there an update on whether ML.NET supports multi-label classification?

I'm currently pulling in my pre-trained TensorFlow model, but it would be nice to have everything under one roof.

hjoshuaj avatar Dec 11 '20 22:12 hjoshuaj

Pinging @briacht to see if she can provide an update

mairaw avatar Dec 12 '20 20:12 mairaw

Pinging @briacht to see if she can provide an update

Hey is there way I can achieve hierarchical classification in ml.net?

TusharMalap avatar Mar 04 '22 14:03 TusharMalap

Does ML.Net support multi-label classification?

lockhartsoftware avatar Mar 12 '22 15:03 lockhartsoftware