dotnet / dotnet/machinelearning
Support ExpandoObject dynamic members for PredictionEngine<TIn,Out> where TIn is an ExpandoObject
- Dominant language
- C#
- Stars
- 9.4k
- Forks
- 2k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 11
Description
The PredictionEngine raises 'Type should contain a member named xyz' when using dynamic properties from an expandoobject that actually does have the member xyz.
_var expando = new ExpandoObject();
// generic code to fill object with lots of properties removed
var predictionEngine = mlContext.Model.CreatePredictionEngine(mlModel, mlSchema);
var prediction = predictionEngine.Predict(expando);_
Please fix this. I train lots of models with each a different and large set of features. Trying to do this with ML.NET now. For training I have a generic solution with my own IDataView where I create dynamic getter functions and use the schemabuilder. That works to train a model and create a schema dynamically supporting thousands of features.
For prediction I have to specify my input as a type like this;
var predictionEngine = mlContext.Model.CreatePredictionEngine<**REQUIREDTYPE**, ModelPrediction>(mlModel, mlSchema);
I do not have type definitions with thousands of fields. It has to be generic. I create an expandoobject and add all the members and values that the engine needs, But it complains that the fields are not there -> 'Type should contain a member named xx'. So that check does not take dynamic properties into account. Support for dynamic properties (or a boolean flag to skip the type check) would open a lot of usecases for flexible featuresets.
Hope someone can fix this test to support also dynamic properties....
Contributor guide
Assessment
This issue has not been assessed yet.