mardi 7 mai 2019

Is it possible to dynamically add the Tsrc and Tdest in CreatePredictionEngine<>?

I am currently trying to dynamically change the Tsrc and Tdest in MlContext.Model.CreatePredictionEngine<>(ITransformer); in ML.net. So instead of having a class for data structure (Tsrc) and a class for the prediction (Tdesc) in the code, could I somehow dynamically add the classes probably with reflection?

I have tried to load an object using JsonConvert.deseralize() and get the type of that object to be the Tsrc and Tdest.

            ITransformer loadedModel = mlContext.Model.Load(modelPath, out var schema);
            List<DataViewSchema.Column?> columnData = new List<DataViewSchema.Column?>();
            foreach (string col in columns)
            {
                DataViewSchema.Column? sch = schema.GetColumnOrNull(col);
                columnData.Add(sch);
            }
            object obj_data = JsonConvert.DeserializeObject(" ");
            object obj_prediction = JsonConvert.DeserializeObject(" ");



            //var prediction = mlContext.Model.CreatePredictionEngine<IrisData, IrisPrediction>(loadedModel).Predict();
            var prediction = mlContext.Model.CreatePredictionEngine<>(loadedModel).predict();





Aucun commentaire:

Enregistrer un commentaire