Closed
Description
@Ivanidzo4ka
I am trying to do multilabel classification on IRISClassification. I am referring to this link https://github.com/dotnet/machinelearning/blob/master/test/Microsoft.ML.Tests/Scenarios/Api/Estimators/PredictAndMetadata.cs#L41
While I am running the code I am getting below exception 'Invalid call to 'GetGetter'' while accessing slotnames.
Activity
Ivanidzo4ka commentedon Mar 1, 2019
Thank you for reporting this.
I'm working on this issue right now.
Problem is what we have internal convention to treat all SlotNames as text (they called Names for a reason) but deep inside if origin of key type is something other than string we don't do proper casting.
@TomFinley Am I right what at this point only way to get original label values is to access KeyValue annotations on PredictedLabel?
Ivanidzo4ka commentedon Mar 1, 2019
To unblock your self you can change definition of slotNames from
VBuffer<ReadOnlyMemory<char>>
toVBuffer<float>
and I would assume it would give you original keys. But I will change that functionality in next release.prathyusha12345 commentedon Mar 1, 2019
@Ivanidzo4ka after using
VBuffer Getting compile time error as below.
Ivanidzo4ka commentedon Mar 1, 2019
Oh, right, this is one of our assumptions what slotnames should be strings.
this one should do the trick:
predEngine.OutputSchema[""].Annotations.GetValue(AnnotationUtils.Kinds.SlotNames, ref slotNames);
prathyusha12345 commentedon Mar 1, 2019
@Ivanidzo4ka it showing AnnotationUtils in accessible due to its protection level
Ivanidzo4ka commentedon Mar 1, 2019
We did a good job on hiding our internals.
this one?
prathyusha12345 commentedon Mar 1, 2019
As discussed getting new exception.

IRISPrediction class as below.
public class IrisPrediction
{
[ColumnName("label")]
public float Label;
And I am doing MapToKeyValue transformation in training pipeLine as below
var trainer = mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(labelColumnName: DefaultColumnNames.Label, featureColumnName: DefaultColumnNames.Features);
var trainingPipeline = dataProcessPipeline.Append(trainer)
.Append(mlContext.Transforms.Conversion.MapKeyToValue("label", "PredictedLabel"));
Ivanidzo4ka commentedon Mar 1, 2019
prathyusha12345 commentedon Mar 1, 2019
@Ivanidzo4ka This code is working fine. But how do we map each score to label? For example GitHub labeler sample has 'area' as label. so we get scoreValues array more than 3. How do we map all of them? Do we need to write program manually like I have written in GITHUBLabeler sample here or do we have any predefined code written in ML.Net.
Because obviously the purpose of this classification is to find the scores and map them to labels accordingly.
Ivanidzo4ka commentedon Mar 1, 2019
Console.WriteLine($"Predicted label: {scoreValues[i]}: {prediction.Score[i]}");
I probably should call
scoreValues
as originalLabels, or something like this.you have two arrays, one with score values, one with original labels, they have same amount of elements and can be mapped to each over by index
Ivanidzo4ka commentedon Mar 1, 2019
Yes, if you can access slotnames. They broken right now if you have non string label.
prathyusha12345 commentedon Mar 1, 2019
@Ivanidzo4ka I got your point that once we get scores and labels we need to Zip them to map each label to score. But From machine learning beginner/user perspective, its difficult to understand terms like slotnames, keys and zip them label and score manually. Its confusing for learners/users.
The better way is get a dictionary of label and scores and user sorts them if needed.
4 remaining items