Example #1
0
        public static ModelOutput Predict(ModelInput input, string modelFilePath)
        {
            MLContext mlContext = new MLContext();
            string    modelPath = modelFilePath;

            //// Load model & create prediction engine
            ITransformer mlModel    = mlContext.Model.Load(modelPath, out var modelInputSchema);
            var          predEngine = mlContext.Model.CreatePredictionEngine <ModelInput, ModelOutput>(mlModel);

            Console.WriteLine($"number of columns is ======= {modelInputSchema.Count.ToString()}");
            foreach (var item in modelInputSchema)
            {
                Console.WriteLine($"name of column is ========={item.Name}");
            }

            // Console.WriteLine($"count is ======= {modelInputSchema.}");

            // Use model to make prediction on input data
            ModelOutput result = predEngine.Predict(input);

            return(result);
        }