0

I am working in a ML project, I have never used C# and specially the ML.NET for this purpose. My question is: What does this line of code mean? I am creating an instance of the class MLContext, but I do not understand the parameters. Seed generates a random number but, what does :0 mean?

var mlContext = new MLContext(seed: 0);
Peter O.
  • 32,158
  • 14
  • 82
  • 96
  • 1
    That's a [named parameter in C#](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments), this would be the same: `var mlContext = new MLContext(0);` – kapsiR Oct 27 '20 at 12:48
  • 1
    We use `seed` to *reproduce* random values generated: if you run the routine again, the result will be the *same*, since random values will be same. If you omit `seed`, the `seed` will be taken from system timer and random values will be different for different runs. `seed` is very useful when *debugging*, *testing* to guarantee same randoms for different executions – Dmitry Bychenko Oct 27 '20 at 12:49
  • Although this is about Java Random generator, the principle of a seed is the same. Does this answer your question? [Java random numbers using a seed](https://stackoverflow.com/questions/12458383/java-random-numbers-using-a-seed) – derpirscher Oct 27 '20 at 12:49
  • @DmitryBychenko thank you very much, now I understand how it works and why I need to use this in my code – Juan Rendon LS Oct 27 '20 at 13:00
  • @derpirscher yes that is thesame principle, now I have fully understand, thank you very much – Juan Rendon LS Oct 27 '20 at 13:01

0 Answers0