Skip to content

Enable to get ranked-list of predicted labels when performing a multi-class classification prediction #2233

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

Closed
CESARDELATORRE opened this issue Jan 24, 2019 · 2 comments

Comments

@CESARDELATORRE
Copy link
Contributor

CESARDELATORRE commented Jan 24, 2019

This is a needed scenario that can be pretty common from a business needs perspective.

When using ML.NET code implementing multi-class classification, we’re returning/predicting a single label…

Multi-class Classification

  • Label: Original Label of the example.
  • Score: Its an array whose length is equal to number of classes and contains probability for each class.
    - PredictedLabel: Predicted class. <-- (*) There's a single PredictedLabel

But in many business scenarios, a list of possible labels where something can be classified is also very useful.

• For instance, a real product might be related to multiple product-categories in an eCommerce, not just one category.
• Another example where this scenario is possible (and we actually have it working), is image classification in TensorFlow, you can get a list of the best labels with a score per each, from the TF model.

In fact, the class used to get a prediction is like:

public class MyPrediction
 {
     public float[] Score;

     public string PredictedLabelValue;
 }

So, we actually get an array of Scores, like here:

image

We need a way to map the array of float confidence/score levels back to each original class/label names, in addition to the “single best” PredictedLabelValue.

Additional info provided by Ivan Matantsev:

Technically it should be accessible via metadata in Schema, but I don’t see any way to access it in transformer.
Theoretically if you load model from file, you can call GetOutputSchema, but if you just do prediction, you don’t have dataview to get Schema you just have example/prediction classes.
So we either need a way to Expose output Schema in prediction function or to have Transformer which would spit out specific metadata for certain columns.

@TomFinley
Copy link
Contributor

So we either need a way to Expose output Schema in prediction function or to have Transformer which would spit out specific metadata for certain columns._

Incidentally having the output schema accessible is preferable. Having appropriate helpers for the "canonical" metadata (probably as extension methods on Schema.Column) would probably be the most useful thing here. (Maybe these already exist, but I wouldn't bet my life on it.)

@CESARDELATORRE
Copy link
Contributor Author

Closing this one (it is already possible) in favor of this issue: #2278

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

No branches or pull requests

2 participants