public static async Task Main(ApplicationDbContext dbContext) { //var dbContext = new ApplicationDbContext(); ImotBgDataGatherer t = new ImotBgDataGatherer(dbContext); // await t.GatherData(30, 32); Console.OutputEncoding = Encoding.UTF8; var modelFile = "SofiaPropertiesModel.zip"; if (!File.Exists(modelFile)) { TrainModel(dbContext, modelFile); } var testModelData = new ModelInput { BuildingType = "2-СТАЕН", District = "град София, Надежда 1", Floor = 2, TotalFloors = 9, Size = 58, Year = 2014, Type = "Тухла", }; testModelData.Dump(); TestModel(testModelData); }
public static float TestModel(ModelInput testModelData) { var modelFile = "SofiaPropertiesModel.zip"; var context = new MLContext(); var model = context.Model.Load(modelFile, out _); var predictionEngine = context.Model.CreatePredictionEngine <ModelInput, ModelOutput>(model); float score = 0; //foreach (var testData in testModelData) //{ var prediction = predictionEngine.Predict(testModelData); score = prediction.Score; return(score); Console.WriteLine(new string('-', 60)); Console.WriteLine($"Input: {testModelData.Dump()}"); Console.WriteLine($"Prediction: {prediction.Score}"); //} }