Description
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:
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.