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(str_data_one);
            object obj_prediction = JsonConvert.DeserializeObject(str_data_two);
            //var prediction = mlContext.Model.CreatePredictionEngine<IrisData, IrisPrediction>(loadedModel).Predict();
            var prediction = mlContext.Model.CreatePredictionEngine<>(loadedModel).predict();
edit: The Tsrc and Tdest are actual classes, not instances of a class or a method. an example is in the commented out code there is IrisData and IrisPrediction, this were the code of each class:
     public class IrisData
    {
        [LoadColumn(0)]
        public float SepalLength;
        [LoadColumn(1)]
        public float SepalWidth;
        [LoadColumn(2)]
        public float PetalLength;
        [LoadColumn(3)]
        public float PetalWidth;
        [LoadColumn(4)]
        public string Label;
    }
    public class IrisPrediction
    {
        [ColumnName("PredictedLabel")]
        public string PredictedLabels;
    }
how would I build the classes above in real time of the program using reflection and adding it to the Tsrc and Tdest?
 
    