-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
System information
- OS version/distro: Windows 10
- .NET Version: .NET 4.7.1
Question
I'm looking at a the cs file here: https://www.microsoft.com/net/learn/apps/machine-learning-and-ai/ml-dotnet/get-started/windows and everything works well.
Now I'd like to improve the example: I'd like to predict a number-only data set and not a number-string dataset, for example predict the ouput of a seven segments display.
Here is my super easy dataset, the last column is the int number that I want to predict:
1,0,1,1,1,1,1,0
0,0,0,0,0,1,1,1
1,1,1,0,1,1,0,2
1,1,1,0,0,1,1,3
0,1,0,1,0,1,1,4
1,1,1,1,0,0,1,5
1,1,1,1,1,0,1,6
1,0,0,0,0,1,1,7
1,1,1,1,1,1,1,8
1,1,1,1,0,1,1,9
And here is my test code:
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("Score")] public float[] Score;
}
public PredictDigit()
{
var pipeline = new LearningPipeline();
var dataPath = Path.Combine("Segmenti", "segments.txt");
pipeline.Add(new TextLoader<Digit>(dataPath, false, ","));
pipeline.Add(new ColumnConcatenator("Label", "DigitValue"));
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,
});
Console.WriteLine($"Predicted digit is: {prediction.Score}");
Console.ReadLine();
}
Now the system "works" and I got as prediction.Score
a Single[]
value where the index associated with the higher value is the predicted value. How to obtain exactly the value?
Is it the right approach?
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested