Sequence prediction in C# using Machine Learning. (1 of many…)
0.4 + 0.4 = 0.79 … well done!
Jokes aside, this is an example of how to use machine learning in C# to predict sequences, in this case to say the sequence of two inputs should result in the sum of the two inputs.
TLDR; the Github repo is here : https://github.com/infiniteloopltd/SharpML-Recurrent
It is 99.9% based on Andrew Fry’s code, but I have modified the dataset generator, that instead of modelling an XOR gate, it models a simple adder. I noticed that the values have to be between 0 and 1, but I guess, you just shift your range to that.
private static List<DataSequence> GetTrainingData()
{var result = new List<DataSequence>();
for (var a = 0.0; a < 0.5; a += 0.1)
{
for (var b = 0.0; b < 0.5; b += 0.1)
{
var sum = a + b;
result.Add(new DataSequence(new List<DataStep>() { new DataStep(new[] { a, b }, new[] { sum }) }));
}
}return result;
}
This simply provides a dataset of every combination of numbers in 0.1 increments between 0 and 0.5, and indicates the sum.
Obviously this training data can be improved, but it’s just a proof of concept, as you can imagine!
Next step is to add another dimension to the output. But that’s work for another day!