7

I'm trying out the ML.net framework with some random test data. My data exists of a DepartmentId (1-25) and a Body (string). I want my machine to predict the department that the body should be allocated (for example in a ticket system like Zendesk).

Using the following code, I'm receving an error:

ArgumentOutOfRangeException: Score column is missing

I'm not sure why it says that the Score column is missing, as it's present in my prediction class.

Here's my setup for training the model, as well as my classes.

Main

var pipeline = new LearningPipeline();
pipeline.Add(new TextLoader(_dataPath).CreateFrom<DepartmentData>(userHeader: true, seperator: ','));
pipeline.Add(new TextFeaturizer("Features", "Body"));
pipeline.Add(new Dictionarizer("Label"));
pipeline.Add(new StochasticDualCoordinateAscentClassifier());
pipeline.Add(new PredictedLabelColumnOriginalValueConverter() { PredictedLabelColumn = "PredictedLabel" });

var model = pipeline.Train<DepartmentData, DepartmentPrediction>();

DepartmentData and DepartmentPrediction

public class DepartmentData
{
    [Column(ordinal: "0", name: "Label")]
    public float Department;
    [Column(ordinal: "1")]
    public string Body;
}

public class DepartmentPrediction
{
    [ColumnName("PredictedLabel")]
    public float Department;

    [ColumnName("Score")]
    public float[] Score;
}

Example data

Department, Body
1, Hello. 4 weeks ago I requested a replacement keycap for my keyboard. I still ahvent received the keycap. Perhaps you can confirm that it has been shipped?
13, I seem to have some problems when paying for you new mouse XZ-250 I'm being told that my card is not valid?
1, I just received the package I bought from you but I'm most definetly not satisfied with the shipment. The box was bended and broken when it received as well as the GPU inside. I demand that you ship a new one to me without charge. I've attached a few images of the box and the GPU here.
/* etc... */

Evaluation

var testData = new TextLoader(_testDataPath).CreateFrom<DepartmentData>(useHeader: true, seperator: ',');
var evaluator = new ClassificationEvaluator();
var metrics = evaluator.Evaluate(model, testData);
Detilium
  • 2,590
  • 5
  • 22
  • 58
  • Shouldn't your `float[]` be a simple `float`? – nvoigt Jul 17 '18 at 09:02
  • @nvoigt No, that causes another exception: `System.InvalidOperationException: 'Can't bind the IDataView column 'Score' of type 'Vec' to field 'Score' of type 'System.Single'.'`, which is why I changed it to an array – Detilium Jul 17 '18 at 09:03
  • I don't suppose you can give a quick sample of the data, can you? – Jon Jul 17 '18 at 14:16
  • Sure I can, I'll update the SO – Detilium Jul 18 '18 at 06:15
  • Running this, I wasn't able to get any error. Here's [a gist](https://gist.github.com/jwood803/55dee80e1d1c7a9c254d9a317b69b3c9) of what I have and the output. – Jon Jul 18 '18 at 15:42
  • @Jon Did you finish the execution? Mine doesn't stop there, but triggers the exception after saying that it won't train a calibrator – Detilium Jul 19 '18 at 10:49
  • I'm having the same problem. Very frustrating – luksfarris Jul 19 '18 at 14:15
  • @Detilium It did finish without any errors. How do you have the project set up? – Jon Jul 20 '18 at 00:52
  • @Jon What do you mean "how do you have tje project set up"? It's a `netcoreapp 2.1`, using `Microsoft.ML 0.3.0`. I don't know what more to tell you, since this is a very small application. – Detilium Jul 20 '18 at 06:32
  • @Jon Oh wow, nevermind. It's my evalutation process that fails, and not the training part. I'm so sorry :/ – Detilium Jul 20 '18 at 06:33
  • @Detilium Can you post the evaluation code? – Jon Jul 21 '18 at 15:03
  • @Jon Sure, I'll update the SO. I did get it to work though, so I'm posting the evaluation code that works, not the one that didn't. – Detilium Jul 23 '18 at 06:37
  • @Detilium it's good that you found an answer yourself. If possible, it would be great to see the code that wasn't working for you – Zruty Aug 10 '18 at 15:33
  • Hi @Detilium I get the same error... OP, do you found a solution? My thread: [topic](https://stackoverflow.com/questions/52335066/ml-net-score-column-is-missing) – michasaucer Sep 14 '18 at 16:03

0 Answers0