private List <CovidSympomes> GetProfileEntitiesData() { string[] lines = System.IO.File.ReadAllLines(@"Resources/Cleaned-Data.csv"); var profileEntitiesList = new List <CovidSympomes>(); foreach (var line in lines) { var items = line.Split(',').ToList(); var profileEntity = new CovidSympomes(); profileEntity.Fever = Int32.Parse(items[0]); profileEntity.TiredNess = Int32.Parse(items[1]); profileEntity.DryCough = Int32.Parse(items[2]); profileEntity.DifficultyInBreathing = Int32.Parse(items[3]); profileEntity.SoreThroat = Int32.Parse(items[4]); profileEntity.None_Symptom = Int32.Parse(items[5]); profileEntity.Pains = Int32.Parse(items[6]); profileEntity.NasalCongestion = Int32.Parse(items[7]); profileEntity.RunnyNose = Int32.Parse(items[8]); profileEntity.Diarrhea = Int32.Parse(items[9]); profileEntity.Age09 = Int32.Parse(items[11]); profileEntity.Age1019 = Int32.Parse(items[12]); profileEntity.Age2024 = Int32.Parse(items[13]); profileEntity.Age2559 = Int32.Parse(items[14]); profileEntity.Age60 = Int32.Parse(items[15]); profileEntity.Gender = Int32.Parse(items[16]); //0 for male profileEntity.Severity = items[0] == "19" ? 1 : items[20] == "1" ? 2 : items[21] == "1" ? 0 : 4; profileEntity.Contact = Int32.Parse(items[25]); profileEntitiesList.Add(profileEntity); } return(profileEntitiesList); }
private static float Predict(MLContext mlContext, ITransformer model, ProfileEntity userProfile) { var predictionFunction = mlContext.Model.CreatePredictionEngine <CovidSympomes, CovidSeverityPrediction>(model); var covidSymptomesSample = new CovidSympomes() { Age09 = userProfile.Age < 10? 1 : 0, Age1019 = userProfile.Age >= 10 && userProfile.Age < 20 ? 1 : 0, Age2024 = userProfile.Age >= 20 && userProfile.Age < 25 ? 1 : 0, Age2559 = userProfile.Age > 24 && userProfile.Age < 60 ? 1 : 0, Age60 = userProfile.Age > 59 ? 1 : 0, Contact = userProfile.Contact? 1 : 0, Diarrhea = userProfile.HealthState.Diarrhea? 1 : 0, Fever = userProfile.HealthState.Fever? 1 : 0, Gender = userProfile.Gender == "m"? 1 : 0, Pains = userProfile.HealthState.Pains? 1 : 0, Severity = userProfile.HealthState.Severity, DryCough = userProfile.HealthState.DryCough? 1 : 0, NasalCongestion = userProfile.HealthState.NasalCongestion? 1 : 0, None_Symptom = userProfile.HealthState.None_Symptom? 1 : 0, RunnyNose = userProfile.HealthState.RunnyNose? 1 : 0, SoreThroat = userProfile.HealthState.SoreThroat? 1 : 0, TiredNess = userProfile.HealthState.TiredNess? 1 : 0, DifficultyInBreathing = userProfile.HealthState.DifficultyInBreathing ? 1 : 0 }; var prediction = predictionFunction.Predict(covidSymptomesSample); Console.WriteLine($"**********************************************************************"); Console.WriteLine($"Predicted fare: {prediction.Severity:0.####}"); Console.WriteLine($"**********************************************************************"); return(prediction.Severity); }