Multi class predicted label shifted by one.
public class Digit
{
[Column("0")] public float Up;
[Column("1")] public float Middle;
[Column("2")] public float Bottom;
[Column("3")] public float UpLeft;
[Column("4")] public float BottomLeft;
[Column("5")] public float TopRight;
[Column("6")] public float BottomRight;
[Column("7")] [ColumnName("Label")] public float Label;
}
public class DigitPrediction
{
[ColumnName("PredictedLabel")]
public uint ExpectedDigit;
[ColumnName("Score")]
public float[] Score;
}
var pipeline = new LearningPipeline();
var data = new Digit[]
{
new Digit { Up = 1, Middle = 0, Bottom = 1, UpLeft = 1, BottomLeft = 1, TopRight = 1, BottomRight = 1, Label = 0 },
new Digit { Up = 0, Middle = 0, Bottom = 0, UpLeft = 0, BottomLeft = 0, TopRight = 1, BottomRight = 1, Label = 1 },
new Digit { Up = 1, Middle = 1, Bottom = 1, UpLeft = 0, BottomLeft = 1, TopRight = 1, BottomRight = 0, Label = 2 },
new Digit { Up = 1, Middle = 1, Bottom = 1, UpLeft = 0, BottomLeft = 0, TopRight = 1, BottomRight = 1, Label = 3 },
new Digit { Up = 0, Middle = 1, Bottom = 0, UpLeft = 1, BottomLeft = 1, TopRight = 1, BottomRight = 1, Label = 4 },
new Digit { Up = 1, Middle = 1, Bottom = 1, UpLeft = 1, BottomLeft = 1, TopRight = 0, BottomRight = 1, Label = 5 },
new Digit { Up = 1, Middle = 1, Bottom = 1, UpLeft = 1, BottomLeft = 1, TopRight = 0, BottomRight = 1, Label = 6 },
new Digit { Up = 1, Middle = 0, Bottom = 0, UpLeft = 0, BottomLeft = 0, TopRight = 1, BottomRight = 1, Label = 7 },
new Digit { Up = 1, Middle = 1, Bottom = 1, UpLeft = 1, BottomLeft = 1, TopRight = 1, BottomRight = 1, Label = 8 },
new Digit { Up = 1, Middle = 1, Bottom = 1, UpLeft = 1, BottomLeft = 0, TopRight = 1, BottomRight = 1, Label = 9 }
};
pipeline.Add(CollectionDataSource.Create(data));
pipeline.Add(new ColumnConcatenator("Features", "Up", "Middle", "Bottom", "UpLeft", "BottomLeft", "TopRight", "BottomRight"));
pipeline.Add(new StochasticDualCoordinateAscentClassifier());
var model = pipeline.Train<Digit, DigitPrediction>();
var prediction = model.Predict(new Digit
{
Up = 1,
Middle = 1,
Bottom = 1,
UpLeft = 1,
BottomLeft = 1,
TopRight = 1,
BottomRight = 1});
I have this wonderful test, but for ExpectedDigit is shifted by 1. I.e if it predict digit 9, it put 10 into expectedDigit
slightly related to #226. @yaeldekel @TomFinley any chance you know why it's +1? https://github.com/dotnet/machinelearning/blob/2bbef1726bda3d60627399b8c4457244597b72ae/src/Microsoft.ML.Data/Scorers/MultiClassClassifierScorer.cs#L569
same for clustering https://github.com/dotnet/machinelearning/blob/35b8134e9d1621783aef5f55afe67daad1aeea81/src/Microsoft.ML.Data/Scorers/ClusteringScorer.cs#L114
Hi @Ivanidzo4ka ... The output is a key value, and it is important for various reasons that the default value of a key value be undefined, rather than any particular class. So if the "default" clustering were the first class.
We probably ought to have a better story for this. Right now the API does not expose this sort of enumeration "well." A language like R has pretty deep support for this concept in the form of factors. I'm not sure how the API should expose this concept, but it's a fairly central one, so we ought to have a better story than just a uint being surfaced somewhere. (We have docs describing key values, but I wrote that more as code rather than user documentation.)
This seems to be a documentation issue: we should document how we handle key types.
And, by the way, this handling has actually changed along the way: as far as I remember, the key values are no longer off by 1, if you use schema comprehension to read the data via AsEnumerable<T>.
This is an old issue and seems to have been fixed in 1.0, as seen in this example.