Skip to content

Support ExpandoObject dynamic members for PredictionEngine<TIn,Out> where TIn is an ExpandoObject #5729

Open
@IvoTops

Description

@IvoTops

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<ExpandoObject, ModelPrediction>(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....

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIIssues pertaining the friendly APIP3Doc bugs, questions, minor issues, etc.enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions