4

I am using Microsoft's ML.net library.

I would like to train data based on a model who's contract is generated at run-time (meaning the fields are not known at compile-time). Can this be achieve using the current ML.net's Train() method siganture?

So far i am trying to call this Train method by passing in the instance of the TInput and TOutput objects (rather than the T class).

AlvinfromDiaspar
  • 6,611
  • 13
  • 75
  • 140
  • I'm not sure if this helps or not, but the [TestDatasetInference](https://github.com/dotnet/machinelearning/blob/c023727b76970ab913ec1ce38276508835c17bcf/test/Microsoft.ML.Predictor.Tests/TestDatasetInference.cs) may be of some use. – Jon Jul 23 '18 at 22:31

1 Answers1

2

According to the docs, LearningPipeline only has one method, Train<TIn, TOut> for training, and it implies that TIn and TOut are actual classes: TIn an input to prediction, and TOut an output.

The underlying ML.NET code doesn't actually depend on knowing the schema ahead of time: the Train<TIn, TOut> method is a convenience method that we decided to expose to the users. The side effect of that decision was that we essentially prohibited use cases like yours.

Of course, you can still use Reflection to generate the class signatures at runtime, when you know the schema of the data, but it is an awkward workaround.

The new ML.NET API that we are working on (see issues in this project) would lift this requirement: you will be able to train on data which schema is not known at compile time.

Zruty
  • 8,377
  • 1
  • 25
  • 31