3

I want to determine which score is related to which label but i get a runtime error.

I have a method which is responsible for that...

public static List<string> GetSlotNames(string name)
{
    var schema = predEngine.OutputSchema;
    var column = schema.GetColumnOrNull(name);

    var slotNames = new VBuffer<ReadOnlyMemory<char>>();
    column.Value.GetSlotNames(ref slotNames); //here is the error
    var names = new string[slotNames.Length];
    var num = 0;
    foreach (var denseValue in slotNames.DenseValues())
    {
        names[num++] = denseValue.ToString();
    }

    return names.ToList();
}

but i get a runtime exception:

System.InvalidOperationException: 'Invalid call to 'GetValue''

EDIT: I trained the model with model builder so code is the standard code which ml.net uses, in my case three categories classification.The parameter of GetSlotNames is "Score"

public class ModelOutput
{        
    [ColumnName("PredictedLabel")]
    public Single Prediction { get; set; }
    [ColumnName("Score")]
    public float[] Score { get; set; }
}
ggeorge
  • 1,496
  • 2
  • 13
  • 19
  • It doesn't look like there's anything out of the ordinary with the code provided. My guess is, the output schema of the prediction engine might be different from what you expect. It would help if you could post the code that you used to train the model, instantiate `predEngine` and which `name` you are calling this method with. – Zruty Nov 11 '19 at 03:56

1 Answers1

0

I know this is an old question and you've either given up or solved it another way but I hope this helps someone.

I also struggled with this. I took the code from the "github tag" example project. I discovered that it only worked with "text" data types. In my need, if I made my inputs (which are naturally Single) into strings the above "GetSlotNames" f(x) worked. If I switched it back, it broke.

I can only assume this is an issue with the underlying framework not having the correct GetValue because if you inspect the data the key mappings are there.