示例#1
0
        public void NaiveBayersNotSpamFalseTest()
        {
            NaiveBayes naiveBayes = new NaiveBayes();
            var        result     = naiveBayes.CheckSMS("Sincerely Mathias");

            Assert.AreEqual(false, result);
            result = naiveBayes.CheckSMS("Dear Graduates");
            Assert.AreEqual(false, result);
            result = naiveBayes.CheckSMS("Thanks in advance for your support");
            Assert.AreEqual(false, result);
            result = naiveBayes.CheckSMS("for it with my Mastercard");
            Assert.AreEqual(false, result);
        }
        private void btnAllCapital_Click(object sender, RoutedEventArgs e)
        {
            SMSReader  reader     = new SMSReader();
            NaiveBayes naiveBayes = new NaiveBayes();
            var        smsList    = reader.Read(@"D:\Nadun.ML.SpamDetector\Nadun.ML.SpamDetectEngine\Data\evaluating.csv");

            TotalMessages = smsList.Count - 1;

            foreach (var sms in smsList)
            {
                if (naiveBayes.CheckSMS(sms.Message, 1))
                {
                    sms.PredictedType = "spam";
                }
                else
                {
                    sms.PredictedType = "ham";
                }

                if (sms.PredictedType == sms.ActualType)
                {
                    CorrectlyPredicted += 1;
                }
            }
            dataGrid.DataContext        = this;
            dataGrid.ItemsSource        = smsList;
            progressBar.IsIndeterminate = false;
            CorrectPercentage           = Math.Round((decimal)(((decimal)CorrectlyPredicted / (decimal)TotalMessages)) * 100, 2, MidpointRounding.AwayFromZero);
            txtPercCorrect.Text         = CorrectPercentage.ToString();
            txtTotalNoMsg.Text          = TotalMessages.ToString();
        }