public ResultModel TestNewData(IList<TestData> data)
 {
     var result = new ResultModel();
     var probabilityResultList = new List<ProbabilityResult>();
     for (var i = 0; i < _naiveBayesModel.TargetAttributeClasses.Count; i++)
         CalculateProbability(data, i, ref probabilityResultList);
     var sumProbabilities = probabilityResultList.Select(x => x.Probability).Sum();
     foreach (var probability in probabilityResultList)
         probability.Percentage = (probability.Probability/sumProbabilities)*100;
     var greaterProbability = probabilityResultList.OrderByDescending(x => x.Percentage).First();
     result.ResultAttribute = greaterProbability.ClassName;
     result.Values = greaterProbability.Percentage;
     return result;
 }
Exemple #2
0
 private static void PrintResultValue(ResultModel result)
 {
     Console.WriteLine("the recommended drug is : " + result.ResultAttribute);
     Console.WriteLine("the porcentage of accuracy is: " + result.Values.ToString(CultureInfo.InvariantCulture));
 }